From 49fd2a97f4c168bfd7be5b890b9717ddb4c1aee2 Mon Sep 17 00:00:00 2001 From: Chioma Onyekpere Date: Wed, 8 Apr 2026 21:10:00 -0500 Subject: [PATCH 1/3] refactor: version-gate Houston airflow deprecations --- houston/deployment.go | 103 +++++++++++++++++++++++++------------ houston/deployment_test.go | 7 ++- houston/types.go | 1 - 3 files changed, 74 insertions(+), 37 deletions(-) diff --git a/houston/deployment.go b/houston/deployment.go index 32c5d5a68..917a0d6f4 100644 --- a/houston/deployment.go +++ b/houston/deployment.go @@ -27,7 +27,7 @@ type ListDeploymentLogsRequest struct { type UpdateDeploymentImageRequest struct { ReleaseName string `json:"releaseName"` Image string `json:"image"` - AirflowVersion string `json:"airflowVersion"` + AirflowVersion string `json:"airflowVersion,omitempty"` RuntimeVersion string `json:"runtimeVersion"` } @@ -769,17 +769,31 @@ var ( } }` - DeploymentInfoRequest = ` - query DeploymentInfo { - deploymentConfig { - airflowImages { - version - tag - } - airflowVersions - defaultAirflowImageTag - } - }` + DeploymentInfoRequest = queryList{ + { + version: "0.25.0", + query: ` + query DeploymentInfo { + deploymentConfig { + airflowImages { + version + tag + } + airflowVersions + defaultAirflowImageTag + } + }`, + }, + { + version: "1.0.1", + query: ` + query DeploymentInfo { + deploymentConfig { + __typename + } + }`, + }, + } DeploymentLogsGetRequest = ` query GetLogs( @@ -800,24 +814,47 @@ var ( } }` - DeploymentImageUpdateRequest = ` - mutation updateDeploymentImage( - $releaseName:String!, - $image:String!, - $airflowVersion:String, - $runtimeVersion:String, - ){ - updateDeploymentImage( - releaseName:$releaseName, - image:$image, - airflowVersion:$airflowVersion, - runtimeVersion:$runtimeVersion - ){ - releaseName - airflowVersion - runtimeVersion - } - }` + DeploymentImageUpdateRequest = queryList{ + { + version: "0.25.0", + query: ` + mutation updateDeploymentImage( + $releaseName:String!, + $image:String!, + $airflowVersion:String, + $runtimeVersion:String, + ){ + updateDeploymentImage( + releaseName:$releaseName, + image:$image, + airflowVersion:$airflowVersion, + runtimeVersion:$runtimeVersion + ){ + releaseName + airflowVersion + runtimeVersion + } + }`, + }, + { + version: "1.0.1", + query: ` + mutation updateDeploymentImage( + $releaseName:String!, + $image:String!, + $runtimeVersion:String, + ){ + updateDeploymentImage( + releaseName:$releaseName, + image:$image, + runtimeVersion:$runtimeVersion + ){ + releaseName + runtimeVersion + } + }`, + }, + } UpdateDeploymentRuntimeRequest = ` mutation updateDeploymentRuntime($deploymentUuid: Uuid!, $desiredRuntimeVersion: String!) { @@ -986,8 +1023,9 @@ func (h ClientImplementation) UpdateDeploymentAirflow(variables map[string]inter // GetDeploymentConfig - get a deployment configuration func (h ClientImplementation) GetDeploymentConfig(_ interface{}) (*DeploymentConfig, error) { + reqQuery := DeploymentInfoRequest.GreatestLowerBound(version) dReq := Request{ - Query: DeploymentInfoRequest, + Query: reqQuery, } resp, err := dReq.DoWithClient(h.client) @@ -1014,8 +1052,9 @@ func (h ClientImplementation) ListDeploymentLogs(filters ListDeploymentLogsReque } func (h ClientImplementation) UpdateDeploymentImage(updateReq UpdateDeploymentImageRequest) (interface{}, error) { + reqQuery := DeploymentImageUpdateRequest.GreatestLowerBound(version) req := Request{ - Query: DeploymentImageUpdateRequest, + Query: reqQuery, Variables: updateReq, } diff --git a/houston/deployment_test.go b/houston/deployment_test.go index bc79d356f..8f7e651ea 100644 --- a/houston/deployment_test.go +++ b/houston/deployment_test.go @@ -664,8 +664,7 @@ func (s *Suite) TestUpdateDeploymentImage() { Data: ResponseData{ UpdateDeploymentImage: UpdateDeploymentImageResp{ ReleaseName: "prehistoric-gravity-930", - AirflowVersion: "2.2.0", - RuntimeVersion: "", + RuntimeVersion: "6.0.0", }, }, } @@ -682,7 +681,7 @@ func (s *Suite) TestUpdateDeploymentImage() { }) api := NewClient(client) - _, err := api.UpdateDeploymentImage(UpdateDeploymentImageRequest{ReleaseName: mockDeployment.Data.UpdateDeploymentImage.ReleaseName, AirflowVersion: mockDeployment.Data.UpdateDeploymentImage.AirflowVersion}) + _, err := api.UpdateDeploymentImage(UpdateDeploymentImageRequest{ReleaseName: mockDeployment.Data.UpdateDeploymentImage.ReleaseName, RuntimeVersion: "6.0.0"}) s.NoError(err) }) @@ -696,7 +695,7 @@ func (s *Suite) TestUpdateDeploymentImage() { }) api := NewClient(client) - _, err := api.UpdateDeploymentImage(UpdateDeploymentImageRequest{ReleaseName: mockDeployment.Data.UpdateDeploymentImage.ReleaseName, AirflowVersion: mockDeployment.Data.UpdateDeploymentImage.AirflowVersion}) + _, err := api.UpdateDeploymentImage(UpdateDeploymentImageRequest{ReleaseName: mockDeployment.Data.UpdateDeploymentImage.ReleaseName, RuntimeVersion: "6.0.0"}) s.Contains(err.Error(), "Internal Server Error") }) } diff --git a/houston/types.go b/houston/types.go index 92c2cd2ce..e8f73a83d 100644 --- a/houston/types.go +++ b/houston/types.go @@ -307,7 +307,6 @@ type AirflowImage struct { type UpdateDeploymentImageResp struct { ReleaseName string `json:"releaseName"` - AirflowVersion string `json:"airflowVersion"` RuntimeVersion string `json:"runtimeVersion"` } From 2db6be96bee3f4004ca29b732b7e6e25e25586b8 Mon Sep 17 00:00:00 2001 From: Chioma Onyekpere Date: Wed, 8 Apr 2026 21:22:02 -0500 Subject: [PATCH 2/3] fix test --- software/deploy/deploy_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/software/deploy/deploy_test.go b/software/deploy/deploy_test.go index a9a53a719..775766805 100644 --- a/software/deploy/deploy_test.go +++ b/software/deploy/deploy_test.go @@ -1234,7 +1234,6 @@ func (s *Suite) TestUpdateDeploymentImage() { } updateDeploymentImageResp := &houston.UpdateDeploymentImageResp{ ReleaseName: releaseName, - AirflowVersion: "", RuntimeVersion: runtimeVersion, } deployment := &houston.Deployment{ From 14381328552aea71eb1ba3ab115f365120aac054 Mon Sep 17 00:00:00 2001 From: Chioma Onyekpere Date: Thu, 9 Apr 2026 14:13:09 -0500 Subject: [PATCH 3/3] chore: pass workspace and deployment context to appConfig query and drop deprecated fields for Houston 2.0 --- cmd/software/deployment.go | 4 +- .../deployment_service_account_test.go | 8 +-- cmd/software/deployment_teams_test.go | 8 +-- cmd/software/deployment_test.go | 52 +++++++++---------- cmd/software/deployment_user_test.go | 8 +-- cmd/software/root.go | 2 +- cmd/software/root_test.go | 7 +-- cmd/software/utils_test.go | 5 +- .../workspace_service_account_test.go | 2 +- cmd/software/workspace_teams_test.go | 8 +-- cmd/software/workspace_test.go | 3 +- cmd/software/workspace_user_test.go | 2 +- houston/app.go | 29 +++++++++-- houston/app_test.go | 10 ++-- houston/houston.go | 2 +- houston/mocks/ClientInterface.go | 18 +++---- houston/types.go | 6 +++ software/auth/auth.go | 2 +- software/auth/auth_test.go | 14 ++--- software/deploy/deploy.go | 4 +- software/deploy/deploy_test.go | 36 ++++++------- 21 files changed, 133 insertions(+), 97 deletions(-) diff --git a/cmd/software/deployment.go b/cmd/software/deployment.go index 127ec529e..596da1a29 100644 --- a/cmd/software/deployment.go +++ b/cmd/software/deployment.go @@ -415,7 +415,7 @@ func newDeploymentRuntimeMigrateCmd(out io.Writer) *cobra.Command { func deploymentCreate(cmd *cobra.Command, out io.Writer) error { if clusterID != "" { - appConfig, _ = houston.Call(houstonClient.GetAppConfig)(clusterID) + appConfig, _ = houston.Call(houstonClient.GetAppConfig)(houston.GetAppConfigRequest{ClusterID: clusterID}) } ws, err := coalesceWorkspace() @@ -529,7 +529,7 @@ func deploymentUpdate(cmd *cobra.Command, args []string, dagDeploymentType, nfsL if err != nil { return fmt.Errorf("failed to get deployment info: %w", err) } - appConfig, err = houston.Call(houstonClient.GetAppConfig)(deploymentInfo.ClusterID) + appConfig, err = houston.Call(houstonClient.GetAppConfig)(houston.GetAppConfigRequest{ClusterID: deploymentInfo.ClusterID, DeploymentUUID: args[0]}) if err != nil { return fmt.Errorf("failed to get app config: %w", err) } diff --git a/cmd/software/deployment_service_account_test.go b/cmd/software/deployment_service_account_test.go index daeea36ee..98c129a5b 100644 --- a/cmd/software/deployment_service_account_test.go +++ b/cmd/software/deployment_service_account_test.go @@ -1,6 +1,8 @@ package software import ( + "github.com/stretchr/testify/mock" + "github.com/astronomer/astro-cli/houston" mocks "github.com/astronomer/astro-cli/houston/mocks" testUtil "github.com/astronomer/astro-cli/pkg/testing" @@ -27,7 +29,7 @@ func (s *Suite) TestDeploymentSAListCommand() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("ListDeploymentServiceAccounts", mockDeployment.ID).Return([]houston.ServiceAccount{mockSA}, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) houstonClient = api @@ -56,7 +58,7 @@ func (s *Suite) TestDeploymentSaDeleteRootCommand() { testUtil.InitTestConfig(testUtil.SoftwarePlatform) api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("DeleteDeploymentServiceAccount", houston.DeleteServiceAccountRequest{DeploymentID: "1234", ServiceAccountID: mockDeploymentSA.ID}).Return(mockDeploymentSA, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) houstonClient = api @@ -93,7 +95,7 @@ func (s *Suite) TestDeploymentSaCreateCommand() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("CreateDeploymentServiceAccount", expectedSARequest).Return(mockSA, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) diff --git a/cmd/software/deployment_teams_test.go b/cmd/software/deployment_teams_test.go index 427441d69..c54914583 100644 --- a/cmd/software/deployment_teams_test.go +++ b/cmd/software/deployment_teams_test.go @@ -5,6 +5,8 @@ import ( "io" "net/http" + "github.com/stretchr/testify/mock" + "github.com/astronomer/astro-cli/houston" mocks "github.com/astronomer/astro-cli/houston/mocks" testUtil "github.com/astronomer/astro-cli/pkg/testing" @@ -32,7 +34,7 @@ Successfully added team cl0evnxfl0120dxxu1s4nbnk7 to deployment cknz133ra49758zr ` api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("AddDeploymentTeam", houston.AddDeploymentTeamRequest{DeploymentID: mockDeployment.ID, TeamID: mockDeploymentTeamRole.Team.ID, Role: mockDeploymentTeamRole.Role}).Return(mockDeploymentTeamRole, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) houstonClient = api @@ -57,7 +59,7 @@ func (s *Suite) TestDeploymentTeamRm() { ` api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("RemoveDeploymentTeam", houston.RemoveDeploymentTeamRequest{DeploymentID: mockDeployment.ID, TeamID: mockDeploymentTeamRole.Team.ID}).Return(mockDeploymentTeamRole, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) houstonClient = api @@ -77,7 +79,7 @@ func (s *Suite) TestDeploymentTeamUpdateCommand() { testUtil.InitTestConfig(testUtil.SoftwarePlatform) api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("UpdateDeploymentTeamRole", houston.UpdateDeploymentTeamRequest{DeploymentID: mockDeployment.ID, TeamID: mockDeploymentTeamRole.Team.ID, Role: mockDeploymentTeamRole.Role}).Return(mockDeploymentTeamRole, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) houstonClient = api diff --git a/cmd/software/deployment_test.go b/cmd/software/deployment_test.go index a6e9a0176..971cefcca 100644 --- a/cmd/software/deployment_test.go +++ b/cmd/software/deployment_test.go @@ -83,7 +83,7 @@ func (s *Suite) TestDeploymentCreateCommandNfsMountDisabled() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) api.On("CreateDeployment", mock.Anything).Return(mockDeployment, nil) @@ -113,7 +113,7 @@ func (s *Suite) TestDeploymentCreateCommandTriggererDisabled() { appConfig = &houston.AppConfig{TriggererEnabled: false} api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) api.On("CreateDeployment", mock.Anything).Return(mockDeployment, nil) @@ -145,7 +145,7 @@ func (s *Suite) TestDeploymentCreateCommandTriggererEnabled() { }, } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) api.On("CreateDeployment", mock.Anything).Return(mockDeployment, nil) @@ -177,7 +177,7 @@ func (s *Suite) TestDeploymentCreateCommandNfsMountEnabled() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) api.On("CreateDeployment", mock.Anything).Return(mockDeployment, nil).Times(2) @@ -210,7 +210,7 @@ func (s *Suite) TestDeploymentCreateCommandGitSyncEnabled() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) api.On("CreateDeployment", mock.Anything).Return(mockDeployment, nil).Times(5) @@ -246,7 +246,7 @@ func (s *Suite) TestDeploymentCreateCommandDagOnlyDeployEnabled() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) api.On("CreateDeployment", mock.Anything).Return(mockDeployment, nil).Times(5) @@ -276,7 +276,7 @@ func (s *Suite) TestDeploymentCreateCommandGitSyncDisabled() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) api.On("CreateDeployment", mock.Anything).Return(mockDeployment, nil) @@ -306,7 +306,7 @@ func (s *Suite) TestDeploymentCreateCommandGitSyncDisabledAndVersionIs1_0_0AndCl } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("GetPlatformVersion", nil).Return("1.0.0", nil) api.On("CreateDeployment", mock.Anything).Return(mockDeployment, nil) @@ -381,7 +381,7 @@ func (s *Suite) TestDeploymentCreateWithTypeDagDeploy() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) api.On("CreateDeployment", mock.Anything).Return(mockDeployment, nil) cmdArgs := []string{"create", "--label=new-deployment-name", "--executor=celery", "--dag-deployment-type=dag_deploy", "--triggerer-replicas=1"} @@ -416,7 +416,7 @@ func (s *Suite) TestDeploymentCreateWithTypeDagDeploy() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) api.On("CreateDeployment", mock.Anything).Return(mockDeployment, nil) cmdArgs := []string{"create", "--label=new-deployment-name", "--executor=celery", "--dag-deployment-type=dag_deploy", "--triggerer-replicas=1"} @@ -451,7 +451,7 @@ func (s *Suite) TestDeploymentUpdateWithTypeDagDeploy() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) api.On("UpdateDeployment", mock.Anything).Return(mockDeployment, nil) dagDeployment := &houston.DagDeploymentConfig{ @@ -476,7 +476,7 @@ func (s *Suite) TestDeploymentUpdateWithTypeDagDeploy() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("UpdateDeployment", mock.Anything).Return(mockDeployment, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) getDeploymentError := errors.New("Test error") @@ -495,7 +495,7 @@ func (s *Suite) TestDeploymentUpdateWithTypeDagDeploy() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("UpdateDeployment", mock.Anything).Return(mockDeployment, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) dagDeployment := &houston.DagDeploymentConfig{ @@ -520,7 +520,7 @@ func (s *Suite) TestDeploymentUpdateWithTypeDagDeploy() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("UpdateDeployment", mock.Anything).Return(mockDeployment, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) dagDeployment := &houston.DagDeploymentConfig{ @@ -561,7 +561,7 @@ func (s *Suite) TestDeploymentUpdateWithTypeDagDeploy() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("UpdateDeployment", mock.Anything).Return(mockDeployment, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) dagDeployment := &houston.DagDeploymentConfig{ @@ -603,7 +603,7 @@ func (s *Suite) TestDeploymentUpdateFromTypeDagDeployToNonDagDeploy() { }, } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("UpdateDeployment", mock.Anything).Return(mockDeployment, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) dagDeployment := &houston.DagDeploymentConfig{ @@ -644,7 +644,7 @@ func (s *Suite) TestDeploymentUpdateFromTypeDagDeployToNonDagDeploy() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("UpdateDeployment", mock.Anything).Return(mockDeployment, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) dagDeployment := &houston.DagDeploymentConfig{ @@ -688,7 +688,7 @@ func (s *Suite) TestDeploymentUpdateCommand() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("UpdateDeployment", mock.Anything).Return(mockDeployment, nil).Times(8) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) dagDeployment := &houston.DagDeploymentConfig{ @@ -733,7 +733,7 @@ func (s *Suite) TestDeploymentUpdateTriggererEnabledCommand() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("UpdateDeployment", mock.Anything).Return(mockDeployment, nil).Twice() api.On("GetPlatformVersion", nil).Return("0.25.0", nil) dagDeployment := &houston.DagDeploymentConfig{ @@ -773,7 +773,7 @@ func (s *Suite) TestDeploymentUpdateCommandGitSyncDisabled() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("UpdateDeployment", mock.Anything).Return(mockDeployment, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) dagDeployment := &houston.DagDeploymentConfig{ @@ -811,7 +811,7 @@ func (s *Suite) TestDeploymentUpdateCommandDagOnlyDeployEnabled() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("UpdateDeployment", mock.Anything).Return(mockDeployment, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) dagDeployment := &houston.DagDeploymentConfig{ @@ -854,7 +854,7 @@ func (s *Suite) TestDeploymentAirflowUpgradeCommand() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("GetDeployment", mockDeploymentResponse.ID).Return(&mockDeploymentResponse, nil) api.On("UpdateDeploymentAirflow", mockUpdateRequest).Return(&mockDeploymentResponse, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) @@ -885,7 +885,7 @@ func (s *Suite) TestDeploymentAirflowUpgradeCancelCommand() { mockDeploymentUpdated.DesiredAirflowVersion = mockDeploymentUpdated.AirflowVersion api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("GetDeployment", mockDeploymentResponse.ID).Return(&mockDeploymentResponse, nil) api.On("UpdateDeploymentAirflow", expectedUpdateRequest).Return(&mockDeploymentUpdated, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) @@ -904,7 +904,7 @@ func (s *Suite) TestDeploymentDelete() { expectedOut := `Successfully deleted deployment` api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("DeleteDeployment", houston.DeleteDeploymentRequest{DeploymentID: mockDeployment.ID, HardDelete: false}).Return(mockDeployment, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) houstonClient = api @@ -953,7 +953,7 @@ func (s *Suite) TestDeploymentDeleteHardResponseNo() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) // mock os.Stdin input := []byte("n") @@ -982,7 +982,7 @@ func (s *Suite) TestDeploymentDeleteHardResponseYes() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(appConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(appConfig, nil) api.On("DeleteDeployment", houston.DeleteDeploymentRequest{DeploymentID: mockDeployment.ID, HardDelete: true}).Return(mockDeployment, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) // mock os.Stdin diff --git a/cmd/software/deployment_user_test.go b/cmd/software/deployment_user_test.go index e06394f8e..091b3ccc2 100644 --- a/cmd/software/deployment_user_test.go +++ b/cmd/software/deployment_user_test.go @@ -1,6 +1,8 @@ package software import ( + "github.com/stretchr/testify/mock" + "github.com/astronomer/astro-cli/houston" mocks "github.com/astronomer/astro-cli/houston/mocks" testUtil "github.com/astronomer/astro-cli/pkg/testing" @@ -20,7 +22,7 @@ func (s *Suite) TestDeploymentUserAddCommand() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("AddDeploymentUser", expectedAddUserRequest).Return(mockDeploymentUserRole, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) houstonClient = api @@ -43,7 +45,7 @@ func (s *Suite) TestDeploymentUserDeleteCommand() { ` api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("DeleteDeploymentUser", houston.DeleteDeploymentUserRequest{DeploymentID: mockDeploymentUserRole.Deployment.ID, Email: mockDeploymentUserRole.User.Username}). Return(mockDeploymentUserRole, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) @@ -93,7 +95,7 @@ func (s *Suite) TestDeploymentUserUpdateCommand() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("UpdateDeploymentUser", expectedUpdateUserRequest).Return(&mockResponseUserRole, nil) api.On("GetPlatformVersion", nil).Return("0.25.0", nil) diff --git a/cmd/software/root.go b/cmd/software/root.go index 9105a2218..5ee45693c 100644 --- a/cmd/software/root.go +++ b/cmd/software/root.go @@ -30,7 +30,7 @@ func AddCmds(client houston.ClientInterface, out io.Writer) []*cobra.Command { var err error // There is no clusterID in the GetAppConfig call at this point of lifecycle, so we are getting the app config for the default cluster - appConfig, err = houston.Call(client.GetAppConfig)("") + appConfig, err = houston.Call(client.GetAppConfig)(houston.GetAppConfigRequest{}) if err != nil { InitDebugLogs = append(InitDebugLogs, fmt.Sprintf("Error checking feature flag: %s", err.Error())) } diff --git a/cmd/software/root_test.go b/cmd/software/root_test.go index a8e14aeb2..59669539c 100644 --- a/cmd/software/root_test.go +++ b/cmd/software/root_test.go @@ -5,6 +5,7 @@ import ( "fmt" "testing" + "github.com/stretchr/testify/mock" "github.com/stretchr/testify/suite" "github.com/astronomer/astro-cli/config" @@ -41,7 +42,7 @@ func (s *AddCmdSuite) TestAddCmds() { }, } houstonMock := new(houston_mocks.ClientInterface) - houstonMock.On("GetAppConfig", "").Return(appConfig, nil) + houstonMock.On("GetAppConfig", mock.Anything).Return(appConfig, nil) houstonMock.On("GetPlatformVersion", nil).Return("0.30.0", nil) buf := new(bytes.Buffer) cmds := AddCmds(houstonMock, buf) @@ -53,7 +54,7 @@ func (s *AddCmdSuite) TestAddCmds() { func (s *AddCmdSuite) TestAppConfigFailure() { houstonMock := new(houston_mocks.ClientInterface) - houstonMock.On("GetAppConfig", "").Return(nil, errMock) + houstonMock.On("GetAppConfig", mock.Anything).Return(nil, errMock) houstonMock.On("GetPlatformVersion", nil).Return("0.30.0", nil) buf := new(bytes.Buffer) cmds := AddCmds(houstonMock, buf) @@ -72,7 +73,7 @@ func (s *AddCmdSuite) TestPlatformVersionFailure() { }, } houstonMock := new(houston_mocks.ClientInterface) - houstonMock.On("GetAppConfig", "").Return(appConfig, nil) + houstonMock.On("GetAppConfig", mock.Anything).Return(appConfig, nil) houstonMock.On("GetPlatformVersion", nil).Return("", errMock) buf := new(bytes.Buffer) cmds := AddCmds(houstonMock, buf) diff --git a/cmd/software/utils_test.go b/cmd/software/utils_test.go index 185ce5b81..72ef58d30 100644 --- a/cmd/software/utils_test.go +++ b/cmd/software/utils_test.go @@ -6,6 +6,7 @@ import ( "os" "github.com/spf13/cobra" + "github.com/stretchr/testify/mock" "github.com/astronomer/astro-cli/houston" houston_mocks "github.com/astronomer/astro-cli/houston/mocks" @@ -15,7 +16,7 @@ func (s *Suite) TestVersionMatchCmds() { s.Run("0.27.0 platform with teams command", func() { buf := new(bytes.Buffer) mockAPI := new(houston_mocks.ClientInterface) - mockAPI.On("GetAppConfig", "").Return(&houston.AppConfig{Version: "0.27.0"}, nil) + mockAPI.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{Version: "0.27.0"}, nil) mockAPI.On("GetPlatformVersion", nil).Return("0.27.0", nil) cmd := &cobra.Command{Use: "astro"} childCMDs := AddCmds(mockAPI, buf) @@ -43,7 +44,7 @@ func (s *Suite) TestVersionMatchCmds() { s.Run("0.30.0 platform with teams command", func() { buf := new(bytes.Buffer) mockAPI := new(houston_mocks.ClientInterface) - mockAPI.On("GetAppConfig", "").Return(&houston.AppConfig{Version: "0.30.0"}, nil) + mockAPI.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{Version: "0.30.0"}, nil) mockAPI.On("GetPlatformVersion", nil).Return("0.30.0", nil) cmd := &cobra.Command{Use: "astro"} childCMDs := AddCmds(mockAPI, buf) diff --git a/cmd/software/workspace_service_account_test.go b/cmd/software/workspace_service_account_test.go index d48452e9e..cd2007a98 100644 --- a/cmd/software/workspace_service_account_test.go +++ b/cmd/software/workspace_service_account_test.go @@ -32,7 +32,7 @@ func (s *Suite) TestWorkspaceSAListCommand() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("ListWorkspaceServiceAccounts", mockWorkspace.ID).Return([]houston.ServiceAccount{mockSA}, nil) houstonClient = api diff --git a/cmd/software/workspace_teams_test.go b/cmd/software/workspace_teams_test.go index 8ba3d4622..e4d352b24 100644 --- a/cmd/software/workspace_teams_test.go +++ b/cmd/software/workspace_teams_test.go @@ -5,6 +5,8 @@ import ( "io" "net/http" + "github.com/stretchr/testify/mock" + "github.com/astronomer/astro-cli/houston" mocks "github.com/astronomer/astro-cli/houston/mocks" testUtil "github.com/astronomer/astro-cli/pkg/testing" @@ -37,7 +39,7 @@ Successfully added cl0evnxfl0120dxxu1s4nbnk7 to airflow ` api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("AddWorkspaceTeam", houston.AddWorkspaceTeamRequest{WorkspaceID: mockWorkspace.ID, TeamID: mockWorkspaceTeamRole.Team.ID, Role: mockWorkspaceTeamRole.Role}).Return(mockWorkspace, nil) houstonClient = api @@ -58,7 +60,7 @@ func (s *Suite) TestWorkspaceTeamRm() { mockTeamID := "ckc0eir8e01gj07608ajmvia1" api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("DeleteWorkspaceTeam", houston.DeleteWorkspaceTeamRequest{WorkspaceID: mockWorkspace.ID, TeamID: mockTeamID}).Return(mockWorkspace, nil) houstonClient = api @@ -78,7 +80,7 @@ func (s *Suite) TestWorkspaceTeamUpdateCommand() { testUtil.InitTestConfig(testUtil.SoftwarePlatform) api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("GetWorkspaceTeamRole", houston.GetWorkspaceTeamRoleRequest{WorkspaceID: mockWorkspace.ID, TeamID: mockWorkspaceTeamRole.Team.ID}).Return(mockWorkspaceTeam, nil) api.On("UpdateWorkspaceTeamRole", houston.UpdateWorkspaceTeamRoleRequest{WorkspaceID: mockWorkspace.ID, TeamID: mockWorkspaceTeamRole.Team.ID, Role: mockWorkspaceTeamRole.Role}).Return(mockWorkspace.Label, nil) houstonClient = api diff --git a/cmd/software/workspace_test.go b/cmd/software/workspace_test.go index d1bd6e5c6..5af38768f 100644 --- a/cmd/software/workspace_test.go +++ b/cmd/software/workspace_test.go @@ -4,6 +4,7 @@ import ( "bytes" "github.com/spf13/cobra" + "github.com/stretchr/testify/mock" "github.com/astronomer/astro-cli/houston" mocks "github.com/astronomer/astro-cli/houston/mocks" @@ -46,7 +47,7 @@ func (s *Suite) TestWorkspaceList() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(&houston.AppConfig{}, nil) + api.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{}, nil) api.On("ListWorkspaces", nil).Return(mockWorkspaces, nil) houstonClient = api diff --git a/cmd/software/workspace_user_test.go b/cmd/software/workspace_user_test.go index 353baee18..3011dc1e7 100644 --- a/cmd/software/workspace_user_test.go +++ b/cmd/software/workspace_user_test.go @@ -33,7 +33,7 @@ func (s *Suite) TestWorkspaceUserRemove() { } api := new(mocks.ClientInterface) - api.On("GetAppConfig", "").Return(mockAppConfig, nil) + api.On("GetAppConfig", mock.Anything).Return(mockAppConfig, nil) api.On("GetWorkspaceUserRole", houston.GetWorkspaceUserRoleRequest{WorkspaceID: mockWorkspace.ID, Email: mockUser.Username}).Return(mockUser, nil) api.On("DeleteWorkspaceUser", houston.DeleteWorkspaceUserRequest{WorkspaceID: mockWorkspace.ID, UserID: mockUser.ID}).Return(mockWorkspace, nil) houstonClient = api diff --git a/houston/app.go b/houston/app.go index 866bb336e..161fc1d0e 100644 --- a/houston/app.go +++ b/houston/app.go @@ -85,6 +85,19 @@ var ( } }`, }, + { + version: "2.0.0", + query: ` + query AppConfig($clusterId: Uuid, $workspaceUuid: Uuid, $deploymentUuid: Uuid) { + appConfig(clusterId: $clusterId, workspaceUuid: $workspaceUuid, deploymentUuid: $deploymentUuid) { + version + baseDomain + byoUpdateRegistryHost + smtpConfigured + featureFlags + } + }`, + }, } AvailableNamespacesGetRequest = queryList{ @@ -117,21 +130,27 @@ var ( ) // GetAppConfig - get application configuration -func (h ClientImplementation) GetAppConfig(clusterID string) (*AppConfig, error) { +func (h ClientImplementation) GetAppConfig(req GetAppConfigRequest) (*AppConfig, error) { // Even if application config has already been requested, we want to request it again // Because we want to get the app config for the clusterID if it is provided vars := map[string]interface{}{} - if clusterID != "" { - vars["clusterId"] = clusterID + if req.ClusterID != "" { + vars["clusterId"] = req.ClusterID + } + if req.WorkspaceUUID != "" { + vars["workspaceUuid"] = req.WorkspaceUUID + } + if req.DeploymentUUID != "" { + vars["deploymentUuid"] = req.DeploymentUUID } reqQuery := AppConfigRequest.GreatestLowerBound(version) - req := Request{ + httpReq := Request{ Query: reqQuery, Variables: vars, } var r *Response - r, appConfigErr = req.DoWithClient(h.client) + r, appConfigErr = httpReq.DoWithClient(h.client) if appConfigErr != nil { appConfigErr = handleAPIErr(appConfigErr) return nil, appConfigErr diff --git a/houston/app_test.go b/houston/app_test.go index a5dd687a4..f9af5d6bc 100644 --- a/houston/app_test.go +++ b/houston/app_test.go @@ -47,11 +47,11 @@ func (s *Suite) TestGetAppConfig() { }) api := NewClient(client) - config, err := api.GetAppConfig("") + config, err := api.GetAppConfig(GetAppConfigRequest{}) s.NoError(err) s.Equal(config, mockAppConfig) - config, err = api.GetAppConfig("") + config, err = api.GetAppConfig(GetAppConfigRequest{}) s.NoError(err) s.Equal(config, mockAppConfig) @@ -74,11 +74,11 @@ func (s *Suite) TestGetAppConfig() { appConfig = nil appConfigErr = nil - config, err := api.GetAppConfig("") + config, err := api.GetAppConfig(GetAppConfigRequest{}) s.Contains(err.Error(), "Internal Server Error") s.Nil(config) - config, err = api.GetAppConfig("") + config, err = api.GetAppConfig(GetAppConfigRequest{}) s.Contains(err.Error(), "Internal Server Error") s.Nil(config) @@ -100,7 +100,7 @@ func (s *Suite) TestGetAppConfig() { }) api := NewClient(client) - _, err := api.GetAppConfig("") + _, err := api.GetAppConfig(GetAppConfigRequest{}) s.EqualError(err, ErrFieldsNotAvailable{}.Error()) }) } diff --git a/houston/houston.go b/houston/houston.go index 58cfc57f1..017ff04cd 100644 --- a/houston/houston.go +++ b/houston/houston.go @@ -75,7 +75,7 @@ type ClientInterface interface { DeleteWorkspaceServiceAccount(req DeleteServiceAccountRequest) (*ServiceAccount, error) ListWorkspaceServiceAccounts(workspaceID string) ([]ServiceAccount, error) // app - GetAppConfig(clusterID string) (*AppConfig, error) + GetAppConfig(req GetAppConfigRequest) (*AppConfig, error) GetAvailableNamespaces(vars map[string]interface{}) ([]Namespace, error) GetPlatformVersion(interface{}) (string, error) // runtime diff --git a/houston/mocks/ClientInterface.go b/houston/mocks/ClientInterface.go index e992da60e..576de9adb 100644 --- a/houston/mocks/ClientInterface.go +++ b/houston/mocks/ClientInterface.go @@ -608,9 +608,9 @@ func (_m *ClientInterface) DeleteWorkspaceUser(req houston.DeleteWorkspaceUserRe return r0, r1 } -// GetAppConfig provides a mock function with given fields: clusterID -func (_m *ClientInterface) GetAppConfig(clusterID string) (*houston.AppConfig, error) { - ret := _m.Called(clusterID) +// GetAppConfig provides a mock function with given fields: req +func (_m *ClientInterface) GetAppConfig(req houston.GetAppConfigRequest) (*houston.AppConfig, error) { + ret := _m.Called(req) if len(ret) == 0 { panic("no return value specified for GetAppConfig") @@ -618,19 +618,19 @@ func (_m *ClientInterface) GetAppConfig(clusterID string) (*houston.AppConfig, e var r0 *houston.AppConfig var r1 error - if rf, ok := ret.Get(0).(func(string) (*houston.AppConfig, error)); ok { - return rf(clusterID) + if rf, ok := ret.Get(0).(func(houston.GetAppConfigRequest) (*houston.AppConfig, error)); ok { + return rf(req) } - if rf, ok := ret.Get(0).(func(string) *houston.AppConfig); ok { - r0 = rf(clusterID) + if rf, ok := ret.Get(0).(func(houston.GetAppConfigRequest) *houston.AppConfig); ok { + r0 = rf(req) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*houston.AppConfig) } } - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(clusterID) + if rf, ok := ret.Get(1).(func(houston.GetAppConfigRequest) error); ok { + r1 = rf(req) } else { r1 = ret.Error(1) } diff --git a/houston/types.go b/houston/types.go index e8f73a83d..719702f07 100644 --- a/houston/types.go +++ b/houston/types.go @@ -347,6 +347,12 @@ func (config *DeploymentConfig) IsValidTag(tag string) bool { return false } +type GetAppConfigRequest struct { + ClusterID string + WorkspaceUUID string + DeploymentUUID string +} + // AppConfig contains current houston config type AppConfig struct { Version string `json:"version"` diff --git a/software/auth/auth.go b/software/auth/auth.go index 571c571e7..3325b4244 100644 --- a/software/auth/auth.go +++ b/software/auth/auth.go @@ -94,7 +94,7 @@ func RegistryAuth(client houston.ClientInterface, out io.Writer, registryDomain return nil } - appConfig, err := houston.Call(client.GetAppConfig)("") + appConfig, err := houston.Call(client.GetAppConfig)(houston.GetAppConfigRequest{}) if err != nil { return err } diff --git a/software/auth/auth_test.go b/software/auth/auth_test.go index d2e7efd14..28b398713 100644 --- a/software/auth/auth_test.go +++ b/software/auth/auth_test.go @@ -161,7 +161,7 @@ func (s *Suite) TestRegistryAuthSuccess() { out := new(bytes.Buffer) houstonMock := new(houstonMocks.ClientInterface) - houstonMock.On("GetAppConfig", "").Return(&houston.AppConfig{Flags: houston.FeatureFlags{BYORegistryEnabled: false}}, nil) + houstonMock.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{Flags: houston.FeatureFlags{BYORegistryEnabled: false}}, nil) tests := []struct { name string @@ -261,7 +261,7 @@ func (s *Suite) TestRegistryAuthRegistryDomain() { } houstonMock := new(houstonMocks.ClientInterface) - houstonMock.On("GetAppConfig", "").Return(&houston.AppConfig{ + houstonMock.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{ Flags: houston.FeatureFlags{ BYORegistryEnabled: tt.byoRegistryEnabled, }, @@ -290,7 +290,7 @@ func (s *Suite) TestRegistryAuthFailure() { out := new(bytes.Buffer) houstonMock := new(houstonMocks.ClientInterface) - houstonMock.On("GetAppConfig", "").Return(&houston.AppConfig{Flags: houston.FeatureFlags{BYORegistryEnabled: true}}, nil).Twice() + houstonMock.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{Flags: houston.FeatureFlags{BYORegistryEnabled: true}}, nil).Twice() err := RegistryAuth(houstonMock, out, "") s.ErrorIs(err, errMockRegistry) @@ -304,7 +304,7 @@ func (s *Suite) TestRegistryAuthFailure() { err = RegistryAuth(houstonMock, out, "") s.NoError(err) - houstonMock.On("GetAppConfig", "").Return(&houston.AppConfig{Flags: houston.FeatureFlags{BYORegistryEnabled: false}}, nil).Once() + houstonMock.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{Flags: houston.FeatureFlags{BYORegistryEnabled: false}}, nil).Once() err = RegistryAuth(houstonMock, out, "") s.ErrorIs(err, errMockRegistry) @@ -316,7 +316,7 @@ func (s *Suite) TestRegistryAuthFailure() { s.Run("houston get app config failure", func() { out := new(bytes.Buffer) houstonMock := new(houstonMocks.ClientInterface) - houstonMock.On("GetAppConfig", "").Return(nil, errMockHouston).Once() + houstonMock.On("GetAppConfig", mock.Anything).Return(nil, errMockHouston).Once() err := RegistryAuth(houstonMock, out, "") s.ErrorIs(err, errMockHouston) @@ -505,7 +505,7 @@ func (s *Suite) TestLoginFailure() { houstonMock.On("GetAuthConfig", mock.Anything).Return(&houston.AuthConfig{LocalEnabled: true}, nil) houstonMock.On("AuthenticateWithBasicAuth", mock.Anything).Return(mockToken, nil) houstonMock.On("ListWorkspaces", nil).Return([]houston.Workspace{{ID: "ck05r3bor07h40d02y2hw4n4v"}, {ID: "test-workspace-id"}}, nil) - houstonMock.On("GetAppConfig", "").Return(&houston.AppConfig{Flags: houston.FeatureFlags{BYORegistryEnabled: false}}, nil) + houstonMock.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{Flags: houston.FeatureFlags{BYORegistryEnabled: false}}, nil) out := &bytes.Buffer{} if s.NoError(Login("dev.astro.io", false, "test", "test", "0.30.0", houstonMock, out)) { @@ -522,7 +522,7 @@ func (s *Suite) TestLoginFailure() { houstonMock.On("GetAuthConfig", mock.Anything).Return(&houston.AuthConfig{LocalEnabled: true}, nil) houstonMock.On("AuthenticateWithBasicAuth", mock.Anything, mock.Anything, mock.Anything).Return(mockToken, nil) houstonMock.On("ListWorkspaces", nil).Return([]houston.Workspace{{ID: "test-workspace-id"}}, nil).Once() - houstonMock.On("GetAppConfig", "").Return(&houston.AppConfig{Flags: houston.FeatureFlags{BYORegistryEnabled: false}}, nil) + houstonMock.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{Flags: houston.FeatureFlags{BYORegistryEnabled: false}}, nil) mockRegistryHandler := new(mocks.RegistryHandler) registryHandlerInit = func(registry string) (airflow.RegistryHandler, error) { diff --git a/software/deploy/deploy.go b/software/deploy/deploy.go index 793a07480..e7657b61a 100644 --- a/software/deploy/deploy.go +++ b/software/deploy/deploy.go @@ -99,7 +99,7 @@ func Airflow(houstonClient houston.ClientInterface, path, deploymentID, wsID str return deploymentID, fmt.Errorf("failed to get deployment info: %w", err) } - appConfig, err := houston.Call(houstonClient.GetAppConfig)(deploymentInfo.ClusterID) + appConfig, err := houston.Call(houstonClient.GetAppConfig)(houston.GetAppConfigRequest{ClusterID: deploymentInfo.ClusterID, WorkspaceUUID: wsID, DeploymentUUID: deploymentID}) if err != nil { return deploymentID, fmt.Errorf("failed to get app config: %w", err) } @@ -483,7 +483,7 @@ func DagsOnlyDeploy(houstonClient houston.ClientInterface, wsID, deploymentID, d if err != nil { return fmt.Errorf("failed to get deployment info: %w", err) } - appConfig, err := houston.Call(houstonClient.GetAppConfig)(deploymentInfo.ClusterID) + appConfig, err := houston.Call(houstonClient.GetAppConfig)(houston.GetAppConfigRequest{ClusterID: deploymentInfo.ClusterID, WorkspaceUUID: wsID, DeploymentUUID: deploymentID}) if err != nil { return fmt.Errorf("failed to get app config: %w", err) } diff --git a/software/deploy/deploy_test.go b/software/deploy/deploy_test.go index 775766805..aa3745b41 100644 --- a/software/deploy/deploy_test.go +++ b/software/deploy/deploy_test.go @@ -482,7 +482,7 @@ func (s *Suite) TestAirflowFailure() { // buildPushDockerImage failure case s.houstonMock.On("GetDeployment", "test-deployment-id").Return(&houston.Deployment{ClusterID: "test-cluster-id"}, nil) - s.houstonMock.On("GetAppConfig", "test-cluster-id").Return(&houston.AppConfig{}, nil) + s.houstonMock.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{}, nil) dockerfile = "Dockerfile.invalid" _, err = Airflow(s.houstonMock, "./testfiles/", "test-deployment-id", "test-workspace-id", false, false, description, false, "") dockerfile = "Dockerfile" @@ -517,7 +517,7 @@ func (s *Suite) TestAirflowSuccess() { {URL: "registry.local.astronomer.io", Type: "registry"}, }, }, nil).Once() - s.houstonMock.On("GetAppConfig", "test-cluster-id").Return(&houston.AppConfig{}, nil).Once() + s.houstonMock.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{}, nil).Once() s.houstonMock.On("GetPlatformVersion", mock.Anything).Return("1.0.0", nil).Once() vars := make(map[string]interface{}) vars["clusterId"] = "test-cluster-id" @@ -556,7 +556,7 @@ func (s *Suite) TestAirflowSuccessForBYORegistry() { {URL: "registry.local.astronomer.io", Type: "registry"}, }, }, nil).Once() - s.houstonMock.On("GetAppConfig", "test-cluster-id").Return(&houston.AppConfig{ + s.houstonMock.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{ Flags: houston.FeatureFlags{ BYORegistryEnabled: true, }, @@ -585,7 +585,7 @@ func (s *Suite) TestAirflowFailureForNoBYORegistryDomain() { {URL: "registry.local.astronomer.io", Type: "registry"}, }, }, nil).Once() - s.houstonMock.On("GetAppConfig", "test-cluster-id").Return(&houston.AppConfig{ + s.houstonMock.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{ Flags: houston.FeatureFlags{ BYORegistryEnabled: true, }, @@ -631,7 +631,7 @@ func (s *Suite) TestAirflowSuccessForImageOnly() { } s.houstonMock.On("GetDeployment", "test-deployment-id").Return(deployment, nil).Once() - s.houstonMock.On("GetAppConfig", "test-cluster-id").Return(&houston.AppConfig{}, nil).Once() + s.houstonMock.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{}, nil).Once() vars := make(map[string]interface{}) vars["clusterId"] = "test-cluster-id" s.houstonMock.On("GetRuntimeReleases", vars).Return(mockRuntimeReleases, nil) @@ -675,7 +675,7 @@ func (s *Suite) TestAirflowSuccessForImageName() { } s.houstonMock.On("GetDeployment", "test-deployment-id").Return(deployment, nil).Once() - s.houstonMock.On("GetAppConfig", "test-cluster-id").Return(&houston.AppConfig{}, nil).Once() + s.houstonMock.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{}, nil).Once() s.houstonMock.On("GetPlatformVersion", mock.Anything).Return("1.0.0", nil).Once() vars := make(map[string]interface{}) vars["clusterId"] = "test-cluster-id" @@ -705,7 +705,7 @@ func (s *Suite) TestAirflowFailForImageNameWhenImageHasNoRuntimeLabel() { } s.houstonMock.On("GetDeployment", "test-deployment-id").Return(deployment, nil).Once() - s.houstonMock.On("GetAppConfig", "test-cluster-id").Return(&houston.AppConfig{}, nil).Once() + s.houstonMock.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{}, nil).Once() _, err := Airflow(s.houstonMock, "./testfiles/", "test-deployment-id", "test-workspace-id", false, false, description, true, customImageName) s.Error(err, ErrNoRuntimeLabelOnCustomImage) @@ -730,7 +730,7 @@ func (s *Suite) TestAirflowFailureForImageOnly() { } s.houstonMock.On("GetDeployment", "test-deployment-id").Return(deployment, nil).Once() - s.houstonMock.On("GetAppConfig", "test-cluster-id").Return(&houston.AppConfig{}, nil).Once() + s.houstonMock.On("GetAppConfig", mock.Anything).Return(&houston.AppConfig{}, nil).Once() _, err := Airflow(s.houstonMock, "./testfiles/", "test-deployment-id", "test-workspace-id", false, false, description, true, "") s.Error(err, ErrDeploymentTypeIncorrectForImageOnly) @@ -757,7 +757,7 @@ func (s *Suite) TestDeployDagsOnlyFailure() { ID: deploymentID, } s.houstonMock.On("GetDeployment", deploymentID).Return(deployment, nil).Once() - s.houstonMock.On("GetAppConfig", deployment.ClusterID).Return(appConfig, nil).Once() + s.houstonMock.On("GetAppConfig", mock.Anything).Return(appConfig, nil).Once() err := DagsOnlyDeploy(s.houstonMock, wsID, deploymentID, config.WorkingPath, nil, false, description) s.ErrorIs(err, ErrDagOnlyDeployDisabledInConfig) }) @@ -798,7 +798,7 @@ func (s *Suite) TestDeployDagsOnlyFailure() { ID: deploymentID, } s.houstonMock.On("GetDeployment", deploymentID).Return(deployment, nil).Once() - s.houstonMock.On("GetAppConfig", deployment.ClusterID).Return(appConfig, nil).Once() + s.houstonMock.On("GetAppConfig", mock.Anything).Return(appConfig, nil).Once() err := DagsOnlyDeploy(s.houstonMock, wsID, deploymentID, config.WorkingPath, nil, false, description) s.ErrorIs(err, ErrDagOnlyDeployNotEnabledForDeployment) }) @@ -823,7 +823,7 @@ func (s *Suite) TestDeployDagsOnlyFailure() { s.houstonMock.On("GetDeployment", deploymentID).Return(deployment, nil).Once() config.ResetCurrentContext() - s.houstonMock.On("GetAppConfig", deployment.ClusterID).Return(appConfig, nil).Once() + s.houstonMock.On("GetAppConfig", mock.Anything).Return(appConfig, nil).Once() err := DagsOnlyDeploy(s.houstonMock, wsID, deploymentID, config.WorkingPath, nil, false, description) s.EqualError(err, "could not get current context! Error: no context set, have you authenticated to Astro or Astro Private Cloud? Run astro login and try again") context.Switch("localhost") @@ -848,7 +848,7 @@ func (s *Suite) TestDeployDagsOnlyFailure() { ClusterID: "test-cluster-id", } s.houstonMock.On("GetDeployment", deploymentID).Return(deployment, nil).Once() - s.houstonMock.On("GetAppConfig", deployment.ClusterID).Return(appConfig, nil).Once() + s.houstonMock.On("GetAppConfig", mock.Anything).Return(appConfig, nil).Once() err := DagsOnlyDeploy(s.houstonMock, wsID, deploymentID, config.WorkingPath, nil, false, description) s.ErrorIs(err, errInvalidDeploymentID) }) @@ -891,7 +891,7 @@ func (s *Suite) TestDeployDagsOnlyFailure() { s.NoError(err) defer os.RemoveAll("dags") - s.houstonMock.On("GetAppConfig", deployment.ClusterID).Return(appConfig, nil).Once() + s.houstonMock.On("GetAppConfig", mock.Anything).Return(appConfig, nil).Once() err = DagsOnlyDeploy(s.houstonMock, wsID, deploymentID, ".", nil, false, description) s.EqualError(err, ErrEmptyDagFolderUserCancelledOperation.Error()) @@ -953,7 +953,7 @@ func (s *Suite) TestDeployDagsOnlyFailure() { })) defer server.Close() - s.houstonMock.On("GetAppConfig", deployment.ClusterID).Return(appConfig, nil).Once() + s.houstonMock.On("GetAppConfig", mock.Anything).Return(appConfig, nil).Once() err = DagsOnlyDeploy(s.houstonMock, wsID, deploymentID, ".", &server.URL, false, description) s.NoError(err) @@ -1003,7 +1003,7 @@ func (s *Suite) TestDeployDagsOnlyFailure() { os.Stdin = r defer testUtil.MockUserInput(s.T(), "y")() - s.houstonMock.On("GetAppConfig", deployment.ClusterID).Return(appConfig, nil).Once() + s.houstonMock.On("GetAppConfig", mock.Anything).Return(appConfig, nil).Once() err = DagsOnlyDeploy(s.houstonMock, wsID, deploymentID, "./dags", nil, false, description) s.EqualError(err, "open dags/dags.tar: no such file or directory") @@ -1048,7 +1048,7 @@ func (s *Suite) TestDeployDagsOnlyFailure() { return gzipMockError } - s.houstonMock.On("GetAppConfig", deployment.ClusterID).Return(appConfig, nil).Once() + s.houstonMock.On("GetAppConfig", mock.Anything).Return(appConfig, nil).Once() err = DagsOnlyDeploy(s.houstonMock, wsID, deploymentID, ".", nil, false, description) s.ErrorIs(err, gzipMockError) @@ -1109,7 +1109,7 @@ func (s *Suite) TestDeployDagsOnlyFailure() { })) defer server.Close() - s.houstonMock.On("GetAppConfig", deployment.ClusterID).Return(appConfig, nil).Once() + s.houstonMock.On("GetAppConfig", mock.Anything).Return(appConfig, nil).Once() err = DagsOnlyDeploy(s.houstonMock, wsID, deploymentID, ".", &server.URL, false, description) s.NoError(err) @@ -1169,7 +1169,7 @@ func (s *Suite) TestDeployDagsOnlyFailure() { })) defer server.Close() - s.houstonMock.On("GetAppConfig", deployment.ClusterID).Return(appConfig, nil).Once() + s.houstonMock.On("GetAppConfig", mock.Anything).Return(appConfig, nil).Once() err = DagsOnlyDeploy(s.houstonMock, wsID, deploymentID, ".", &server.URL, true, description) s.NoError(err)