Skip to content

Commit

Permalink
Update error message (#1580)
Browse files Browse the repository at this point in the history
* Update error message

* Fixing lint
  • Loading branch information
kushalmalani committed Feb 29, 2024
1 parent fc00c14 commit 59ac8c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 11 additions & 9 deletions cloud/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ const (
warningInvaildImageNameMsg = "WARNING! The image in your Dockerfile '%s' is not based on Astro Runtime and is not supported. Change your Dockerfile with an image that pulls from 'quay.io/astronomer/astro-runtime' to proceed.\n"
warningInvalidImageTagMsg = "WARNING! You are about to push an image using the '%s' runtime tag. This is not supported.\nConsider using one of the following supported tags: %s"

message = "DAGs uploaded successfully"
action = "UPLOAD"
allTests = "all-tests"
parseAndPytest = "parse-and-all-tests"
enableDagDeployMsg = "DAG-only deploys are not enabled for this Deployment. Run 'astro deployment update %s --dag-deploy enable' to enable DAG-only deploys."
dagDeployDisabled = "dag deploy is not enabled for deployment"
invalidWorkspaceID = "Invalid workspace id %s was provided through the --workspace-id flag\n"
message = "DAGs uploaded successfully"
action = "UPLOAD"
allTests = "all-tests"
parseAndPytest = "parse-and-all-tests"
enableDagDeployMsg = "DAG-only deploys are not enabled for this Deployment. Run 'astro deployment update %s --dag-deploy enable' to enable DAG-only deploys."
dagDeployDisabled = "dag deploy is not enabled for deployment"
invalidWorkspaceID = "Invalid workspace id %s was provided through the --workspace-id flag\n"
errCiCdEnforcementUpdate = "cannot deploy since ci/cd enforcement is enabled for the deployment %s. Please use API Tokens or API Keys instead"
)

var (
Expand All @@ -72,7 +73,6 @@ var (
var (
errDagsParseFailed = errors.New("your local DAGs did not parse. Fix the listed errors or use `astro deploy [deployment-id] -f` to force deploy") //nolint:revive
envFileMissing = errors.New("Env file path is incorrect: ") //nolint:revive
errCiCdEnforcementUpdate = errors.New("cannot update dag deploy since ci/cd enforcement is enabled for this deployment. Please use API Tokens or API Keys instead")
errImageDeployNoPriorDags = errors.New("cannot do image only deploy with no prior DAGs deployed. Please deploy DAGs to your deployment first")
)

Expand All @@ -95,6 +95,7 @@ type deploymentInfo struct {
desiredDagTarballVersion string
dagDeployEnabled bool
cicdEnforcement bool
name string
}

type InputDeploy struct {
Expand Down Expand Up @@ -233,7 +234,7 @@ func Deploy(deployInput InputDeploy, platformCoreClient astroplatformcore.CoreCl
}
if deployInfo.cicdEnforcement {
if !canCiCdDeploy(c.Token) {
return errCiCdEnforcementUpdate
return fmt.Errorf(errCiCdEnforcementUpdate, deployInfo.name) //nolint
}
}

Expand Down Expand Up @@ -465,6 +466,7 @@ func getDeploymentInfo(
desiredDagTarballVersion,
currentDeployment.IsDagDeployEnabled,
currentDeployment.IsCicdEnforced,
currentDeployment.Name,
}, nil
}
c, err := config.GetCurrentContext()
Expand Down
4 changes: 3 additions & 1 deletion cloud/deploy/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var (
mockCoreDeploymentResponse = []astroplatformcore.Deployment{
{
Id: deploymentID,
Name: "test-deployment",
Status: "HEALTHY",
Type: &hybridType,
},
Expand Down Expand Up @@ -122,6 +123,7 @@ var (
IsDagDeployEnabled: false,
IsCicdEnforced: true,
Type: &hybridType,
Name: "test-deployment",
},
}
deploymentResponseDags = astroplatformcore.GetDeploymentResponse{
Expand Down Expand Up @@ -272,7 +274,7 @@ func TestDeployOnCiCdEnforcedDeployment(t *testing.T) {

defer testUtil.MockUserInput(t, "1")()
err := Deploy(deployInput, mockPlatformCoreClient, nil)
assert.ErrorIs(t, err, errCiCdEnforcementUpdate)
assert.Contains(t, err.Error(), "cannot deploy since ci/cd enforcement is enabled for the deployment test-deployment. Please use API Tokens or API Keys instead")

defer os.RemoveAll("./testfiles/dags/")

Expand Down

0 comments on commit 59ac8c6

Please sign in to comment.