Skip to content
4 changes: 2 additions & 2 deletions cmd/software/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should pass workspace whereever possible. The astro cli commands don't expect workspace to be passed and it is stored in the context. You can fetch it anywhere via the coalesceWorkspace() function. Please use it here and pass the workspace as well.

}

ws, err := coalesceWorkspace()
Expand Down Expand Up @@ -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)
}
Expand Down
8 changes: 5 additions & 3 deletions cmd/software/deployment_service_account_test.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
8 changes: 5 additions & 3 deletions cmd/software/deployment_teams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
52 changes: 26 additions & 26 deletions cmd/software/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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"}
Expand Down Expand Up @@ -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"}
Expand Down Expand Up @@ -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{
Expand All @@ -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")
Expand All @@ -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{
Expand All @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions cmd/software/deployment_user_test.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion cmd/software/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
Expand Down
Loading