From 0540fcd17f513963c1d90af2a04052cbca17f352 Mon Sep 17 00:00:00 2001 From: icechen Date: Tue, 11 Jan 2022 00:03:14 +0800 Subject: [PATCH] fix: yaml tag --- api.go | 4 ++-- config/configFile.go | 22 ++++++++++------------ go.mod | 1 + go.sum | 3 ++- service.go | 4 ++-- template/api/deploy/deoloy.go | 4 ++-- template/service/deploy/deoloy.go | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/api.go b/api.go index 4198981..bb26daf 100644 --- a/api.go +++ b/api.go @@ -24,7 +24,7 @@ func ActionListApi(c *cli.Context) error { } color.Green("API应用列表:") for _, api := range config.Config.HasApi { - color.Green("\t%s.%s", api.Name, api.NameSpace) + color.Green("\t%s.%s", api.Name, api.Namespace) color.Green("\t\t路径:\t%s", api.Root) color.Green("\t\t类型:\t%s", api.Type) color.Green("\t\t端口:\t%s", api.Port) @@ -72,7 +72,7 @@ func ActionNewApi(c *cli.Context) error { color.Green("正在创建[%s]API应用...", newApp) app := config.Config.Api.GetApp(namespace, newApp) app = config.Api{ - NameSpace: namespace, + Namespace: namespace, Name: newApp, Root: fmt.Sprintf("app/%s/api/%s", namespace, newApp), } diff --git a/config/configFile.go b/config/configFile.go index 7753498..b208caa 100644 --- a/config/configFile.go +++ b/config/configFile.go @@ -1,13 +1,11 @@ package config import ( + "github.com/urfave/cli/v2" + "gopkg.in/yaml.v3" "io/ioutil" "git.icechen.cn/pkg/wujian_develop_tool/util" - - "github.com/urfave/cli/v2" - - "gopkg.in/yaml.v3" ) var DefaultConfigFile = ".drone.yml" @@ -43,9 +41,9 @@ type ConfigFile struct { type ( ApiList []Api Api struct { - NameSpace string `json:"name_space" yaml:"nameSpace"` + Namespace string `json:"namespace" yaml:"namespace"` Name string `json:"name" yaml:"name"` - AliasName string `json:"alias_name" yaml:"aliasName"` + AliasName string `json:"alias_name" yaml:"alias_name"` Root string `json:"root" yaml:"root"` Type string `json:"type" yaml:"type"` Port string `json:"port" yaml:"port"` @@ -57,9 +55,9 @@ type ( type ( ServiceList []Service Service struct { - NameSpace string `json:"name_space" yaml:"nameSpace"` + Namespace string `json:"namespace" yaml:"namespace"` Name string `json:"name" yaml:"name"` - AliasName string `json:"alias_name" yaml:"aliasName"` + AliasName string `json:"alias_name" yaml:"alias_name"` Root string `json:"root" yaml:"root"` Type string `json:"type" yaml:"type"` Port string `json:"port" yaml:"port"` @@ -83,7 +81,7 @@ func ReadConfig() error { func (c *ConfigFile) AppendAPI(api Api) error { has := false for i, a := range c.Api { - if a.Name == api.Name && a.NameSpace == api.NameSpace { + if a.Name == api.Name && a.Namespace == api.Namespace { c.Api[i] = api has = true break @@ -105,7 +103,7 @@ func (c *ConfigFile) AppendAPI(api Api) error { func (c *ConfigFile) AppendService(service Service) error { has := false for i, s := range c.Service { - if s.Name == service.Name && s.NameSpace == service.NameSpace { + if s.Name == service.Name && s.Namespace == service.Namespace { c.Service[i] = service has = true break @@ -145,7 +143,7 @@ al: func (sl ApiList) GetApp(namespace, appName string) Api { for _, api := range sl { - if api.Name == appName && api.NameSpace == namespace { + if api.Name == appName && api.Namespace == namespace { return api } } @@ -173,7 +171,7 @@ sl: func (sl ServiceList) GetApp(namespace, appName string) Service { for _, service := range sl { - if service.Name == appName && service.NameSpace == namespace { + if service.Name == appName && service.Namespace == namespace { return service } } diff --git a/go.mod b/go.mod index 749e5f2..b64f29d 100644 --- a/go.mod +++ b/go.mod @@ -21,4 +21,5 @@ require ( golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.27.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 9112480..8f773ee 100644 --- a/go.sum +++ b/go.sum @@ -398,8 +398,9 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/service.go b/service.go index 0dbba73..f3e9ec5 100644 --- a/service.go +++ b/service.go @@ -24,7 +24,7 @@ func ActionListService(c *cli.Context) error { } color.Green("Service应用列表:") for _, service := range config.Config.HasService { - color.Green("\t%s.%s", service.Name, service.NameSpace) + color.Green("\t%s.%s", service.Name, service.Namespace) color.Green("\t\t路径:\t%s", service.Root) color.Green("\t\t类型:\t%s", service.Type) color.Green("\t\t端口:\t%s", service.Port) @@ -72,7 +72,7 @@ func ActionNewService(c *cli.Context) error { color.Green("正在创建[%s]Service应用...", newApp) app := config.Config.Service.GetApp(namespace, newApp) app = config.Service{ - NameSpace: namespace, + Namespace: namespace, Name: newApp, Root: fmt.Sprintf("app/%s/service/%s", namespace, newApp), } diff --git a/template/api/deploy/deoloy.go b/template/api/deploy/deoloy.go index 925f1ab..36af76a 100644 --- a/template/api/deploy/deoloy.go +++ b/template/api/deploy/deoloy.go @@ -32,11 +32,11 @@ func GenDeploy(api config.Api) error { path := api.Path if path == "" { - path = fmt.Sprintf("/%s/%s/?(.*)", api.NameSpace, api.Name) + path = fmt.Sprintf("/%s/%s/?(.*)", api.Namespace, api.Name) } data := map[string]string{ - "NameSpace": api.NameSpace, + "NameSpace": api.Namespace, "AppName": api.Name, "AliasName": api.AliasName, "Port": api.Port, diff --git a/template/service/deploy/deoloy.go b/template/service/deploy/deoloy.go index 34411ff..fee7394 100644 --- a/template/service/deploy/deoloy.go +++ b/template/service/deploy/deoloy.go @@ -26,7 +26,7 @@ func GenDeploy(service config.Service) error { } data := map[string]string{ - "NameSpace": service.NameSpace, + "NameSpace": service.Namespace, "AppName": service.Name, "AliasName": service.AliasName, "Port": service.Port,