parent
7f8bb65be3
commit
0540fcd17f
4
api.go
4
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),
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
1
go.mod
1
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
|
||||
)
|
||||
|
|
3
go.sum
3
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=
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue