diff --git a/cmd/commands/check.go b/cmd/commands/check.go index 02965ce..2e96683 100644 --- a/cmd/commands/check.go +++ b/cmd/commands/check.go @@ -55,10 +55,13 @@ func etcExecute(ls []LocalServices) { for _, service := range ls { yamlUrl := fmt.Sprintf("%s%s/%s/%s_%s.yaml", service.Srv.OssUrl, service.Srv.EtcPath, env.MeshEnv.Workspace, service.Srv.ServiceKey, env.MeshEnv.RuntimeMode) body, err := utils.HttpGet(yamlUrl) - checkError(err) - fmt.Println("Check YAML Configure:", yamlUrl, " [OK]") - yamlPath := filepath.Join(env.MeshEnv.Prefix, service.Srv.EtcPath, fmt.Sprintf("%s_%s.yaml", service.Srv.ServiceKey, env.MeshEnv.RuntimeMode)) - utils.StringToFile(yamlPath, string(body)) + if err != nil { + fmt.Println("Check YAML Configure:", yamlUrl, " [ERROR]", err.Error()) + } else { + fmt.Println("Check YAML Configure:", yamlUrl, " [OK]") + yamlPath := filepath.Join(env.MeshEnv.Prefix, service.Srv.EtcPath, fmt.Sprintf("%s_%s.yaml", service.Srv.ServiceKey, env.MeshEnv.RuntimeMode)) + utils.StringToFile(yamlPath, string(body)) + } } } @@ -66,15 +69,26 @@ func getLocalServices() []LocalServices { reles := getRegistryReleases() dirFs, err := os.ReadDir(env.MeshEnv.Prefix) - checkError(err) ls := make([]LocalServices, 0) - for _, v := range dirFs { - version := getCurrentVersion(v.Name()) - if version != " - " { - for _, srv := range reles.Data { + + checkError(err) + + for _, v := range reles.Data { + var check bool = false + for _, srv := range dirFs { + if v.ServiceKey == srv.Name() { + check = true + break + } + } + + if check { + version := getCurrentVersion(v.ServiceKey) + if version != " - " { + ls = append(ls, LocalServices{ - Srv: srv, + Srv: v, LocalVersion: version, }) }