|
1 | 1 | package apply |
2 | 2 |
|
3 | | -import ( |
4 | | - "context" |
5 | | - "fmt" |
6 | | - |
7 | | - "github.com/spf13/cobra" |
8 | | -) |
9 | | - |
10 | | -// NewApplyCmd creates a new apply command |
11 | | -func NewApplyCmd() *cobra.Command { |
12 | | - var filePath string |
13 | | - |
14 | | - cmd := &cobra.Command{ |
15 | | - Use: "apply", |
16 | | - Short: "Apply a YAML configuration file to create systems and deployments", |
17 | | - Long: `Apply a YAML configuration file to create systems and deployments in Ctrlplane`, |
18 | | - RunE: func(cmd *cobra.Command, args []string) error { |
19 | | - return runApply(filePath) |
20 | | - }, |
21 | | - } |
22 | | - |
23 | | - cmd.Flags().StringVarP(&filePath, "file", "f", "", "Path to the YAML configuration file (required)") |
24 | | - cmd.MarkFlagRequired("file") |
25 | | - |
26 | | - return cmd |
27 | | -} |
28 | | - |
29 | | -func runApply(filePath string) error { |
30 | | - ctx := context.Background() |
31 | | - |
32 | | - // Read and parse the YAML file |
33 | | - config, err := readConfigFile(filePath) |
34 | | - if err != nil { |
35 | | - return fmt.Errorf("failed to read config file: %w", err) |
36 | | - } |
37 | | - |
38 | | - // Create API client |
39 | | - client, workspaceID, err := createAPIClient() |
40 | | - if err != nil { |
41 | | - return err |
42 | | - } |
43 | | - |
44 | | - // Process systems and collect errors |
45 | | - processAllSystems(ctx, client, workspaceID, config.Systems) |
46 | | - processResourceProvider(ctx, client, workspaceID.String(), config.Providers) |
47 | | - processResourceRelationships(ctx, client, workspaceID.String(), config.Relationships) |
48 | | - processAllPolicies(ctx, client, workspaceID.String(), config.Policies) |
49 | | - |
50 | | - return nil |
51 | | -} |
| 3 | +// import ( |
| 4 | +// "context" |
| 5 | +// "fmt" |
| 6 | + |
| 7 | +// "github.com/spf13/cobra" |
| 8 | +// ) |
| 9 | + |
| 10 | +// // NewApplyCmd creates a new apply command |
| 11 | +// func NewApplyCmd() *cobra.Command { |
| 12 | +// var filePath string |
| 13 | + |
| 14 | +// cmd := &cobra.Command{ |
| 15 | +// Use: "apply", |
| 16 | +// Short: "Apply a YAML configuration file to create systems and deployments", |
| 17 | +// Long: `Apply a YAML configuration file to create systems and deployments in Ctrlplane`, |
| 18 | +// RunE: func(cmd *cobra.Command, args []string) error { |
| 19 | +// return runApply(filePath) |
| 20 | +// }, |
| 21 | +// } |
| 22 | + |
| 23 | +// cmd.Flags().StringVarP(&filePath, "file", "f", "", "Path to the YAML configuration file (required)") |
| 24 | +// cmd.MarkFlagRequired("file") |
| 25 | + |
| 26 | +// return cmd |
| 27 | +// } |
| 28 | + |
| 29 | +// func runApply(filePath string) error { |
| 30 | +// ctx := context.Background() |
| 31 | + |
| 32 | +// // Read and parse the YAML file |
| 33 | +// config, err := readConfigFile(filePath) |
| 34 | +// if err != nil { |
| 35 | +// return fmt.Errorf("failed to read config file: %w", err) |
| 36 | +// } |
| 37 | + |
| 38 | +// // Create API client |
| 39 | +// client, workspaceID, err := createAPIClient() |
| 40 | +// if err != nil { |
| 41 | +// return err |
| 42 | +// } |
| 43 | + |
| 44 | +// // Process systems and collect errors |
| 45 | +// processAllSystems(ctx, client, workspaceID, config.Systems) |
| 46 | +// processResourceProvider(ctx, client, workspaceID.String(), config.Providers) |
| 47 | +// processResourceRelationships(ctx, client, workspaceID.String(), config.Relationships) |
| 48 | +// processAllPolicies(ctx, client, workspaceID.String(), config.Policies) |
| 49 | + |
| 50 | +// return nil |
| 51 | +// } |
0 commit comments