diff --git a/src/cmd/scope/scopeService.go b/src/cmd/scope/scopeService.go index f547b36f..48377065 100644 --- a/src/cmd/scope/scopeService.go +++ b/src/cmd/scope/scopeService.go @@ -36,10 +36,7 @@ func (s *service) LoadSelectedScope(ctx context.Context, _ *cmdBuilder.Cmd, cmdD if serviceIdOrName, exists := cmdData.Args[ServiceArgName]; exists { service, err = repository.GetServiceByIdOrName(ctx, cmdData.RestApiClient, cmdData.Project.ID, serviceIdOrName[0]) if err != nil { - return errorsx.Convert( - err, - errorsx.ConvertInvalidUserInput("id", i18n.T(i18n.ErrorInvalidServiceIdOrName)), - ) + return err } } diff --git a/src/cmd/servicePush.go b/src/cmd/servicePush.go index 06c810a2..c9bddeda 100644 --- a/src/cmd/servicePush.go +++ b/src/cmd/servicePush.go @@ -149,7 +149,6 @@ func servicePushCmd() *cmdBuilder.Cmd { }, body.PutAppVersionBuildAndDeploy{ ZeropsYaml: types.MediumText(configContent), - Source: types.NewStringNull("CLI"), }, ) if err != nil { diff --git a/src/entity/repository/service.go b/src/entity/repository/service.go index 60bfcd41..4ba908eb 100644 --- a/src/entity/repository/service.go +++ b/src/entity/repository/service.go @@ -5,10 +5,12 @@ import ( "github.com/zeropsio/zcli/src/entity" "github.com/zeropsio/zcli/src/errorsx" + "github.com/zeropsio/zcli/src/i18n" "github.com/zeropsio/zcli/src/zeropsRestApiClient" "github.com/zeropsio/zerops-go/dto/input/body" "github.com/zeropsio/zerops-go/dto/input/path" "github.com/zeropsio/zerops-go/dto/output" + "github.com/zeropsio/zerops-go/errorCode" "github.com/zeropsio/zerops-go/types" "github.com/zeropsio/zerops-go/types/uuid" ) @@ -21,15 +23,21 @@ func GetServiceByIdOrName( ) (*entity.Service, error) { service, err := GetServiceById(ctx, restApiClient, uuid.ServiceStackId(serviceIdOrName)) if err != nil { - if errorsx.IsUserError(err) { + if errorsx.Check(err, + errorsx.CheckErrorCode(errorCode.InvalidUserInput), + errorsx.CheckErrorCode(errorCode.ServiceStackNotFound), + ) { service, err = GetServiceByName(ctx, restApiClient, projectId, types.String(serviceIdOrName)) if err != nil { - return nil, err + return nil, errorsx.Convert( + err, + errorsx.ConvertErrorCode(errorCode.ServiceStackNotFound, i18n.T(i18n.ErrorServiceNotFound, serviceIdOrName)), + ) } } } - return service, err + return service, nil } func GetServiceById( diff --git a/src/errorsx/userError.go b/src/errorsx/userError.go index e9ab2f99..f1992d79 100644 --- a/src/errorsx/userError.go +++ b/src/errorsx/userError.go @@ -16,10 +16,6 @@ func NewUserError(message string, previous error) *UserError { } } -func IsUserError(err error) bool { - return AsUserError(err) != nil -} - func AsUserError(err error) *UserError { var userError *UserError if errors.As(err, &userError) { diff --git a/src/i18n/en.go b/src/i18n/en.go index 49e9d126..2c74d871 100644 --- a/src/i18n/en.go +++ b/src/i18n/en.go @@ -232,5 +232,5 @@ more info: https://docs.zerops.io/documentation/cli/authorization.html`, ErrorInvalidProjectId: "Invalid project ID [%s]", ErrorInvalidScopedProjectId: "Invalid ID of the scoped project [%s], select a different project using `zcli scope project` command.", ErrorInvalidServiceId: "Invalid service ID [%s]", - ErrorInvalidServiceIdOrName: "Invalid service ID or name [%s]", + ErrorServiceNotFound: "Service [%s] not found", } diff --git a/src/i18n/i18n.go b/src/i18n/i18n.go index 381a2f03..aadad0a4 100644 --- a/src/i18n/i18n.go +++ b/src/i18n/i18n.go @@ -242,5 +242,5 @@ const ( ErrorInvalidProjectId = "ErrorInvalidProjectId" ErrorInvalidScopedProjectId = "ErrorInvalidScopedProjectId" ErrorInvalidServiceId = "ErrorInvalidServiceId" - ErrorInvalidServiceIdOrName = "ErrorInvalidServiceIdOrName" + ErrorServiceNotFound = "ErrorServiceNotFound" )