• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

astronomer / astro-cli / 357629b1-60cb-43d6-9ac2-8b5249dd574b

26 Mar 2026 02:28PM UTC coverage: 36.086% (-0.3%) from 36.378%
357629b1-60cb-43d6-9ac2-8b5249dd574b

Pull #2060

circleci

jlaneve
fix: add include/ to PYTHONPATH in standalone mode

Standalone mode's buildEnv() did not set PYTHONPATH to include the
project's include/ directory. In Docker mode the Astronomer runtime
image bakes /usr/local/airflow/include into PYTHONPATH, but standalone
had no equivalent — causing import failures for any user modules in
include/ during pytest, parse, and start.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pull Request #2060: fix: add include/ to PYTHONPATH in standalone mode

7 of 8 new or added lines in 1 file covered. (87.5%)

403 existing lines in 8 files now uncovered.

24494 of 67876 relevant lines covered (36.09%)

8.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.19
/cmd/cloud/deployment_objects.go
1
package cloud
2

3
import (
4
        "fmt"
5
        "io"
6
        "strings"
7

8
        airflowversions "github.com/astronomer/astro-cli/airflow_versions"
9
        astroplatformcore "github.com/astronomer/astro-cli/astro-client-platform-core"
10
        "github.com/astronomer/astro-cli/cloud/deployment"
11
        "github.com/astronomer/astro-cli/cloud/deployment/inspect"
12
        "github.com/pkg/errors"
13
        "github.com/spf13/cobra"
14
)
15

16
var (
17
        connID             string
18
        connType           string
19
        host               string
20
        login              string
21
        password           string
22
        schema             string
23
        extra              string
24
        fromDeploymentID   string
25
        fromDeploymentName string
26
        toDeploymentID     string
27
        toDeploymentName   string
28
        port               int
29
        varValue           string
30
        key                string
31
        slots              int
32
        includeDeferred    string
33
)
34

35
const (
36
        webserverURLField        = "metadata.airflow_api_url"
37
        warningConnectionCopyCMD = "WARNING! The password and extra field are not copied over. You will need to manually add these values"
38
        warningVariableCopyCMD   = "WARNING! Secret values are not copied over. You will need to manually add these values"
39
)
40

41
func newDeploymentConnectionRootCmd(out io.Writer) *cobra.Command {
236✔
42
        cmd := &cobra.Command{
236✔
43
                Use:     "connection",
236✔
44
                Aliases: []string{"con", "connections"},
236✔
45
                Short:   "Manage deployment connections",
236✔
46
                Long:    "Manage connections for an Astro Deployment.",
236✔
47
        }
236✔
48
        cmd.AddCommand(
236✔
49
                newDeploymentConnectionListCmd(out),
236✔
50
                newDeploymentConnectionCreateCmd(out),
236✔
51
                newDeploymentConnectionUpdateCmd(out),
236✔
52
                newDeploymentConnectionCopyCmd(out),
236✔
53
        )
236✔
54
        return cmd
236✔
55
}
236✔
56

57
func newDeploymentConnectionListCmd(out io.Writer) *cobra.Command {
236✔
58
        cmd := &cobra.Command{
236✔
59
                Use:     "list",
236✔
60
                Aliases: []string{"li"},
236✔
61
                Short:   "list a Deployment's connections",
236✔
62
                Long:    "list connections for an Astro Deployment",
236✔
63
                RunE: func(cmd *cobra.Command, args []string) error {
238✔
64
                        return deploymentConnectionList(cmd, out)
2✔
65
                },
2✔
66
        }
67
        cmd.Flags().StringVarP(&deploymentID, "deployment-id", "d", "", "The ID of the Deployment.")
236✔
68
        cmd.Flags().StringVarP(&deploymentName, "deployment-name", "n", "", "The name of the Deployment.")
236✔
69

236✔
70
        return cmd
236✔
71
}
72

73
//nolint:dupl
74
func newDeploymentConnectionCreateCmd(out io.Writer) *cobra.Command {
236✔
75
        cmd := &cobra.Command{
236✔
76
                Use:     "create",
236✔
77
                Aliases: []string{"cr"},
236✔
78
                Short:   "Create connections for a Deployment",
236✔
79
                Long:    "Create Airflow connections for an Astro Deployment",
236✔
80
                RunE: func(cmd *cobra.Command, args []string) error {
239✔
81
                        return deploymentConnectionCreate(cmd, out)
3✔
82
                },
3✔
83
        }
84
        cmd.Flags().StringVarP(&deploymentID, "deployment-id", "d", "", "The ID of the Deployment.")
236✔
85
        cmd.Flags().StringVarP(&deploymentName, "deployment-name", "n", "", "The name of the Deployment.")
236✔
86
        cmd.Flags().StringVarP(&connID, "conn-id", "i", "", "The connection ID. Required.")
236✔
87
        cmd.Flags().StringVarP(&connType, "conn-type", "t", "", "The connection type. Required.")
236✔
88
        cmd.Flags().StringVarP(&description, "description", "", "", "The connection description.")
236✔
89
        cmd.Flags().StringVarP(&host, "host", "", "", "The connection host.")
236✔
90
        cmd.Flags().StringVarP(&login, "login", "l", "", "The connection login or username.")
236✔
91
        cmd.Flags().StringVarP(&password, "password", "p", "", "The connection password.")
236✔
92
        cmd.Flags().StringVarP(&schema, "schema", "s", "", "The connection schema.")
236✔
93
        cmd.Flags().IntVarP(&port, "port", "o", 0, "The connection port.")
236✔
94
        cmd.Flags().StringVarP(&extra, "extra", "e", "", "The extra field configuration, defined as a stringified JSON object.")
236✔
95

236✔
96
        return cmd
236✔
97
}
98

