Skip to content

Commit

Permalink
fix: add resolves resource params to the output spec
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Meier <[email protected]>
  • Loading branch information
astromechza committed Oct 28, 2024
1 parent 9240d0c commit 47365be
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/command/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ service:
ports:
web:
port: 8080
resources:
thing:
params:
x: example
type: something
`, string(raw))

// check that state was persisted
Expand Down Expand Up @@ -138,6 +143,11 @@ containers:
- target: /somefile
content: |
${metadata.name}
resources:
thing:
type: something
params:
x: ${metadata.name}
`), 0755))

_, _, err = executeAndResetCommand(context.Background(), rootCmd, []string{
Expand All @@ -161,5 +171,10 @@ containers:
key: value
metadata:
name: example
resources:
thing:
params:
x: example
type: something
`, string(raw))
}
11 changes: 11 additions & 0 deletions internal/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ func Workload(currentState *state.State, workloadName string) (map[string]interf
containers[containerName] = container
}
spec.Containers = containers
resources := maps.Clone(spec.Resources)
for resName, res := range resources {
resUid := framework.NewResourceUid(workloadName, resName, res.Type, res.Class, res.Id)
resState, ok := currentState.Resources[resUid]
if !ok {
return nil, fmt.Errorf("workload '%s': resource '%s' (%s) is not primed", workloadName, resName, resUid)
}
res.Params = resState.Params
resources[resName] = res
}
spec.Resources = resources

// ===============================================================================
// TODO: HERE IS WHERE YOU MAY CONVERT THE WORKLOAD INTO YOUR TARGET MANIFEST TYPE
Expand Down

0 comments on commit 47365be

Please sign in to comment.