Skip to content

Commit

Permalink
fix deployemnt as code (#1289)
Browse files Browse the repository at this point in the history
  • Loading branch information
kushalmalani committed Jun 30, 2023
1 parent 1e1382f commit e1754ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
16 changes: 10 additions & 6 deletions cloud/deployment/fromfile/fromfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ func getCreateOrUpdateInput(deploymentFromFile *inspect.FormattedDeployment, clu
RuntimeReleaseVersion: deploymentFromFile.Deployment.Configuration.RunTimeVersion,
DagDeployEnabled: deploymentFromFile.Deployment.Configuration.DagDeployEnabled,
SchedulerSize: deploymentFromFile.Deployment.Configuration.SchedulerSize,
APIKeyOnlyDeployments: deploymentFromFile.Deployment.Configuration.APIKeyOnlyDeployments,
IsHighAvailability: deploymentFromFile.Deployment.Configuration.IsHighAvailability,
DeploymentSpec: astro.DeploymentCreateSpec{
Executor: deploymentFromFile.Deployment.Configuration.Executor,
Scheduler: astro.Scheduler{
Expand All @@ -258,12 +260,14 @@ func getCreateOrUpdateInput(deploymentFromFile *inspect.FormattedDeployment, clu
fmt.Errorf("changing an existing deployment's cluster %w", errNotPermitted)
}
updateInput = astro.UpdateDeploymentInput{
ID: existingDeployment.ID,
ClusterID: clusterID,
Label: deploymentFromFile.Deployment.Configuration.Name,
Description: deploymentFromFile.Deployment.Configuration.Description,
DagDeployEnabled: deploymentFromFile.Deployment.Configuration.DagDeployEnabled,
SchedulerSize: deploymentFromFile.Deployment.Configuration.SchedulerSize,
ID: existingDeployment.ID,
ClusterID: clusterID,
Label: deploymentFromFile.Deployment.Configuration.Name,
Description: deploymentFromFile.Deployment.Configuration.Description,
DagDeployEnabled: deploymentFromFile.Deployment.Configuration.DagDeployEnabled,
SchedulerSize: deploymentFromFile.Deployment.Configuration.SchedulerSize,
APIKeyOnlyDeployments: deploymentFromFile.Deployment.Configuration.APIKeyOnlyDeployments,
IsHighAvailability: deploymentFromFile.Deployment.Configuration.IsHighAvailability,
DeploymentSpec: astro.DeploymentCreateSpec{
Executor: deploymentFromFile.Deployment.Configuration.Executor,
Scheduler: astro.Scheduler{
Expand Down
5 changes: 5 additions & 0 deletions cloud/deployment/fromfile/fromfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"net/http"
"strconv"
"testing"

"github.com/astronomer/astro-cli/astro-client"
Expand Down Expand Up @@ -1022,6 +1023,8 @@ deployment:
cluster_name: test-cluster
workspace_name: test-workspace
deployment_type: HOSTED_DEDICATED
is_high_availability: true
ci_cd_enforcement: true
worker_queues:
- name: default
is_default: true
Expand Down Expand Up @@ -1112,6 +1115,8 @@ deployment:
err = CreateOrUpdate("deployment.yaml", "create", mockClient, mockCoreClient, out)
assert.NoError(t, err)
assert.Contains(t, out.String(), "configuration:\n name: "+createdDeployment.Label)
assert.Contains(t, out.String(), "ci_cd_enforcement: "+strconv.FormatBool(createdDeployment.APIKeyOnlyDeployments))
assert.Contains(t, out.String(), "is_high_availability: "+strconv.FormatBool(createdDeployment.IsHighAvailability))
assert.Contains(t, out.String(), "metadata:\n deployment_id: "+createdDeployment.ID)
mockClient.AssertExpectations(t)
mockCoreClient.AssertExpectations(t)
Expand Down

0 comments on commit e1754ab

Please sign in to comment.