99
//nolint:dupl
100
func newDeploymentConnectionUpdateCmd(out io.Writer) *cobra.Command {
236✔
101
        cmd := &cobra.Command{
236✔
102
                Use:     "update",
236✔
103
                Aliases: []string{"up"},
236✔
104
                Short:   "Update connections for a Deployment",
236✔
105
                Long:    "Update existing Airflow connections for an Astro Deployment",
236✔
106
                RunE: func(cmd *cobra.Command, args []string) error {
239✔
107
                        return deploymentConnectionUpdate(cmd, out)
3✔
108
                },
3✔
109
        }
110
        cmd.Flags().StringVarP(&deploymentID, "deployment-id", "d", "", "The ID of the Deployment.")
236✔
111
        cmd.Flags().StringVarP(&deploymentName, "deployment-name", "n", "", "The name of the Deployment.")
236✔
112
        cmd.Flags().StringVarP(&connID, "conn-id", "i", "", "The connection ID. Required.")
236✔
113
        cmd.Flags().StringVarP(&connType, "conn-type", "t", "", "The connection type. Required.")
236✔
114
        cmd.Flags().StringVarP(&description, "description", "", "", "The connection description.")
236✔
115
        cmd.Flags().StringVarP(&host, "host", "", "", "The connection host.")
236✔
116
        cmd.Flags().StringVarP(&login, "login", "l", "", "The connection login or username.")
236✔
117
        cmd.Flags().StringVarP(&password, "password", "p", "", "The connection password.")
236✔
118
        cmd.Flags().StringVarP(&schema, "schema", "s", "", "The connection schema.")
236✔
119
        cmd.Flags().IntVarP(&port, "port", "o", 0, "The connection port.")
236✔
120
        cmd.Flags().StringVarP(&extra, "extra", "e", "", "The extra field configuration, defined as a stringified JSON object.")
236✔
121

236✔
122
        return cmd
236✔
123
}
124

125
//nolint:dupl
126
func newDeploymentConnectionCopyCmd(out io.Writer) *cobra.Command {
236✔
127
        cmd := &cobra.Command{
236✔
128
                Use:     "copy",
236✔
129
                Aliases: []string{"cp"},
236✔
130
                Short:   "Copy connections from one Deployment to another",
236✔
131
                Long:    "Copy Airflow connections from one Astro Deployment to another. Passwords and extra configurations will not copy over. If a connection already exits with same connection ID in the target Deployment, that connection will be updated",
236✔
132
                RunE: func(cmd *cobra.Command, args []string) error {
239✔
133
                        return deploymentConnectionCopy(cmd, out)
3✔
134
                },
3✔
135
        }
136
        cmd.Flags().StringVarP(&fromDeploymentID, "source-id", "s", "", "The ID of the Deployment to copy connections from.")
236✔
137
        cmd.Flags().StringVarP(&fromDeploymentName, "source-name", "n", "", "The name of the Deployment to copy connections from")
236✔
138
        cmd.Flags().StringVarP(&toDeploymentID, "target-id", "t", "", "The ID of the Deployment to receive the copied connections")
236✔
139
        cmd.Flags().StringVarP(&toDeploymentName, "target-name", "", "", "The name of the Deployment to receive the copied connections")
236✔
140

236✔
141
        return cmd
236✔
142
}
143

144
func newDeploymentAirflowVariableRootCmd(out io.Writer) *cobra.Command {
236✔
145
        cmd := &cobra.Command{
236✔
146
                Use:     "airflow-variable",
236✔
147
                Aliases: []string{"var"},
236✔
148
                Short:   "Manage Airflow variables in an Astro Deployment",
236✔
149
                Long:    "Manage Airflow variables stored in an Astro Deployment's metadata database.",
236✔
150
        }
236✔
151
        cmd.AddCommand(
236✔
152
                newDeploymentAirflowVariableListCmd(out),
236✔
153
                newDeploymentAirflowVariableCreateCmd(out),
236✔
154
                newDeploymentAirflowVariableUpdateCmd(out),
236✔
155
                newDeploymentAirflowVariableCopyCmd(out),
236✔
156
        )
236✔
157
        return cmd
236✔
158
}
236✔
159

