Skip to content

Commit a136012

Browse files
committed
add support for yaml resource selectors on deployments
1 parent d95c9a7 commit a136012

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

cmd/ctrlc/root/apply/deployment.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ func processDeployment(
3939

4040
func createDeploymentRequestBody(systemID uuid.UUID, deployment Deployment) api.CreateDeploymentJSONBody {
4141
return api.CreateDeploymentJSONBody{
42-
SystemId: systemID,
43-
Slug: deployment.Slug,
44-
Name: deployment.Name,
45-
Description: deployment.Description,
42+
SystemId: systemID,
43+
Slug: deployment.Slug,
44+
Name: deployment.Name,
45+
Description: deployment.Description,
46+
ResourceSelector: deployment.ResourceSelector,
4647
}
4748
}
4849

@@ -82,14 +83,13 @@ func processEnvironment(
8283
defer environmentWg.Done()
8384

8485
body := api.CreateEnvironmentJSONRequestBody{
85-
SystemId: systemID.String(),
86-
Name: environment.Name,
87-
Description: &environment.Description,
86+
SystemId: systemID.String(),
87+
Name: environment.Name,
88+
Description: environment.Description,
89+
ResourceSelector: environment.ResourceSelector,
90+
Metadata: environment.Metadata,
8891
}
8992

90-
if environment.ResourceSelector != nil {
91-
body.ResourceSelector = environment.ResourceSelector
92-
}
9393
_, err := client.CreateEnvironmentWithResponse(ctx, body)
9494
if err != nil {
9595
log.Error("Failed to create environment", "name", environment.Name, "error", err)

cmd/ctrlc/root/apply/types.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@ type System struct {
1616
}
1717

1818
type Environment struct {
19-
Name string `yaml:"name"`
20-
Description string `yaml:"description"`
21-
ResourceSelector *map[string]any `yaml:"resourceSelector,omitempty"`
19+
Name string `yaml:"name"`
20+
Description *string `yaml:"description,omitempty"`
21+
ResourceSelector *map[string]any `yaml:"resourceSelector,omitempty"`
22+
Metadata *map[string]string `yaml:"metadata,omitempty"`
2223
}
2324

2425
type Deployment struct {
25-
Slug string `yaml:"slug"`
26-
Name string `yaml:"name"`
27-
Description *string `yaml:"description"`
28-
JobAgent *JobAgent `yaml:"jobAgent,omitempty"`
26+
Slug string `yaml:"slug"`
27+
Name string `yaml:"name"`
28+
Description *string `yaml:"description"`
29+
JobAgent *JobAgent `yaml:"jobAgent,omitempty"`
30+
ResourceSelector *map[string]any `yaml:"resourceSelector,omitempty"`
31+
Metadata *map[string]string `yaml:"metadata,omitempty"`
2932
}
3033

3134
type JobAgent struct {

0 commit comments

Comments
 (0)