Skip to content

Commit be6bf58

Browse files
committed
fix duplicates. tmp fix
1 parent 8c80f10 commit be6bf58

File tree

11 files changed

+799
-794
lines changed

11 files changed

+799
-794
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ test.bash
44
/bin
55
.idea
66
.vscode
7-
*.test.yaml
7+
*.test.yaml
8+
9+
switch.sh

cmd/ctrlc/root/api/get/get.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package get
22

33
import (
4-
"github.com/ctrlplanedev/cli/cmd/ctrlc/root/api/upsert/deploymentversion"
4+
"github.com/ctrlplanedev/cli/cmd/ctrlc/root/api/get/resources"
55
"github.com/spf13/cobra"
66
)
77

@@ -15,7 +15,7 @@ func NewGetCmd() *cobra.Command {
1515
},
1616
}
1717

18-
cmd.AddCommand(deploymentversion.NewUpsertDeploymentVersionCmd())
18+
cmd.AddCommand(resources.NewResourcesCmd())
1919

2020
return cmd
2121
}

cmd/ctrlc/root/api/get/resources/resources.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package resources
22

33
import (
44
"fmt"
5+
"net/url"
56

67
"github.com/ctrlplanedev/cli/internal/api"
78
"github.com/ctrlplanedev/cli/internal/cliutil"
@@ -13,7 +14,6 @@ func NewResourcesCmd() *cobra.Command {
1314
var query string
1415
var limit int
1516
var offset int
16-
var workspace string
1717

1818
cmd := &cobra.Command{
1919
Use: "resources",
@@ -22,6 +22,8 @@ func NewResourcesCmd() *cobra.Command {
2222
RunE: func(cmd *cobra.Command, args []string) error {
2323
apiURL := viper.GetString("url")
2424
apiKey := viper.GetString("api-key")
25+
workspace := viper.GetString("workspace")
26+
2527
client, err := api.NewAPIKeyClientWithResponses(apiURL, apiKey)
2628
if err != nil {
2729
return fmt.Errorf("failed to create API client: %w", err)
@@ -37,8 +39,10 @@ func NewResourcesCmd() *cobra.Command {
3739
params.Offset = &offset
3840
}
3941
if query != "" {
40-
params.Cel = &query
42+
q := url.QueryEscape(query)
43+
params.Cel = &q
4144
}
45+
4246
resp, err := client.GetAllResources(cmd.Context(), workspaceID.String(), params)
4347
if err != nil {
4448
return fmt.Errorf("failed to get resources: %w", err)
@@ -51,7 +55,6 @@ func NewResourcesCmd() *cobra.Command {
5155
cmd.Flags().StringVarP(&query, "query", "q", "", "CEL filter")
5256
cmd.Flags().IntVarP(&limit, "limit", "l", 50, "Limit the number of results")
5357
cmd.Flags().IntVarP(&offset, "offset", "o", 0, "Offset the results")
54-
cmd.Flags().StringVarP(&workspace, "workspace", "w", "", "Workspace to get resources from")
5558

5659
cmd.MarkFlagRequired("workspace")
5760

cmd/ctrlc/root/apply/cmd.go

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
package apply
22

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

Comments
 (0)