160
func newDeploymentAirflowVariableListCmd(out io.Writer) *cobra.Command {
236✔
161
        cmd := &cobra.Command{
236✔
162
                Use:     "list",
236✔
163
                Aliases: []string{"li"},
236✔
164
                Short:   "list a Deployment's Airflow variables",
236✔
165
                Long:    "list Airflow variables stored in an Astro Deployment's metadata database",
236✔
166
                RunE: func(cmd *cobra.Command, args []string) error {
238✔
167
                        return deploymentAirflowVariableList(cmd, out)
2✔
168
                },
2✔
169
        }
170
        cmd.Flags().StringVarP(&deploymentID, "deployment-id", "d", "", "The ID of the Deployment.")
236✔
171
        cmd.Flags().StringVarP(&deploymentName, "deployment-name", "n", "", "The name of the Deployment.")
236✔
172

236✔
173
        return cmd
236✔
174
}
175

176
//nolint:dupl
177
func newDeploymentAirflowVariableCreateCmd(out io.Writer) *cobra.Command {
236✔
178
        cmd := &cobra.Command{
236✔
179
                Use:     "create",
236✔
180
                Aliases: []string{"cr"},
236✔
181
                Short:   "Create Airflow variables for a Deployment",
236✔
182
                Long:    "Create Airflow variables for an Astro Deployment",
236✔
183
                RunE: func(cmd *cobra.Command, args []string) error {
239✔
184
                        return deploymentAirflowVariableCreate(cmd, out)
3✔
185
                },
3✔
186
        }
187
        cmd.Flags().StringVarP(&deploymentID, "deployment-id", "d", "", "The ID of the Deployment.")
236✔
188
        cmd.Flags().StringVarP(&deploymentName, "deployment-name", "n", "", "The name of the Deployment.")
236✔
189
        cmd.Flags().StringVarP(&varValue, "value", "v", "", "The Airflow variable value. Required.")
236✔
190
        cmd.Flags().StringVarP(&key, "key", "k", "", "The Airflow variable key. Required.")
236✔
191
        cmd.Flags().StringVarP(&description, "description", "", "", "The Airflow variable description.")
236✔
192

236✔
193
        return cmd
236✔
194
}
195

196
//nolint:dupl
197
func newDeploymentAirflowVariableUpdateCmd(out io.Writer) *cobra.Command {
236✔
198
        cmd := &cobra.Command{
236✔
199
                Use:     "update",
236✔
200
                Aliases: []string{"up"},
236✔
201
                Short:   "Update Airflow variables for a Deployment",
236✔
202
                Long:    "Update Airflow variables for an Astro Deployment",
236✔
203
                RunE: func(cmd *cobra.Command, args []string) error {
239✔
204
                        return deploymentAirflowVariableUpdate(cmd, out)
3✔
205
                },
3✔
206
        }
207
        cmd.Flags().StringVarP(&deploymentID, "deployment-id", "d", "", "The ID of the Deployment.")
236✔
208
        cmd.Flags().StringVarP(&deploymentName, "deployment-name", "n", "", "The name of the Deployment.")
236✔
209
        cmd.Flags().StringVarP(&varValue, "value", "v", "", "The Airflow variable value. Required.")
236✔
210
        cmd.Flags().StringVarP(&key, "key", "k", "", "The Airflow variable key. Required.")
236✔
211
        cmd.Flags().StringVarP(&description, "description", "", "", "The Airflow variable description.")
236✔
212

236✔
213
        return cmd
236✔
214
}
215

216
//nolint:dupl
217
func newDeploymentAirflowVariableCopyCmd(out io.Writer) *cobra.Command {
236✔
218
        cmd := &cobra.Command{
236✔
219
                Use:     "copy",
236✔
220
                Aliases: []string{"cp"},
236✔
221
                Short:   "Copy the Airflow variables from one Deployment to another",
236✔
222
                Long:    "Copy Airflow variables from one Astro Deployment to another Astro Deployment. If a variable already exits with same Key it will be updated",
236✔
223
                RunE: func(cmd *cobra.Command, args []string) error {
239✔
224
                        return deploymentAirflowVariableCopy(cmd, out)
3✔
225
                },
3✔
226
        }
227
        cmd.Flags().StringVarP(&fromDeploymentID, "source-id", "s", "", "The ID of the Deployment to copy Airflow variables from.")
236✔
228
        cmd.Flags().StringVarP(&fromDeploymentName, "source-name", "n", "", "The name of the Deployment to copy Airflow variables from")
236✔
229
        cmd.Flags().StringVarP(&toDeploymentID, "target-id", "t", "", "The ID of the Deployment to receive the copied Airflow variables")
236✔
230
        cmd.Flags().StringVarP(&toDeploymentName, "target-name", "", "", "The name of the Deployment to receive the copied Airflow variables")
236✔
231

236✔
232
        return cmd
236✔
233
}
234

