Skip to content

Commit

Permalink
fix: change cfgfile field name (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
hysyeah authored Nov 14, 2024
1 parent 6f122e5 commit 5a35195
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cmd/devbox/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func main() {
rootCmd := &cobra.Command{
Use: "devbox",
Short: "DevBox",
Long: `The DevBox is a Terminus App dev tools`,
Long: `The DevBox is a Olares App dev tools`,
}

serverCmd := &cobra.Command{
Expand Down
18 changes: 9 additions & 9 deletions pkg/api/server/handlers_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (h *handlers) getAppConfig(ctx *fiber.Ctx) error {
klog.Error("read app cfg error, ", err, ", ", app, ", ", appCfgPath)
return ctx.JSON(fiber.Map{
"code": http.StatusBadRequest,
"message": fmt.Sprintf("Read TerminusManifest.yaml failed: %v", err),
"message": fmt.Sprintf("Read OlaresManifest.yaml failed: %v", err),
})
}

Expand All @@ -54,7 +54,7 @@ func (h *handlers) getAppConfig(ctx *fiber.Ctx) error {
klog.Error(string(data))
return ctx.JSON(fiber.Map{
"code": http.StatusBadRequest,
"message": fmt.Sprintf("Parse TerminusManifest.yaml failed: %v", err),
"message": fmt.Sprintf("Parse OlaresManifest.yaml failed: %v", err),
})
}

Expand Down Expand Up @@ -82,20 +82,20 @@ func (h *handlers) updateAppConfig(ctx *fiber.Ctx) error {
klog.Error("read app cfg post data error, ", err)
return ctx.JSON(fiber.Map{
"code": http.StatusBadRequest,
"message": fmt.Sprintf("TerminusManifest.yaml has errors: %v", err),
"message": fmt.Sprintf("OlaresManifest.yaml has errors: %v", err),
})
}
data, err := yaml.Marshal(&appcfg)
if err != nil {
klog.Error("parse post app cfg error, ", err)
return ctx.JSON(fiber.Map{
"code": http.StatusBadRequest,
"message": fmt.Sprintf("TerminusManifest.yaml has errors: %v", err),
"message": fmt.Sprintf("OlaresManifest.yaml has errors: %v", err),
})
}
appCfg := filepath.Join(path, constants.AppCfgFileName)
uniquePath := uuid.NewString()
appCfgBak := filepath.Join("/tmp", uniquePath, "TerminusManifest.yaml.bak")
appCfgBak := filepath.Join("/tmp", uniquePath, "OlaresManifest.yaml.bak")
chartDeferFunc, err := command.BackupAndRestoreFile(appCfg, appCfgBak)
if err != nil {
return ctx.JSON(fiber.Map{
Expand All @@ -109,15 +109,15 @@ func (h *handlers) updateAppConfig(ctx *fiber.Ctx) error {
klog.Error("save app cfg to file error, ", err, ", ", appCfgPath)
return ctx.JSON(fiber.Map{
"code": http.StatusBadRequest,
"message": fmt.Sprintf("Save TerminusManifest.yaml error: %v", err),
"message": fmt.Sprintf("Save OlaresManifest.yaml error: %v", err),
})
}
output, err := command.CheckCfg().WithDir(BaseDir).Run(ctx.Context(), app)
if err != nil {
klog.Error("check app cfg error, ", err)
return ctx.JSON(fiber.Map{
"code": http.StatusBadRequest,
"message": fmt.Sprintf("TerminusManifest.yaml has errors: %v", err),
"message": fmt.Sprintf("OlaresManifest.yaml has errors: %v", err),
})
}
if len(output) > 0 {
Expand Down Expand Up @@ -406,7 +406,7 @@ func (h *handlers) listAppContainersInChart(ctx *fiber.Ctx) error {
klog.Error("read app cfg error, ", err, ", ", app, ", ", appCfgPath)
return ctx.JSON(fiber.Map{
"code": http.StatusBadRequest,
"message": fmt.Sprintf("Read TerminusManifest.yaml failed: %v", err),
"message": fmt.Sprintf("Read OlaresManifest.yaml failed: %v", err),
})
}

Expand All @@ -417,7 +417,7 @@ func (h *handlers) listAppContainersInChart(ctx *fiber.Ctx) error {
klog.Error(string(data))
return ctx.JSON(fiber.Map{
"code": http.StatusBadRequest,
"message": fmt.Sprintf("Parse TerminusManifest.yaml failed: %v", err),
"message": fmt.Sprintf("Parse OlaresManifest.yaml failed: %v", err),
})
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/api/server/handlers_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ func (h *handlers) createDevApp(ctx *fiber.Ctx) error {
output, err := command.CheckCfg().WithDir(BaseDir).Run(ctx.Context(), config.Name)
if err != nil {

klog.Error("check TerminusManifest.yaml error, ", err, ", ", config)
klog.Error("check OlaresManifest.yaml error, ", err, ", ", config)
return ctx.JSON(fiber.Map{
"code": http.StatusBadRequest,
"message": fmt.Sprintf("TerminusManifest.yaml has error: %v", err),
"message": fmt.Sprintf("OlaresManifest.yaml has error: %v", err),
})
}
if len(output) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func readCfgFromFile(chartDir string) (*application.AppConfiguration, error) {
cfgFile := findAppCfgFile(chartDir)
klog.Infof("readCfgFromFile: %s", cfgFile)
if len(cfgFile) == 0 {
return nil, errors.New("not found TerminusManifest.yaml file")
return nil, errors.New("not found OlaresManifest.yaml file")
}
appcfg, err := readAppInfo(cfgFile)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

const (
DevOwnerLabel = "dev.bytetrade.io/dev-owner"
AppCfgFileName = "TerminusManifest.yaml"
AppCfgFileName = "OlaresManifest.yaml"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions pkg/development/application/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type AppMetaData struct {
}

type AppConfiguration struct {
ConfigVersion string `yaml:"terminusManifest.version" json:"terminusManifest.version"`
ConfigType string `yaml:"terminusManifest.type" json:"terminusManifest.type"`
ConfigVersion string `yaml:"olaresManifest.version" json:"olaresManifest.version"`
ConfigType string `yaml:"olaresManifest.type" json:"olaresManifest.type"`
Metadata AppMetaData `yaml:"metadata" json:"metadata"`
Entrances []Entrance `yaml:"entrances" json:"entrances"`
Spec AppSpec `yaml:"spec" json:"spec"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/development/command/updaterepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ func (c *updateRepo) Run(ctx context.Context, app string, notExist bool) error {
if !notExist {
err = helm.UpdateAppCfgVersion(realPath, &newVersion)
if err != nil {
klog.Error("update TerminusManifest.yaml metadata.version error, ", err)
klog.Error("update OlaresManifest.yaml metadata.version error, ", err)
return err
}
}

appcfg := filepath.Join(realPath, constants.AppCfgFileName)
appcfgBak := filepath.Join(realPath, "TerminusManifest.yaml.bak")
appcfgBak := filepath.Join(realPath, "OlaresManifest.yaml.bak")
appcfgDeferFunc, err := backupAndRestoreFile(appcfg, appcfgBak)
if err != nil {
return err
Expand Down
10 changes: 5 additions & 5 deletions pkg/development/helm/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func UpdateAppCfgVersion(path string, version *semver.Version) error {
}
err = os.WriteFile(appCfgYaml, data, 0644)
if err != nil {
klog.Error("write file TerminusManifest.yaml error, ", err)
klog.Error("write file OlaresManifest.yaml error, ", err)
return err
}

Expand All @@ -155,7 +155,7 @@ func UpdateAppCfgName(name, path string) error {
var appCfg application.AppConfiguration
err = yaml.Unmarshal(data, &appCfg)
if err != nil {
klog.Error("parse TerminusManifest.yaml error, ", err)
klog.Error("parse OlaresManifest.yaml error, ", err)
return err
}

Expand All @@ -178,7 +178,7 @@ func UpdateAppCfgName(name, path string) error {

err = os.WriteFile(appCfgYaml, data, 0644)
if err != nil {
klog.Error("write file TerminusManifest.yaml error, ", err)
klog.Error("write file OlaresManifest.yaml error, ", err)
return err
}

Expand Down Expand Up @@ -398,14 +398,14 @@ func GetAppCfg(app string, baseDir string) (*application.AppConfiguration, error
appCfgYaml := filepath.Join(realPath, constants.AppCfgFileName)
data, err := os.ReadFile(appCfgYaml)
if err != nil {
klog.Error("read TerminusManifest.yaml error, ", err, ", ", appCfgYaml)
klog.Error("read OlaresManifest.yaml error, ", err, ", ", appCfgYaml)
return nil, err
}

var appCfg application.AppConfiguration
err = yaml.Unmarshal(data, &appCfg)
if err != nil {
klog.Error("parse TerminusManifest.yaml error, ", err)
klog.Error("parse OlaresManifest.yaml error, ", err)
return nil, err
}

Expand Down

0 comments on commit 5a35195

Please sign in to comment.