diff --git a/internal/pkg/github/deployment.go b/internal/pkg/github/deployment.go index cd5d8943..0478b46e 100644 --- a/internal/pkg/github/deployment.go +++ b/internal/pkg/github/deployment.go @@ -93,7 +93,7 @@ func (g *Github) GetConfig(ctx context.Context, u *ent.User, r *ent.Repo) (*exte c := &extent.Config{} if err := extent.UnmarshalYAML([]byte(content), c); err != nil { return nil, e.NewError( - e.ErrorCodeConfigParseError, + e.ErrorCodeConfigInvalid, err, ) } diff --git a/model/extent/config.go b/model/extent/config.go index 8874bbe6..efdd5b4c 100644 --- a/model/extent/config.go +++ b/model/extent/config.go @@ -65,7 +65,7 @@ const ( func UnmarshalYAML(content []byte, c *Config) error { if err := yaml.Unmarshal([]byte(content), c); err != nil { - return eutil.NewError(eutil.ErrorCodeConfigParseError, err) + return eutil.NewError(eutil.ErrorCodeConfigInvalid, err) } c.source = content @@ -101,11 +101,11 @@ func (c *Config) Eval(v *EvalValues) error { evalued, err := envsubst.Eval(string(c.source), mapper) if err != nil { - return eutil.NewError(eutil.ErrorCodeConfigParseError, err) + return eutil.NewError(eutil.ErrorCodeConfigInvalid, err) } if err := yaml.Unmarshal([]byte(evalued), c); err != nil { - return eutil.NewError(eutil.ErrorCodeConfigParseError, err) + return eutil.NewError(eutil.ErrorCodeConfigInvalid, err) } return nil @@ -144,7 +144,7 @@ func (e *Env) IsDeployableRef(ref string) (bool, error) { matched, err := regexp.MatchString(*e.DeployableRef, ref) if err != nil { - return false, eutil.NewError(eutil.ErrorCodeConfigRegexpError, err) + return false, eutil.NewError(eutil.ErrorCodeConfigInvalid, err) } return matched, nil @@ -158,7 +158,7 @@ func (e *Env) IsAutoDeployOn(ref string) (bool, error) { matched, err := regexp.MatchString(*e.AutoDeployOn, ref) if err != nil { - return false, eutil.NewError(eutil.ErrorCodeConfigRegexpError, err) + return false, eutil.NewError(eutil.ErrorCodeConfigInvalid, err) } return matched, nil diff --git a/pkg/e/code.go b/pkg/e/code.go index 6051057d..50b54096 100644 --- a/pkg/e/code.go +++ b/pkg/e/code.go @@ -6,12 +6,10 @@ import ( ) const ( - // ErrorCodeConfigParseError is that an error occurs when it parse the file. - ErrorCodeConfigParseError ErrorCode = "config_parse_error" + // ErrorCodeConfigInvalid is that an error occurs when it parse the file. + ErrorCodeConfigInvalid ErrorCode = "config_parse_error" // ErrorCodeConfigUndefinedEnv is that the environment is not defined in the configuration file. ErrorCodeConfigUndefinedEnv ErrorCode = "config_undefined_env" - // ErrorCodeConfigRegexpError is the regexp(re2) is invalid. - ErrorCodeConfigRegexpError ErrorCode = "config_regexp_error" // ErrorCodeDeploymentConflict is the deployment number is conflicted. ErrorCodeDeploymentConflict ErrorCode = "deployment_conflict" diff --git a/pkg/e/trans.go b/pkg/e/trans.go index e19a8db2..088747cd 100644 --- a/pkg/e/trans.go +++ b/pkg/e/trans.go @@ -3,9 +3,8 @@ package e import "net/http" var messages = map[ErrorCode]string{ - ErrorCodeConfigParseError: "The configuration is invalid.", + ErrorCodeConfigInvalid: "The configuration is invalid.", ErrorCodeConfigUndefinedEnv: "The environment is not defined in the configuration.", - ErrorCodeConfigRegexpError: "The regexp is invalid.", ErrorCodeDeploymentConflict: "The conflict occurs, please retry.", ErrorCodeDeploymentInvalid: "The validation has failed.", ErrorCodeDeploymentLocked: "The environment is locked.", @@ -31,9 +30,8 @@ func GetMessage(code ErrorCode) string { } var httpCodes = map[ErrorCode]int{ - ErrorCodeConfigParseError: http.StatusUnprocessableEntity, + ErrorCodeConfigInvalid: http.StatusUnprocessableEntity, ErrorCodeConfigUndefinedEnv: http.StatusUnprocessableEntity, - ErrorCodeConfigRegexpError: http.StatusUnprocessableEntity, ErrorCodeDeploymentConflict: http.StatusUnprocessableEntity, ErrorCodeDeploymentInvalid: http.StatusUnprocessableEntity, ErrorCodeDeploymentLocked: http.StatusUnprocessableEntity,