diff --git a/cmd/.gitignore b/cmd/.gitignore new file mode 100644 index 000000000..c38481fb3 --- /dev/null +++ b/cmd/.gitignore @@ -0,0 +1 @@ +upgrade-test* diff --git a/settings/settings.go b/settings/settings.go index ae6e0d88a..d134e044e 100644 --- a/settings/settings.go +++ b/settings/settings.go @@ -136,7 +136,7 @@ func AddConnections(id string, version uint64, envConns map[string]astrocore.Env connections = AppendEnvironmentConnections(connections, envConns) baseCmd := "airflow connections " - var baseAddCmd, baseRmCmd, baseListCmd, connIDArg, connTypeArg, connURIArg, connExtraArg, connHostArg, connLoginArg, connPasswordArg, connSchemaArg, connPortArg string + var baseAddCmd, baseRmCmd, baseListCmd, connIDArg, connDescriptionArg, connTypeArg, connURIArg, connExtraArg, connHostArg, connLoginArg, connPasswordArg, connSchemaArg, connPortArg string if version >= AirflowVersionTwo { // Airflow 2.0.0 command // based on https://airflow.apache.org/docs/apache-airflow/2.0.0/cli-and-env-variables-ref.html @@ -144,6 +144,7 @@ func AddConnections(id string, version uint64, envConns map[string]astrocore.Env baseRmCmd = baseCmd + "delete " baseListCmd = baseCmd + "list -o plain" connIDArg = "" + connDescriptionArg = "--conn-description" connTypeArg = "--conn-type" connURIArg = "--conn-uri" connExtraArg = "--conn-extra" @@ -194,6 +195,10 @@ func AddConnections(id string, version uint64, envConns map[string]astrocore.Env } airflowCommand = fmt.Sprintf("%s %s '%s' ", baseAddCmd, connIDArg, conn.ConnID) + if objectValidator(0, conn.ConnDescription) { + airflowCommand += fmt.Sprintf("%s '%s' ", connDescriptionArg, conn.ConnDescription) + j++ + } if objectValidator(0, conn.ConnType) { airflowCommand += fmt.Sprintf("%s '%s' ", connTypeArg, conn.ConnType) j++ diff --git a/settings/testfiles/airflow_settings_export.yaml b/settings/testfiles/airflow_settings_export.yaml index d6479b427..32b286c06 100644 --- a/settings/testfiles/airflow_settings_export.yaml +++ b/settings/testfiles/airflow_settings_export.yaml @@ -1,6 +1,7 @@ airflow: connections: - conn_id: local_postgres + conn_description: "" conn_type: postgres conn_host: example.db.example.com conn_schema: schema diff --git a/settings/types.go b/settings/types.go index eabfb4da6..d28d6b37f 100644 --- a/settings/types.go +++ b/settings/types.go @@ -5,15 +5,16 @@ type Connections []Connection // Connection contains structure of airflow connection type Connection struct { - ConnID string `mapstructure:"conn_id" yaml:"conn_id"` - ConnType string `mapstructure:"conn_type" yaml:"conn_type"` - ConnHost string `mapstructure:"conn_host" yaml:"conn_host"` - ConnSchema string `mapstructure:"conn_schema" yaml:"conn_schema"` - ConnLogin string `mapstructure:"conn_login" yaml:"conn_login"` - ConnPassword string `mapstructure:"conn_password" yaml:"conn_password"` - ConnPort int `mapstructure:"conn_port" yaml:"conn_port"` - ConnURI string `mapstructure:"conn_uri" yaml:"conn_uri"` - ConnExtra interface{} `mapstructure:"conn_extra" yaml:"conn_extra"` + ConnID string `mapstructure:"conn_id" yaml:"conn_id"` + ConnDescription string `mapstructure:"conn_description" yaml:"conn_description"` + ConnType string `mapstructure:"conn_type" yaml:"conn_type"` + ConnHost string `mapstructure:"conn_host" yaml:"conn_host"` + ConnSchema string `mapstructure:"conn_schema" yaml:"conn_schema"` + ConnLogin string `mapstructure:"conn_login" yaml:"conn_login"` + ConnPassword string `mapstructure:"conn_password" yaml:"conn_password"` + ConnPort int `mapstructure:"conn_port" yaml:"conn_port"` + ConnURI string `mapstructure:"conn_uri" yaml:"conn_uri"` + ConnExtra interface{} `mapstructure:"conn_extra" yaml:"conn_extra"` } // Pools contains structure of airflow pools