diff --git a/cmd/software/deploy.go b/cmd/software/deploy.go index a2ceb3a61..787ead4e0 100644 --- a/cmd/software/deploy.go +++ b/cmd/software/deploy.go @@ -96,6 +96,9 @@ func deployAirflow(cmd *cobra.Command, args []string) error { if appConfig != nil && appConfig.Flags.BYORegistryEnabled { byoRegistryEnabled = true byoRegistryDomain = appConfig.BYORegistryDomain + if byoRegistryDomain == "" { + return deploy.ErrBYORegistryDomainNotSet + } } if isDagOnlyDeploy { return DagsOnlyDeploy(houstonClient, appConfig, ws, deploymentID, config.WorkingPath, nil, true) diff --git a/cmd/software/deploy_test.go b/cmd/software/deploy_test.go index 513725c0b..19d3bf288 100644 --- a/cmd/software/deploy_test.go +++ b/cmd/software/deploy_test.go @@ -79,4 +79,19 @@ func TestDeploy(t *testing.T) { err := execDeployCmd([]string{"test-deployment-id", "--dags", "--force"}...) assert.ErrorIs(t, err, deploy.ErrDagOnlyDeployDisabledInConfig) }) + + t.Run("error should be returned if BYORegistryEnabled is true but BYORegistryDomain is empty", func(t *testing.T) { + appConfig = &houston.AppConfig{ + BYORegistryDomain: "", + Flags: houston.FeatureFlags{ + BYORegistryEnabled: true, + }, + } + DagsOnlyDeploy = func(houstonClient houston.ClientInterface, appConfig *houston.AppConfig, wsID, deploymentID, dagsParentPath string, dagDeployURL *string, cleanUpFiles bool) error { + return deploy.ErrNoWorkspaceID + } + err := execDeployCmd([]string{"-f"}...) + assert.ErrorIs(t, err, deploy.ErrBYORegistryDomainNotSet) + DagsOnlyDeploy = deploy.DagsOnlyDeploy + }) } diff --git a/software/deploy/deploy.go b/software/deploy/deploy.go index 1979001a5..f985593d9 100644 --- a/software/deploy/deploy.go +++ b/software/deploy/deploy.go @@ -41,6 +41,7 @@ var ( ErrDagOnlyDeployDisabledInConfig = errors.New("to perform this operation, set both deployments.dagOnlyDeployment and deployments.configureDagDeployment to true in your Astronomer cluster") ErrDagOnlyDeployNotEnabledForDeployment = errors.New("to perform this operation, first set the Deployment type to 'dag_deploy' via the UI or the API or the CLI") ErrEmptyDagFolderUserCancelledOperation = errors.New("no DAGs found in the dags folder. User canceled the operation") + ErrBYORegistryDomainNotSet = errors.New("Custom registry host is not set in config. It can be set at astronomer.houston.config.deployments.registry.protectedCustomRegistry.updateRegistry.host") //nolint ) const (