Merge pull request #1502 from talentedmrjones/refactor-transform-secret-data-race
moved FillPath outside of Walk
This commit is contained in:
commit
6ce362be5d
@ -48,7 +48,13 @@ func (c *transformSecretTask) Run(ctx context.Context, pctx *plancontext.Context
|
|||||||
return nil, errors.New(errStr)
|
return nil, errors.New(errStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
output := compiler.NewValue()
|
type pathSecret struct {
|
||||||
|
path cue.Path
|
||||||
|
secret *plancontext.Secret
|
||||||
|
}
|
||||||
|
|
||||||
|
var pathsSecrets []pathSecret
|
||||||
|
|
||||||
// users could yaml.Unmarshal(input) and return a map
|
// users could yaml.Unmarshal(input) and return a map
|
||||||
// or yaml.Unmarshal(input).someKey and return a string
|
// or yaml.Unmarshal(input).someKey and return a string
|
||||||
// walk will ensure we convert every leaf
|
// walk will ensure we convert every leaf
|
||||||
@ -60,9 +66,15 @@ func (c *transformSecretTask) Run(ctx context.Context, pctx *plancontext.Context
|
|||||||
newLeafSelectors := v.Path().Selectors()[len(functionPathSelectors):]
|
newLeafSelectors := v.Path().Selectors()[len(functionPathSelectors):]
|
||||||
newLeafSelectors = append(newLeafSelectors, cue.Str("contents"))
|
newLeafSelectors = append(newLeafSelectors, cue.Str("contents"))
|
||||||
newLeafPath := cue.MakePath(newLeafSelectors...)
|
newLeafPath := cue.MakePath(newLeafSelectors...)
|
||||||
output.FillPath(newLeafPath, secret.MarshalCUE())
|
pathsSecrets = append(pathsSecrets, pathSecret{newLeafPath, secret})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
output := compiler.NewValue()
|
||||||
|
|
||||||
|
for _, ps := range pathsSecrets {
|
||||||
|
output.FillPath(ps.path, ps.secret.MarshalCUE())
|
||||||
|
}
|
||||||
|
|
||||||
return output, nil
|
return output, nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user