package go_handler import ( "bytes" "text/template" "git.icechen.cn/pkg/drone_plugin/config" "git.icechen.cn/pkg/drone_plugin/go_handler/go_handler_template" "git.icechen.cn/pkg/drone_plugin/consts" ) type GoServiceHandler struct { NameSpace string Name string AliasName string Root string Port string DeployEnv consts.Env Reg config.Registry Kube config.KubeConfig } func (gsh GoServiceHandler) ToDestinationConfig() (string, error) { var err error t := template.New(gsh.Name) gsh.Reg = config.GetRegistryConfig() servicePipeline := go_handler_template.ServiceTestPipeline gsh.Kube = config.GetTestKubeConfigByNamespace(gsh.NameSpace) if gsh.DeployEnv == consts.EnvProduction { servicePipeline = go_handler_template.ServiceProductionPipeline gsh.Kube = config.GetOnlKubeConfigByNamespace(gsh.NameSpace) } t, err = t.Parse(servicePipeline) if err != nil { return "", err } b := bytes.Buffer{} err = t.Execute(&b, gsh) if err != nil { return "", err } return b.String(), nil }