235
func newDeploymentPoolRootCmd(out io.Writer) *cobra.Command {
236✔
236
        cmd := &cobra.Command{
236✔
237
                Use:     "pool",
236✔
238
                Aliases: []string{"pl", "pools"},
236✔
239
                Short:   "Manage Deployment's Airflow pools",
236✔
240
                Long:    "Manage Airflow pools stored for an Astro Deployment",
236✔
241
        }
236✔
242
        cmd.AddCommand(
236✔
243
                newDeploymentPoolListCmd(out),
236✔
244
                newDeploymentPoolCreateCmd(out),
236✔
245
                newDeploymentPoolUpdateCmd(out),
236✔
246
                newDeploymentPoolCopyCmd(out),
236✔
247
        )
236✔
248
        return cmd
236✔
249
}
236✔
250

251
func newDeploymentPoolListCmd(out io.Writer) *cobra.Command {
236✔
252
        cmd := &cobra.Command{
236✔
253
                Use:     "list",
236✔
254
                Aliases: []string{"li"},
236✔
255
                Short:   "list a Deployment's Airflow pools",
236✔
256
                Long:    "list Airflow pools for an Astro Deployment",
236✔
257
                RunE: func(cmd *cobra.Command, args []string) error {
238✔
258
                        return deploymentPoolList(cmd, out)
2✔
259
                },
2✔
260
        }
261
        cmd.Flags().StringVarP(&deploymentID, "deployment-id", "d", "", "The ID of the Deployment.")
236✔
262
        cmd.Flags().StringVarP(&deploymentName, "deployment-name", "n", "", "The name of the Deployment.")
236✔
263

236✔
264
        return cmd
236✔
265
}
266

267
//nolint:dupl
268
func newDeploymentPoolCreateCmd(out io.Writer) *cobra.Command {
236✔
269
        cmd := &cobra.Command{
236✔
270
                Use:     "create",
236✔
271
                Aliases: []string{"cr"},
236✔
272
                Short:   "Create Airflow pools for an Astro Deployment",
236✔
273
                Long:    "Create Airflow pools for an Astro Deployment",
236✔
274
                RunE: func(cmd *cobra.Command, args []string) error {
240✔
275
                        return deploymentPoolCreate(cmd, out)
4✔
276
                },
4✔
277
        }
278
        cmd.Flags().StringVarP(&deploymentID, "deployment-id", "d", "", "The ID of the Deployment.")
236✔
279
        cmd.Flags().StringVarP(&deploymentName, "deployment-name", "n", "", "The name of the Deployment.")
236✔
280
        cmd.Flags().StringVarP(&name, "name", "", "", "The Airflow pool value. Required")
236✔
281
        cmd.Flags().IntVarP(&slots, "slots", "s", 0, "The Airflow pool key. Required")
236✔
282
        cmd.Flags().StringVarP(&description, "description", "", "", "The Airflow pool description")
236✔
283
        cmd.Flags().StringVarP(&includeDeferred, "include-deferred", "", "", "If set to 'enable', deferred tasks are considered when calculating open pool slots. Default is 'disable'. Possible values are disable/enable.")
236✔
284

236✔
285
        return cmd
236✔
286
}
287

288
//nolint:dupl
289
func newDeploymentPoolUpdateCmd(out io.Writer) *cobra.Command {
236✔
290
        cmd := &cobra.Command{
236✔
291
                Use:     "update",
236✔
292
                Aliases: []string{"up"},
236✔
293
                Short:   "Update Airflow pools for an Astro Deployment",
236✔
294
                Long:    "Update Airflow pools for an Astro Deployment",
236✔
295
                RunE: func(cmd *cobra.Command, args []string) error {
240✔
296
                        return deploymentPoolUpdate(cmd, out)
4✔
297
                },
4✔
298
        }
299
        cmd.Flags().StringVarP(&deploymentID, "deployment-id", "d", "", "The ID of the Deployment.")
236✔
300
        cmd.Flags().StringVarP(&deploymentName, "deployment-name", "n", "", "The name of the Deployment.")
236✔
301
        cmd.Flags().StringVarP(&name, "name", "", "", "The pool value.  Required.")
236✔
302
        cmd.Flags().IntVarP(&slots, "slots", "s", 0, "The pool slots.")
236✔
303
        cmd.Flags().StringVarP(&description, "description", "", "", "The pool description.")
236✔
304
        cmd.Flags().StringVarP(&includeDeferred, "include-deferred", "", "", "If set to 'enable', deferred tasks are considered when calculating open pool slots. Required for Airflow 3+ deployments. Possible values disable/enable.")
236✔
305

236✔
306
        return cmd
236✔
307
}
308

309
//nolint:dupl
310
func newDeploymentPoolCopyCmd(out io.Writer) *cobra.Command {
236✔
311
        cmd := &cobra.Command{
236✔
312
                Use:     "copy",
236✔
313
                Aliases: []string{"cp"},
236✔
314
                Short:   "Copy Airflow pools from one Astro Deployment to another",
236✔
315
                Long:    "Copy Airflow pools from one Astro Deployment to another Astro Deployment. If a pool already exits with same name it will be updated",
236✔
316
                RunE: func(cmd *cobra.Command, args []string) error {
239✔
317
                        return deploymentPoolCopy(cmd, out)
3✔
318
                },
3✔
319
        }
320
        cmd.Flags().StringVarP(&fromDeploymentID, "source-id", "s", "", "The ID of the Deployment to copy Airflow pools from.")
236✔
321
        cmd.Flags().StringVarP(&fromDeploymentName, "source-name", "n", "", "The name of the Deployment to copy Airflow pools from")
236✔
322
        cmd.Flags().StringVarP(&toDeploymentID, "target-id", "t", "", "The ID of the Deployment to receive the copied Airflow pools")
236✔
323
        cmd.Flags().StringVarP(&toDeploymentName, "target-name", "", "", "The name of the Deployment to receive the copied Airflow pools")
236✔
324

236✔
325
        return cmd
236✔
326
}
327

