Skip to content

Commit

Permalink
moved FillPath outside of Walk
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Jones <richard@dagger.io>
  • Loading branch information
Richard Jones committed Jan 25, 2022
1 parent 8781f7e commit 3292771
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions plan/task/transformsecret.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ func (c *transformSecretTask) Run(ctx context.Context, pctx *plancontext.Context
return nil, errors.New(errStr)
}

output := compiler.NewValue()
type pathSecret struct {
path cue.Path
value *compiler.Value
}

var pathsSecrets []pathSecret

// users could yaml.Unmarshal(input) and return a map
// or yaml.Unmarshal(input).someKey and return a string
// walk will ensure we convert every leaf
Expand All @@ -60,9 +66,15 @@ func (c *transformSecretTask) Run(ctx context.Context, pctx *plancontext.Context
newLeafSelectors := v.Path().Selectors()[len(functionPathSelectors):]
newLeafSelectors = append(newLeafSelectors, cue.Str("contents"))
newLeafPath := cue.MakePath(newLeafSelectors...)
output.FillPath(newLeafPath, secret.MarshalCUE())
pathsSecrets = append(pathsSecrets, pathSecret{newLeafPath, secret.MarshalCUE()})
}
})

output := compiler.NewValue()

for _, ps := range pathsSecrets {
output.FillPath(ps.path, ps.value)
}

return output, nil
}

0 comments on commit 3292771

Please sign in to comment.