From 3adffcaaac61464d0589aa22a7400eb432a67960 Mon Sep 17 00:00:00 2001 From: erdos2n Date: Fri, 18 Aug 2023 14:52:20 +0000 Subject: [PATCH] pre-commit fixes --- cmd/.gitignore | 1 + settings/settings.go | 7 ++++++- .../testfiles/airflow_settings_export.yaml | 1 + settings/types.go | 19 ++++++++++--------- 4 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 cmd/.gitignore 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 9074ba6fb..9dc1af5b4 100644 --- a/settings/settings.go +++ b/settings/settings.go @@ -133,7 +133,7 @@ func AddVariables(id string, version uint64) { func AddConnections(id string, version uint64) { connections := settings.Airflow.Connections 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 @@ -141,6 +141,7 @@ func AddConnections(id string, version uint64) { baseRmCmd = baseCmd + "delete " baseListCmd = baseCmd + "list -o plain" connIDArg = "" + connDescriptionArg = "--conn-description" connTypeArg = "--conn-type" connURIArg = "--conn-uri" connExtraArg = "--conn-extra" @@ -191,6 +192,10 @@ func AddConnections(id string, version uint64) { } 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