328
//nolint:dupl
329
func deploymentConnectionList(cmd *cobra.Command, out io.Writer) error {
2✔
330
        ws, err := coalesceWorkspace()
2✔
331
        if err != nil {
3✔
332
                return errors.Wrap(err, "failed to find a valid workspace")
1✔
333
        }
1✔
334

335
        // Silence Usage as we have now validated command input
336
        cmd.SilenceUsage = true
1✔
337

1✔
338
        // get or select the deployment
1✔
339
        requestedDeployment, err := deployment.GetDeployment(ws, deploymentID, deploymentName, false, nil, platformCoreClient, astroCoreClient)
1✔
340
        if err != nil {
1✔
UNCOV
341
                return err
×
UNCOV
342
        }
×
343

344
        airflowURL, err := getAirflowURL(&requestedDeployment)
1✔
345
        if err != nil {
1✔
UNCOV
346
                return err
×
UNCOV
347
        }
×
348

349
        return deployment.ConnectionList(airflowURL, airflowAPIClient, out)
1✔
350
}
351

352
func deploymentConnectionCreate(cmd *cobra.Command, out io.Writer) error {
3✔
353
        ws, err := coalesceWorkspace()
3✔
354
        if err != nil {
4✔
355
                return errors.Wrap(err, "failed to find a valid Workspace")
1✔
356
        }
1✔
357

358
        // Silence Usage as we have now validated command input
359
        cmd.SilenceUsage = true
2✔
360

2✔
361
        // get or select the deployment
2✔
362
        requestedDeployment, err := deployment.GetDeployment(ws, deploymentID, deploymentName, false, nil, platformCoreClient, astroCoreClient)
2✔
363
        if err != nil {
2✔
UNCOV
364
                return err
×
UNCOV
365
        }
×
366

367
        airflowURL, err := getAirflowURL(&requestedDeployment)
2✔
368
        if err != nil {
2✔
UNCOV
369
                return err
×
UNCOV
370
        }
×
371

372
        // check connID and connType
373
        if connID == "" {
2✔
UNCOV
374
                return errors.New("a connection ID is needed to create a connection. Please use the '--conn-id' flag to specify a connection ID")
×
UNCOV
375
        }
×
376

377
        if connType == "" {
2✔
UNCOV
378
                return errors.New("a connection type is needed to create a connection. Please use the '--conn-type' flag to specify a connection type")
×
UNCOV
379
        }
×
380

381
        return deployment.ConnectionCreate(airflowURL, connID, connType, description, host, login, password, schema, extra, port, airflowAPIClient, out)
2✔
382
}
383

384
func deploymentConnectionUpdate(cmd *cobra.Command, out io.Writer) error {
3✔
385
        ws, err := coalesceWorkspace()
3✔
386
        if err != nil {
4✔
387
                return errors.Wrap(err, "failed to find a valid workspace")
1✔
388
        }
1✔
389

390
        // Silence Usage as we have now validated command input
391
        cmd.SilenceUsage = true
2✔
392

2✔
393
        // get or select the deployment
2✔
394
        requestedDeployment, err := deployment.GetDeployment(ws, deploymentID, deploymentName, false, nil, platformCoreClient, astroCoreClient)
2✔
395
        if err != nil {
2✔
UNCOV
396
                return err
×
UNCOV
397
        }
×
398

399
        airflowURL, err := getAirflowURL(&requestedDeployment)
2✔
400
        if err != nil {
2✔
UNCOV
401
                return err
×
UNCOV
402
        }
×
403

404
        // check connID and connType
405
        if connID == "" {
2✔
UNCOV
406
                return errors.New("a connection ID is needed to create a connection. Please use the '--conn-id' flag to specify a connection ID")
×
UNCOV
407
        }
×
408

409
        return deployment.ConnectionUpdate(airflowURL, connID, connType, description, host, login, password, schema, extra, port, airflowAPIClient, out)
2✔
410
}
411

