fix: yaml tag

master v1.0.4
icechen 2022-01-11 00:03:14 +08:00
parent 7f8bb65be3
commit 0540fcd17f
7 changed files with 20 additions and 20 deletions

4
api.go
View File

@ -24,7 +24,7 @@ func ActionListApi(c *cli.Context) error {
} }
color.Green("API应用列表:") color.Green("API应用列表:")
for _, api := range config.Config.HasApi { 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.Root)
color.Green("\t\t类型:\t%s", api.Type) color.Green("\t\t类型:\t%s", api.Type)
color.Green("\t\t端口:\t%s", api.Port) color.Green("\t\t端口:\t%s", api.Port)
@ -72,7 +72,7 @@ func ActionNewApi(c *cli.Context) error {
color.Green("正在创建[%s]API应用...", newApp) color.Green("正在创建[%s]API应用...", newApp)
app := config.Config.Api.GetApp(namespace, newApp) app := config.Config.Api.GetApp(namespace, newApp)
app = config.Api{ app = config.Api{
NameSpace: namespace, Namespace: namespace,
Name: newApp, Name: newApp,
Root: fmt.Sprintf("app/%s/api/%s", namespace, newApp), Root: fmt.Sprintf("app/%s/api/%s", namespace, newApp),
} }

View File

@ -1,13 +1,11 @@
package config package config
import ( import (
"github.com/urfave/cli/v2"
"gopkg.in/yaml.v3"
"io/ioutil" "io/ioutil"
"git.icechen.cn/pkg/wujian_develop_tool/util" "git.icechen.cn/pkg/wujian_develop_tool/util"
"github.com/urfave/cli/v2"
"gopkg.in/yaml.v3"
) )
var DefaultConfigFile = ".drone.yml" var DefaultConfigFile = ".drone.yml"
@ -43,9 +41,9 @@ type ConfigFile struct {
type ( type (
ApiList []Api ApiList []Api
Api struct { Api struct {
NameSpace string `json:"name_space" yaml:"nameSpace"` Namespace string `json:"namespace" yaml:"namespace"`
Name string `json:"name" yaml:"name"` 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"` Root string `json:"root" yaml:"root"`
Type string `json:"type" yaml:"type"` Type string `json:"type" yaml:"type"`
Port string `json:"port" yaml:"port"` Port string `json:"port" yaml:"port"`
@ -57,9 +55,9 @@ type (
type ( type (
ServiceList []Service ServiceList []Service
Service struct { Service struct {
NameSpace string `json:"name_space" yaml:"nameSpace"` Namespace string `json:"namespace" yaml:"namespace"`
Name string `json:"name" yaml:"name"` 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"` Root string `json:"root" yaml:"root"`
Type string `json:"type" yaml:"type"` Type string `json:"type" yaml:"type"`
Port string `json:"port" yaml:"port"` Port string `json:"port" yaml:"port"`
@ -83,7 +81,7 @@ func ReadConfig() error {
func (c *ConfigFile) AppendAPI(api Api) error { func (c *ConfigFile) AppendAPI(api Api) error {
has := false has := false
for i, a := range c.Api { 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 c.Api[i] = api
has = true has = true
break break
@ -105,7 +103,7 @@ func (c *ConfigFile) AppendAPI(api Api) error {
func (c *ConfigFile) AppendService(service Service) error { func (c *ConfigFile) AppendService(service Service) error {
has := false has := false
for i, s := range c.Service { 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 c.Service[i] = service
has = true has = true
break break
@ -145,7 +143,7 @@ al:
func (sl ApiList) GetApp(namespace, appName string) Api { func (sl ApiList) GetApp(namespace, appName string) Api {
for _, api := range sl { for _, api := range sl {
if api.Name == appName && api.NameSpace == namespace { if api.Name == appName && api.Namespace == namespace {
return api return api
} }
} }
@ -173,7 +171,7 @@ sl:
func (sl ServiceList) GetApp(namespace, appName string) Service { func (sl ServiceList) GetApp(namespace, appName string) Service {
for _, service := range sl { for _, service := range sl {
if service.Name == appName && service.NameSpace == namespace { if service.Name == appName && service.Namespace == namespace {
return service return service
} }
} }

1
go.mod
View File

@ -21,4 +21,5 @@ require (
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
google.golang.org/appengine v1.6.7 // indirect google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
) )

3
go.sum
View File

@ -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/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.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.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.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 h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 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= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

View File

@ -24,7 +24,7 @@ func ActionListService(c *cli.Context) error {
} }
color.Green("Service应用列表:") color.Green("Service应用列表:")
for _, service := range config.Config.HasService { 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.Root)
color.Green("\t\t类型:\t%s", service.Type) color.Green("\t\t类型:\t%s", service.Type)
color.Green("\t\t端口:\t%s", service.Port) color.Green("\t\t端口:\t%s", service.Port)
@ -72,7 +72,7 @@ func ActionNewService(c *cli.Context) error {
color.Green("正在创建[%s]Service应用...", newApp) color.Green("正在创建[%s]Service应用...", newApp)
app := config.Config.Service.GetApp(namespace, newApp) app := config.Config.Service.GetApp(namespace, newApp)
app = config.Service{ app = config.Service{
NameSpace: namespace, Namespace: namespace,
Name: newApp, Name: newApp,
Root: fmt.Sprintf("app/%s/service/%s", namespace, newApp), Root: fmt.Sprintf("app/%s/service/%s", namespace, newApp),
} }

View File

@ -32,11 +32,11 @@ func GenDeploy(api config.Api) error {
path := api.Path path := api.Path
if 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{ data := map[string]string{
"NameSpace": api.NameSpace, "NameSpace": api.Namespace,
"AppName": api.Name, "AppName": api.Name,
"AliasName": api.AliasName, "AliasName": api.AliasName,
"Port": api.Port, "Port": api.Port,

View File

@ -26,7 +26,7 @@ func GenDeploy(service config.Service) error {
} }
data := map[string]string{ data := map[string]string{
"NameSpace": service.NameSpace, "NameSpace": service.Namespace,
"AppName": service.Name, "AppName": service.Name,
"AliasName": service.AliasName, "AliasName": service.AliasName,
"Port": service.Port, "Port": service.Port,