Skip to content

Commit

Permalink
Adding a description flag for deploy (#1323)
Browse files Browse the repository at this point in the history
  • Loading branch information
kushalmalani authored Jul 27, 2023
1 parent eb70430 commit f2ce354
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
4 changes: 2 additions & 2 deletions astro-client/astro.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Client interface {
ReportDagDeploymentStatus(input *ReportDagDeploymentStatusInput) (DagDeploymentStatus, error)
// Image
CreateImage(input CreateImageInput) (*Image, error)
DeployImage(input DeployImageInput) (*Image, error)
DeployImage(input *DeployImageInput) (*Image, error)
// WorkerQueues
GetWorkerQueueOptions() (WorkerQueueDefaultOptions, error)
// Organizations
Expand Down Expand Up @@ -177,7 +177,7 @@ func (c *HTTPClient) CreateImage(input CreateImageInput) (*Image, error) {
return resp.Data.CreateImage, nil
}

func (c *HTTPClient) DeployImage(input DeployImageInput) (*Image, error) {
func (c *HTTPClient) DeployImage(input *DeployImageInput) (*Image, error) {
req := Request{
Query: DeployImage,
Variables: map[string]interface{}{"imageDeployInput": input},
Expand Down
4 changes: 2 additions & 2 deletions astro-client/astro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ func TestDeployImage(t *testing.T) {
})
astroClient := NewAstroClient(client)

image, err := astroClient.DeployImage(DeployImageInput{})
image, err := astroClient.DeployImage(&DeployImageInput{})
assert.NoError(t, err)
assert.Equal(t, image, mockResponse.Data.DeployImage)
})
Expand All @@ -576,7 +576,7 @@ func TestDeployImage(t *testing.T) {
})
astroClient := NewAstroClient(client)

_, err := astroClient.DeployImage(DeployImageInput{})
_, err := astroClient.DeployImage(&DeployImageInput{})
assert.Contains(t, err.Error(), "Internal Server Error")
})
}
Expand Down
8 changes: 4 additions & 4 deletions astro-client/mocks/Client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions astro-client/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ type DeployImageInput struct {
Tag string `json:"tag"`
Repository string `json:"repository"`
DagDeployEnabled bool `json:"dagDeployEnabled"`
Description string `json:"description"`
}

type CreateDeploymentInput struct {
Expand Down
8 changes: 5 additions & 3 deletions cloud/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ type InputDeploy struct {
Dags bool
WaitForStatus bool
DagsPath string
Description string
}

func getRegistryURL(domain string) string {
Expand Down Expand Up @@ -364,7 +365,7 @@ func Deploy(deployInput InputDeploy, client astro.Client, coreClient astrocore.C
}

// Deploy the image
err = imageDeploy(imageCreateRes.ID, deployInfo.deploymentID, repository, nextTag, deployInfo.dagDeployEnabled, client)
err = imageDeploy(imageCreateRes.ID, deployInfo.deploymentID, repository, nextTag, deployInput.Description, deployInfo.dagDeployEnabled, client)
if err != nil {
return err
}
Expand Down Expand Up @@ -677,15 +678,16 @@ func buildImage(path, currentVersion, deployImage, imageName string, dagDeployEn
}

// Deploy the image
func imageDeploy(imageCreateResID, deploymentID, repository, nextTag string, dagDeployEnabled bool, client astro.Client) error {
func imageDeploy(imageCreateResID, deploymentID, repository, nextTag, description string, dagDeployEnabled bool, client astro.Client) error {
imageDeployInput := astro.DeployImageInput{
ImageID: imageCreateResID,
DeploymentID: deploymentID,
Repository: repository,
Tag: nextTag,
DagDeployEnabled: dagDeployEnabled,
Description: description,
}
resp, err := client.DeployImage(imageDeployInput)
resp, err := client.DeployImage(&imageDeployInput)
if err != nil {
return err
}
Expand Down
32 changes: 16 additions & 16 deletions cmd/cloud/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@ import (
)

var (
forceDeploy bool
forcePrompt bool
saveDeployConfig bool
pytest bool
parse bool
dags bool
waitForDeploy bool
dagsPath string
deployExample = `
forceDeploy bool
forcePrompt bool
saveDeployConfig bool
pytest bool
parse bool
dags bool
waitForDeploy bool
dagsPath string
pytestFile string
envFile string
imageName string
deploymentName string
deployDescription string
deployExample = `
Specify the ID of the Deployment on Astronomer you would like to deploy this project to:
$ astro deploy <deployment ID>
Expand All @@ -35,13 +40,6 @@ Menu will be presented if you do not specify a deployment ID:
EnsureProjectDir = utils.EnsureProjectDir
)

var (
pytestFile string
envFile string
imageName string
deploymentName string
)

const (
registryUncommitedChangesMsg = "Project directory has uncommitted changes, use `astro deploy [deployment-id] -f` to force deploy."
)
Expand Down Expand Up @@ -70,6 +68,7 @@ func NewDeployCmd() *cobra.Command {
cmd.Flags().BoolVar(&parse, "parse", false, "Succeed only if all DAGs in your Astro project parse without errors")
cmd.Flags().BoolVarP(&waitForDeploy, "wait", "w", false, "Wait for the Deployment to become healthy before ending the command")
cmd.Flags().MarkHidden("dags-path") //nolint:errcheck
cmd.Flags().StringVarP(&deployDescription, "description", "", "", "Add a description for more context on this deploy")
return cmd
}

Expand Down Expand Up @@ -140,6 +139,7 @@ func deploy(cmd *cobra.Command, args []string) error {
Dags: dags,
WaitForStatus: waitForDeploy,
DagsPath: dagsPath,
Description: deployDescription,
}

return DeployImage(deployInput, astroClient, astroCoreClient)
Expand Down

0 comments on commit f2ce354

Please sign in to comment.