412
//nolint:dupl
413
func deploymentConnectionCopy(cmd *cobra.Command, out io.Writer) error {
3✔
414
        ws, err := coalesceWorkspace()
3✔
415
        if err != nil {
4✔
416
                return errors.Wrap(err, "failed to find a valid Workspace")
1✔
417
        }
1✔
418

419
        // Silence Usage as we have now validated command input
420
        cmd.SilenceUsage = true
2✔
421

2✔
422
        // get source deployment
2✔
423
        if fromDeploymentName == "" && fromDeploymentID == "" {
2✔
424
                fmt.Println("Which Deployment should connections be copied from?")
×
425
        }
×
426
        fromDeployment, err := deployment.GetDeployment(ws, fromDeploymentID, fromDeploymentName, false, nil, platformCoreClient, astroCoreClient)
2✔
427
        if err != nil {
2✔
UNCOV
428
                return errors.Wrap(err, "failed to find the source Deployment")
×
UNCOV
429
        }
×
430

431
        fromAirflowURL, err := getAirflowURL(&fromDeployment)
2✔
432
        if err != nil {
2✔
UNCOV
433
                return errors.Wrap(err, "failed to find the source Deployment Airflow webserver URL")
×
UNCOV
434
        }
×
435

436
        // get target deployment
437
        if toDeploymentName == "" && toDeploymentID == "" {
2✔
UNCOV
438
                fmt.Println("Which Deployment should receive the connections?")
×
UNCOV
439
        }
×
440
        toDeployment, err := deployment.GetDeployment(ws, toDeploymentID, toDeploymentName, false, nil, platformCoreClient, astroCoreClient)
2✔
441
        if err != nil {
2✔
442
                return errors.Wrap(err, "failed to find the target Deployment")
×
443
        }
×
444

445
        toAirflowURL, err := getAirflowURL(&toDeployment)
2✔
446
        if err != nil {
2✔
447
                return errors.Wrap(err, "failed to find the target Deployment Airflow webserver URL")
×
448
        }
×
449

450
        fmt.Println(warningConnectionCopyCMD)
2✔
451
        return deployment.CopyConnection(fromAirflowURL, toAirflowURL, airflowAPIClient, out)
2✔
452
}
453

454
//nolint:dupl
455
func deploymentAirflowVariableList(cmd *cobra.Command, out io.Writer) error {
2✔
456
        ws, err := coalesceWorkspace()
2✔
457
        if err != nil {
3✔
458
                return errors.Wrap(err, "failed to find a valid Workspace")
1✔
459
        }
1✔
460

461
        // Silence Usage as we have now validated command input
462
        cmd.SilenceUsage = true
1✔
463

1✔
464
        // get or select the deployment
1✔
465
        requestedDeployment, err := deployment.GetDeployment(ws, deploymentID, deploymentName, false, nil, platformCoreClient, astroCoreClient)
1✔
466
        if err != nil {
1✔
UNCOV
467
                return err
×
UNCOV
468
        }
×
469

470
        airflowURL, err := getAirflowURL(&requestedDeployment)
1✔
471
        if err != nil {
1✔
UNCOV
472
                return err
×
UNCOV
473
        }
×
474

475
        return deployment.AirflowVariableList(airflowURL, airflowAPIClient, out)
1✔
476
}
477

478
func deploymentAirflowVariableCreate(cmd *cobra.Command, out io.Writer) error {
3✔
479
        ws, err := coalesceWorkspace()
3✔
480
        if err != nil {
4✔
481
                return errors.Wrap(err, "failed to find a valid workspace")
1✔
482
        }
1✔
483

484
        // Silence Usage as we have now validated command input
485
        cmd.SilenceUsage = true
2✔
486

2✔
487
        // get or select the deployment
2✔
488
        requestedDeployment, err := deployment.GetDeployment(ws, deploymentID, deploymentName, false, nil, platformCoreClient, astroCoreClient)
2✔
489
        if err != nil {
2✔
UNCOV
490
                return err
×
UNCOV
491
        }
×
492

493
        airflowURL, err := getAirflowURL(&requestedDeployment)
2✔
494
        if err != nil {
2✔
UNCOV
495
                return err
×
UNCOV
496
        }
×
497

498
        // check key and varValue
499
        if key == "" {
2✔
UNCOV
500
                return errors.New("a variable key is needed to create an airflow variable. Please use the '--key' flag to specify a key")
×
UNCOV
501
        }
×
502

503
        if varValue == "" {
2✔
UNCOV
504
                return errors.New("a variable value is needed to create an airflow variable. Please use the '--value' flag to specify a value")
×
UNCOV
505
        }
×
506

507
        return deployment.VariableCreate(airflowURL, varValue, key, description, airflowAPIClient, out)
2✔
508
}
509

510
func deploymentAirflowVariableUpdate(cmd *cobra.Command, out io.Writer) error { //nolint
3✔
511
        ws, err := coalesceWorkspace()
3✔
512
        if err != nil {
4✔
513
                return errors.Wrap(err, "failed to find a valid workspace")
1✔
514
        }
1✔
515

516
        // Silence Usage as we have now validated command input
517
        cmd.SilenceUsage = true
2✔
518

2✔
519
        // get or select the deployment
2✔
520
        requestedDeployment, err := deployment.GetDeployment(ws, deploymentID, deploymentName, false, nil, platformCoreClient, astroCoreClient)
2✔
521
        if err != nil {
2✔
UNCOV
522
                return err
×
UNCOV
523
        }
×
524

525
        airflowURL, err := getAirflowURL(&requestedDeployment)
2✔
526
        if err != nil {
2✔
UNCOV
527
                return err
×
UNCOV
528
        }
×
529

530
        // check key
531
        if key == "" {
2✔
UNCOV
532
                return errors.New("a variable key is needed to create an airflow variable. Please use the '--key' flag to specify a key")
×
UNCOV
533
        }
×
534

535
        return deployment.VariableUpdate(airflowURL, varValue, key, description, airflowAPIClient, out)
2✔
536
}
537

