Skip to content

Commit

Permalink
Rename pipeline.transformRefFields as pipeline.TransformFields
Browse files Browse the repository at this point in the history
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
  • Loading branch information
ulucinar committed Jun 9, 2022
1 parent 7a587ee commit 00b7d18
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/pipeline/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (eg *ExampleGenerator) Generate(group, version string, r *config.Resource,
if err := json.TFParser.Unmarshal([]byte(rm.Examples[0].Manifest), &exampleParams); err != nil {
return errors.Wrapf(err, "cannot unmarshal example manifest for resource: %s", r.Name)
}
transformRefFields(exampleParams, r.ExternalName.OmittedFields, fieldTransformations, "")
transformFields(exampleParams, r.ExternalName.OmittedFields, fieldTransformations, "")

example := map[string]interface{}{
"apiVersion": fmt.Sprintf("%s/%s", group, version),
Expand Down Expand Up @@ -207,7 +207,7 @@ func getHierarchicalName(prefix, name string) string {
return fmt.Sprintf("%s.%s", prefix, name)
}

func transformRefFields(params map[string]interface{}, omittedFields []string, t map[string]tjtypes.Transformation, namePrefix string) { // nolint:gocyclo
func transformFields(params map[string]interface{}, omittedFields []string, t map[string]tjtypes.Transformation, namePrefix string) { // nolint:gocyclo
for _, hn := range omittedFields {
for n := range params {
if hn == getHierarchicalName(namePrefix, n) {
Expand All @@ -220,15 +220,15 @@ func transformRefFields(params map[string]interface{}, omittedFields []string, t
for n, v := range params {
switch pT := v.(type) {
case map[string]interface{}:
transformRefFields(pT, omittedFields, t, getHierarchicalName(namePrefix, n))
transformFields(pT, omittedFields, t, getHierarchicalName(namePrefix, n))

case []interface{}:
for _, e := range pT {
eM, ok := e.(map[string]interface{})
if !ok {
continue
}
transformRefFields(eM, omittedFields, t, getHierarchicalName(namePrefix, n))
transformFields(eM, omittedFields, t, getHierarchicalName(namePrefix, n))
}
}
}
Expand Down

0 comments on commit 00b7d18

Please sign in to comment.