diff --git a/cmd/deployment.go b/cmd/deployment.go index aceccf9d6..a7166df96 100644 --- a/cmd/deployment.go +++ b/cmd/deployment.go @@ -19,6 +19,7 @@ var ( systemSA bool category string label string + releaseName string CreateExample = ` # Create new deployment with Celery executor (default: celery without params). $ astro deployment create new-deployment-name --executor=celery @@ -76,6 +77,7 @@ func newDeploymentCreateCmd(client *houston.Client, out io.Writer) *cobra.Comman RunE: deploymentCreate, } cmd.Flags().StringVarP(&executor, "executor", "e", "", "Add executor parameter: local or celery") + cmd.Flags().StringVarP(&releaseName, "release-name", "r", "", "Set custom release-name if possible") return cmd } @@ -212,7 +214,7 @@ func deploymentCreate(cmd *cobra.Command, args []string) error { return errors.New("please specify correct executor, one of: local, celery, kubernetes, k8s") } - return deployment.Create(args[0], ws, deploymentConfig) + return deployment.Create(args[0], ws, releaseName, deploymentConfig) } func deploymentDelete(cmd *cobra.Command, args []string) error { diff --git a/deployment/deployment.go b/deployment/deployment.go index f761db507..169796ad7 100644 --- a/deployment/deployment.go +++ b/deployment/deployment.go @@ -20,10 +20,28 @@ var ( } ) -func Create(label, ws string, deploymentConfig map[string]string) error { +func checkManualReleaseNames() bool { + req := houston.Request{ + Query: houston.AppConfigRequest, + } + r, err := req.Do() + if err != nil { + return false + } + + return r.Data.GetAppConfig.ManualReleaseNames +} + +func Create(label, ws, releaseName string, deploymentConfig map[string]string) error { + vars := map[string]interface{}{"label": label, "workspaceId": ws, "config": deploymentConfig} + + if releaseName != "" && checkManualReleaseNames() { + vars["releaseName"] = releaseName + } + req := houston.Request{ Query: houston.DeploymentCreateRequest, - Variables: map[string]interface{}{"label": label, "workspaceId": ws, "config": deploymentConfig}, + Variables: vars, } r, err := req.Do() diff --git a/houston/queries.go b/houston/queries.go index e00dc7e7a..dd78faff8 100644 --- a/houston/queries.go +++ b/houston/queries.go @@ -19,6 +19,7 @@ var ( mutation CreateDeployment( $label: String! $type: String = "airflow" + $releaseName: String $workspaceId: Uuid! $config: JSON! ) { @@ -26,6 +27,7 @@ var ( label: $label type: $type workspaceUuid: $workspaceId + releaseName: $releaseName config: $config ) { id @@ -438,4 +440,13 @@ var ( defaultAirflowImageTag } }` + AppConfigRequest = ` + query AppConfig { + appConfig { + version + baseDomain + smtpConfigured + manualReleaseNames + } + }` ) diff --git a/houston/types.go b/houston/types.go index 3ee530a7c..c975bfcd5 100644 --- a/houston/types.go +++ b/houston/types.go @@ -17,6 +17,7 @@ type Response struct { DeleteWorkspace *Workspace `json:"deleteWorkspace,omitempty"` GetDeployments []Deployment `json:"workspaceDeployments,omitempty"` GetAuthConfig *AuthConfig `json:"authConfig,omitempty"` + GetAppConfig *AppConfig `json:"appConfig,omitempty"` GetServiceAccounts []ServiceAccount `json:"serviceAccounts,omitempty"` GetUsers []User `json:"users,omitempty"` GetWorkspaces []Workspace `json:"workspaces,omitempty"` @@ -226,3 +227,11 @@ func (config *DeploymentConfig) IsValidTag(tag string) bool { } return false } + +// AppConfig contains current houston config +type AppConfig struct { + Version string `json:"version"` + BaseDomain string `json:"baseDomain"` + SmtpConfigured bool `json:"smtpConfigured"` + ManualReleaseNames bool `json:"manualReleaseNames"` +}