538
//nolint:dupl
539
func deploymentAirflowVariableCopy(cmd *cobra.Command, out io.Writer) error {
3✔
540
        ws, err := coalesceWorkspace()
3✔
541
        if err != nil {
4✔
542
                return errors.Wrap(err, "failed to find a valid workspace")
1✔
543
        }
1✔
544

545
        // Silence Usage as we have now validated command input
546
        cmd.SilenceUsage = true
2✔
547

2✔
548
        // get source deployment
2✔
549
        if fromDeploymentName == "" && fromDeploymentID == "" {
2✔
550
                fmt.Println("Which deployment should airflow variables be copied from?")
×
551
        }
×
552
        fromDeployment, err := deployment.GetDeployment(ws, fromDeploymentID, fromDeploymentName, false, nil, platformCoreClient, astroCoreClient)
2✔
553
        if err != nil {
2✔
UNCOV
554
                return errors.Wrap(err, "failed to find the source Deployment")
×
UNCOV
555
        }
×
556

557
        fromAirflowURL, err := getAirflowURL(&fromDeployment)
2✔
558
        if err != nil {
2✔
UNCOV
559
                return errors.Wrap(err, "failed to find the source deployments airflow webserver URL")
×
UNCOV
560
        }
×
561

562
        // get target deployment
563
        if toDeploymentName == "" && toDeploymentID == "" {
2✔
UNCOV
564
                fmt.Println("Which deployment should airflow variables be pasted to?")
×
UNCOV
565
        }
×
566
        toDeployment, err := deployment.GetDeployment(ws, toDeploymentID, toDeploymentName, false, nil, platformCoreClient, astroCoreClient)
2✔
567
        if err != nil {
2✔
568
                return errors.Wrap(err, "failed to find the target Deployment")
×
569
        }
×
570

571
        toAirflowURL, err := getAirflowURL(&toDeployment)
2✔
572
        if err != nil {
2✔
573
                return errors.Wrap(err, "failed to find the target deployments airflow webserver URL")
×
574
        }
×
575

576
        fmt.Println(warningVariableCopyCMD)
2✔
577
        return deployment.CopyVariable(fromAirflowURL, toAirflowURL, airflowAPIClient, out)
2✔
578
}
579

580
//nolint:dupl
581
func deploymentPoolList(cmd *cobra.Command, out io.Writer) error {
2✔
582
        ws, err := coalesceWorkspace()
2✔
583
        if err != nil {
3✔
584
                return errors.Wrap(err, "failed to find a valid workspace")
1✔
585
        }
1✔
586

587
        // Silence Usage as we have now validated command input
588
        cmd.SilenceUsage = true
1✔
589

1✔
590
        // get or select the deployment
1✔
591
        requestedDeployment, err := deployment.GetDeployment(ws, deploymentID, deploymentName, false, nil, platformCoreClient, astroCoreClient)
1✔
592
        if err != nil {
1✔
UNCOV
593
                return err
×
UNCOV
594
        }
×
595

596
        airflowURL, err := getAirflowURL(&requestedDeployment)
1✔
597
        if err != nil {
1✔
UNCOV
598
                return err
×
UNCOV
599
        }
×
600

601
        return deployment.PoolList(airflowURL, airflowAPIClient, out)
1✔
602
}
603

604
func deploymentPoolCreate(cmd *cobra.Command, out io.Writer) error { //nolint
4✔
605
        ws, err := coalesceWorkspace()
4✔
606
        if err != nil {
5✔
607
                return errors.Wrap(err, "failed to find a valid workspace")
1✔
608
        }
1✔
609

610
        // Silence Usage as we have now validated command input
611
        cmd.SilenceUsage = true
3✔
612

3✔
613
        // get or select the deployment
3✔
614
        requestedDeployment, err := deployment.GetDeployment(ws, deploymentID, deploymentName, false, nil, platformCoreClient, astroCoreClient)
3✔
615
        if err != nil {
3✔
UNCOV
616
                return err
×
UNCOV
617
        }
×
618

619
        airflowURL, err := getAirflowURL(&requestedDeployment)
3✔
620
        if err != nil {
3✔
UNCOV
621
                return err
×
UNCOV
622
        }
×
623

624
        // check name
625
        if name == "" {
3✔
UNCOV
626
                return errors.New("a pool name is needed to create a pool. Please use the '--name' flag to specify a name")
×
UNCOV
627
        }
×
628

629
        // check includeDeferred
630
        var includeDeferredValue bool
3✔
631
        switch includeDeferred {
3✔
632
        case enable:
1✔
633
                includeDeferredValue = true
1✔
634
        case disable, "":
2✔
635
                includeDeferredValue = false
2✔
UNCOV
636
        default:
×
UNCOV
637
                return errors.New("Invalid --include-deferred value")
×
638
        }
639

640
        return deployment.PoolCreate(airflowURL, name, description, slots, includeDeferredValue, airflowAPIClient, out)
3✔
641
}
642

