/
airflow.go
94 lines (76 loc) · 2.27 KB
/
airflow.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package cmd
import (
"github.com/astronomerio/astro-cli/airflow"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var (
deploymentName string
deploymentTag string
airflowRootCmd = &cobra.Command{
Use: "airflow",
Short: "Manage airflow projects and deployments",
Long: "Manage airflow projects and deployments",
}
airflowInitCmd = &cobra.Command{
Use: "init",
Short: "Scaffold a new airflow project",
Long: "Scaffold a new airflow project",
Run: airflowInit,
}
airflowInitCmd = &cobra.Command{
Use: "init",
Short: "Scaffold a new airflow project",
Long: "Scaffold a new airflow project",
Run: airflowInit,
}
airflowCreateCmd = &cobra.Command{
Use: "create",
Short: "Create a new airflow deployment",
Long: "Create a new airflow deployment",
Run: airflowCreate,
}
airflowDeployCmd = &cobra.Command{
Use: "deploy",
Short: "Deploy an airflow project",
Long: "Deploy an airflow project to a given deployment",
Args: cobra.ExactArgs(2),
Run: airflowDeploy,
}
airflowStatusCmd = &cobra.Command{
Use: "status",
Short: "Print the status of an airflow deployment",
Long: "Print the status of an airflow deployment",
Run: airflowStatus,
}
)
func init() {
// Airflow root
RootCmd.AddCommand(airflowRootCmd)
// Airflow init
airflowRootCmd.AddCommand(airflowInitCmd)
// Airflow create
airflowRootCmd.AddCommand(airflowCreateCmd)
// Airflow deploy
airflowDeployCmd.Flags().StringVarP(&deploymentName, "name", "n", "", "Name of airflow deployment")
airflowDeployCmd.Flags().StringVarP(&deploymentTag, "version", "v", "", "Version of airflow deployment")
viper.BindPFlag("name", airflowDeployCmd.Flags().Lookup("name"))
viper.BindPFlag("version", airflowDeployCmd.Flags().Lookup("version"))
airflowRootCmd.AddCommand(airflowDeployCmd)
// Airflow status
airflowRootCmd.AddCommand(airflowStatusCmd)
}
func airflowInit(cmd *cobra.Command, args []string) {
airflow.Init()
}
func airflowCreate(cmd *cobra.Command, args []string) {
airflow.Create()
}
func airflowDeploy(cmd *cobra.Command, args []string) {
deploymentName := args[0]
deploymentTag := args[1]
airflow.Build(deploymentName, deploymentTag)
airflow.Deploy(deploymentName, deploymentTag)
}
func airflowStatus(cmd *cobra.Command, args []string) {
}