Skip to content

Commit a9d4ee7

Browse files
Merge pull request #21 from ctrlplanedev/resource-upsert-one
chore: update cli with new upsert resource
2 parents c9daebd + b17f9ec commit a9d4ee7

3 files changed

Lines changed: 656 additions & 115 deletions

File tree

cmd/ctrlc/root/api/upsert/policy/policy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func NewUpsertPolicyCmd() *cobra.Command {
9999
}
100100

101101
// Create policy request
102-
body := api.CreatePolicyJSONRequestBody{
102+
body := api.UpsertPolicyJSONRequestBody{
103103
Name: name,
104104
WorkspaceId: workspaceId,
105105
Description: &description,
@@ -115,7 +115,7 @@ func NewUpsertPolicyCmd() *cobra.Command {
115115
DeploymentVersionSelector: parsedDeploymentVersionSelector,
116116
}
117117

118-
resp, err := client.CreatePolicy(cmd.Context(), body)
118+
resp, err := client.UpsertPolicy(cmd.Context(), body)
119119
if err != nil {
120120
return fmt.Errorf("failed to create policy: %w", err)
121121
}

cmd/ctrlc/root/api/upsert/resource/resource.go

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,27 +70,14 @@ func NewUpsertResourceCmd() *cobra.Command {
7070
}
7171

7272
// Extrat into vars
73-
resp, err := client.UpsertResources(cmd.Context(), api.UpsertResourcesJSONRequestBody{
74-
Resources: []struct {
75-
Config map[string]interface{} `json:"config"`
76-
Identifier string `json:"identifier"`
77-
Kind string `json:"kind"`
78-
Metadata *map[string]string `json:"metadata,omitempty"`
79-
Name string `json:"name"`
80-
Variables *[]api.Variable `json:"variables,omitempty"`
81-
Version string `json:"version"`
82-
}{
83-
{
84-
Version: version,
85-
Identifier: identifier,
86-
Metadata: &metadata,
87-
Name: name,
88-
Kind: kind,
89-
Config: config,
90-
Variables: variablesRequest,
91-
},
92-
},
93-
73+
resp, err := client.UpsertResource(cmd.Context(), api.UpsertResourceJSONRequestBody{
74+
Config: config,
75+
Identifier: identifier,
76+
Kind: kind,
77+
Metadata: &metadata,
78+
Name: name,
79+
Variables: variablesRequest,
80+
Version: version,
9481
WorkspaceId: uuid.Must(uuid.Parse(workspaceId)),
9582
})
9683

0 commit comments

Comments
 (0)