643
func deploymentPoolUpdate(cmd *cobra.Command, out io.Writer) error { //nolint
4✔
644
        ws, err := coalesceWorkspace()
4✔
645
        if err != nil {
5✔
646
                return errors.Wrap(err, "failed to find a valid workspace")
1✔
647
        }
1✔
648

649
        // Silence Usage as we have now validated command input
650
        cmd.SilenceUsage = true
3✔
651

3✔
652
        // get or select the deployment
3✔
653
        requestedDeployment, err := deployment.GetDeployment(ws, deploymentID, deploymentName, false, nil, platformCoreClient, astroCoreClient)
3✔
654
        if err != nil {
3✔
UNCOV
655
                return err
×
UNCOV
656
        }
×
657

658
        airflowURL, err := getAirflowURL(&requestedDeployment)
3✔
659
        if err != nil {
3✔
UNCOV
660
                return err
×
UNCOV
661
        }
×
662

663
        // check name
664
        if name == "" {
3✔
UNCOV
665
                return errors.New("a pool name is needed to update a pool. Please use the '--name' flag to specify a name")
×
UNCOV
666
        }
×
667

668
        // check includeDeferred
669
        if airflowversions.AirflowMajorVersionForRuntimeVersion(requestedDeployment.RuntimeVersion) >= "3" && includeDeferred == "" {
3✔
UNCOV
670
                return errors.New("an include deferred value is needed to update a pool. Please use the '--include-deferred' flag to specify a value")
×
UNCOV
671
        }
×
672
        var includeDeferredValue bool
3✔
673
        switch includeDeferred {
3✔
674
        case enable:
1✔
675
                includeDeferredValue = true
1✔
676
        case disable, "":
2✔
677
                includeDeferredValue = false
2✔
UNCOV
678
        default:
×
UNCOV
679
                return errors.New("Invalid --include-deferred value")
×
680
        }
681

682
        return deployment.PoolUpdate(airflowURL, name, description, slots, includeDeferredValue, airflowAPIClient, out)
3✔
683
}
684

685
//nolint:dupl
686
func deploymentPoolCopy(cmd *cobra.Command, out io.Writer) error {
3✔
687
        ws, err := coalesceWorkspace()
3✔
688
        if err != nil {
4✔
689
                return errors.Wrap(err, "failed to find a valid workspace")
1✔
690
        }
1✔
691

692
        // Silence Usage as we have now validated command input
693
        cmd.SilenceUsage = true
2✔
694

2✔
695
        // get source deployment
2✔
696
        if fromDeploymentName == "" && fromDeploymentID == "" {
2✔
UNCOV
697
                fmt.Println("Which deployment should pools be copied from?")
×
UNCOV
698
        }
×
699
        fromDeployment, err := deployment.GetDeployment(ws, fromDeploymentID, fromDeploymentName, false, nil, platformCoreClient, astroCoreClient)
2✔
700
        if err != nil {
2✔
701
                return errors.Wrap(err, "failed to find the source Deployment")
×
702
        }
×
703

704
        fromAirflowURL, err := getAirflowURL(&fromDeployment)
2✔
705
        if err != nil {
2✔
706
                return errors.Wrap(err, "failed to find the source deployments airflow webserver URL")
×
707
        }
×
708

709
        // get target deployment
710
        if toDeploymentName == "" && toDeploymentID == "" {
2✔
711
                fmt.Println("Which deployment should pools be pasted to?")
×
712
        }
×
713
        toDeployment, err := deployment.GetDeployment(ws, toDeploymentID, toDeploymentName, false, nil, platformCoreClient, astroCoreClient)
2✔
714
        if err != nil {
2✔
UNCOV
715
                return errors.Wrap(err, "failed to find the target Deployment")
×
716
        }
×
717

718
        toAirflowURL, err := getAirflowURL(&toDeployment)
2✔
719
        if err != nil {
2✔
UNCOV
720
                return errors.Wrap(err, "failed to find the target deployments airflow webserver URL")
×
UNCOV
721
        }
×
722

723
        return deployment.CopyPool(fromAirflowURL, toAirflowURL, airflowAPIClient, out)
2✔
724
}
725

726
func getAirflowURL(depl *astroplatformcore.Deployment) (string, error) {
29✔
727
        value, err := inspect.ReturnSpecifiedValue(depl, webserverURLField, platformCoreClient)
29✔
728
        if err != nil {
29✔
UNCOV
729
                return "", errors.Wrap(err, "failed to find a deployments airflow webserver URL")
×
UNCOV
730
        }
×
731

732
        airflowURL := fmt.Sprintf("%v", value)
29✔
733
        splitAirflowURL := strings.Split(airflowURL, "?")[0]
29✔
734

29✔
735
        return splitAirflowURL, nil
29✔
736
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc