Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add --image flag for image only deploy #1446

Merged
merged 9 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions cloud/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
DeploymentName string
Prompt bool
Dags bool
Image bool
WaitForStatus bool
DagsPath string
Description string
Expand Down Expand Up @@ -235,7 +236,6 @@
if err != nil {
return err
}

resp, err := createDeploy(deployInfo.organizationID, deployInfo.deploymentID, deployInput.Description, "", deployInput.Dags, coreClient)
if err != nil {
return err
Expand Down Expand Up @@ -326,7 +326,7 @@
return fmt.Errorf("%w %s", envFileMissing, deployInput.EnvFile)
}

if deployInfo.dagDeployEnabled && len(dagFiles) == 0 && config.CFG.ShowWarnings.GetBool() {
if deployInfo.dagDeployEnabled && len(dagFiles) == 0 && config.CFG.ShowWarnings.GetBool() && !deployInput.Image {
i, _ := input.Confirm("Warning: No DAGs found. This will delete any existing DAGs. Are you sure you want to deploy?")

if !i {
Expand Down Expand Up @@ -366,12 +366,30 @@
}

if deployInfo.dagDeployEnabled && len(dagFiles) > 0 {
dagTarballVersion, err = deployDags(deployInput.Path, dagsPath, deployInfo.deploymentType, dagsUploadURL)
if !deployInput.Image {
dagTarballVersion, err = deployDags(deployInput.Path, dagsPath, deployInfo.deploymentType, dagsUploadURL)
if err != nil {
return err

Check warning on line 372 in cloud/deploy/deploy.go

View check run for this annotation

Codecov / codecov/patch

cloud/deploy/deploy.go#L372

Added line #L372 was not covered by tests
}
} else {
if !deployInfo.dagDeployEnabled {
return fmt.Errorf(enableDagDeployMsg, deployInfo.deploymentID) //nolint

Check warning on line 376 in cloud/deploy/deploy.go

View check run for this annotation

Codecov / codecov/patch

cloud/deploy/deploy.go#L374-L376

Added lines #L374 - L376 were not covered by tests
}
fmt.Println("Image Deploy only. Skipping deploying DAG...")

Check warning on line 378 in cloud/deploy/deploy.go

View check run for this annotation

Codecov / codecov/patch

cloud/deploy/deploy.go#L378

Added line #L378 was not covered by tests
}
}
// finish deploy
if deployInput.Image {
coreDeployment, err := deployment.CoreGetDeployment(deployInfo.workspaceID, deployInfo.organizationID, deployInfo.deploymentID, coreClient)

Check warning on line 383 in cloud/deploy/deploy.go

View check run for this annotation

Codecov / codecov/patch

cloud/deploy/deploy.go#L383

Added line #L383 was not covered by tests
if err != nil {
return err
}
if coreDeployment.CurrentDagTarballVersion != nil {
dagTarballVersion = *coreDeployment.CurrentDagTarballVersion
} else {
dagTarballVersion = ""

Check warning on line 390 in cloud/deploy/deploy.go

View check run for this annotation

Codecov / codecov/patch

cloud/deploy/deploy.go#L387-L390

Added lines #L387 - L390 were not covered by tests
}
}
// finish deploy
err = updateDeploy(deployID, deployInfo.deploymentID, deployInfo.organizationID, dagTarballVersion, deployInfo.dagDeployEnabled, coreClient)
if err != nil {
return err
Expand Down Expand Up @@ -412,7 +430,6 @@
if err != nil {
return deploymentInfo{}, err
}

return deploymentInfo{
currentDeployment.ID,
currentDeployment.ReleaseName,
Expand Down
7 changes: 7 additions & 0 deletions cmd/cloud/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
parse bool
dags bool
waitForDeploy bool
image bool
dagsPath string
pytestFile string
envFile string
Expand Down Expand Up @@ -63,6 +64,7 @@
cmd.Flags().StringVarP(&pytestFile, "test", "t", "", "Location of Pytests or specific Pytest file. All Pytest files must be located in the tests directory")
cmd.Flags().StringVarP(&imageName, "image-name", "i", "", "Name of a custom image to deploy")
cmd.Flags().BoolVarP(&dags, "dags", "d", false, "Push only DAGs to your Astro Deployment")
cmd.Flags().BoolVarP(&image, "image", "", false, "Push only an image to your Astro Deployment. If you have DAG Deploy enabled your DAGs will not be affected.")
cmd.Flags().StringVar(&dagsPath, "dags-path", "", "If set deploy dags from this path instead of the dags from working directory")
cmd.Flags().StringVarP(&deploymentName, "deployment-name", "n", "", "Name of the deployment to deploy to")
cmd.Flags().BoolVar(&parse, "parse", false, "Succeed only if all DAGs in your Astro project parse without errors")
Expand Down Expand Up @@ -104,6 +106,10 @@
}
}

if dags && image {
return errors.New("cannot use both --dags and --image together. Run 'astro deploy' to update both your image and dags")

Check warning on line 110 in cmd/cloud/deploy.go

View check run for this annotation

Codecov / codecov/patch

cmd/cloud/deploy.go#L110

Added line #L110 was not covered by tests
}

// Save deploymentId in config if specified
if len(deploymentID) > 0 && saveDeployConfig {
err := config.CFG.ProjectDeployment.SetProjectString(deploymentID)
Expand Down Expand Up @@ -137,6 +143,7 @@
DeploymentName: deploymentName,
Prompt: forcePrompt,
Dags: dags,
Image: image,
WaitForStatus: waitForDeploy,
DagsPath: dagsPath,
Description: deployDescription,
Expand Down