1. diff
2. namespace
This commit is contained in:
2022-01-10 20:26:14 +08:00
parent 5826eef7bf
commit 7f8bb65be3
14 changed files with 141 additions and 83 deletions
+10 -7
View File
@@ -1,9 +1,10 @@
package config
import (
"git.icechen.cn/pkg/wujian_develop_tool/util"
"io/ioutil"
"git.icechen.cn/pkg/wujian_develop_tool/util"
"github.com/urfave/cli/v2"
"gopkg.in/yaml.v3"
@@ -42,6 +43,7 @@ type ConfigFile struct {
type (
ApiList []Api
Api struct {
NameSpace string `json:"name_space" yaml:"nameSpace"`
Name string `json:"name" yaml:"name"`
AliasName string `json:"alias_name" yaml:"aliasName"`
Root string `json:"root" yaml:"root"`
@@ -55,6 +57,7 @@ type (
type (
ServiceList []Service
Service struct {
NameSpace string `json:"name_space" yaml:"nameSpace"`
Name string `json:"name" yaml:"name"`
AliasName string `json:"alias_name" yaml:"aliasName"`
Root string `json:"root" yaml:"root"`
@@ -80,7 +83,7 @@ func ReadConfig() error {
func (c *ConfigFile) AppendAPI(api Api) error {
has := false
for i, a := range c.Api {
if a.Name == api.Name {
if a.Name == api.Name && a.NameSpace == api.NameSpace {
c.Api[i] = api
has = true
break
@@ -102,7 +105,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 {
if s.Name == service.Name && s.NameSpace == service.NameSpace {
c.Service[i] = service
has = true
break
@@ -140,9 +143,9 @@ al:
return hasApp
}
func (sl ApiList) GetApp(appName string) Api {
func (sl ApiList) GetApp(namespace, appName string) Api {
for _, api := range sl {
if api.Name == appName {
if api.Name == appName && api.NameSpace == namespace {
return api
}
}
@@ -168,9 +171,9 @@ sl:
return hasApp
}
func (sl ServiceList) GetApp(appName string) Service {
func (sl ServiceList) GetApp(namespace, appName string) Service {
for _, service := range sl {
if service.Name == appName {
if service.Name == appName && service.NameSpace == namespace {
return service
}
}