Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localize helm fields #4978

Merged
merged 4 commits into from Jan 26, 2023

Conversation

annasong20
Copy link
Contributor

@annasong20 annasong20 commented Jan 13, 2023

This PR localizes the valuesFile and chartHome fields of the helm fields helmChartInflationGenerator, helmCharts, and helmGlobals.

  • The directory specified by chartHome is copied to the localize destination, but symlinks inside said directory are not followed.
  • If a helm chart does not specify a chart home, localize attempts to copy the default home named charts.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 13, 2023
@annasong20
Copy link
Contributor Author

/cc @natasha41575
/uncc @koba1t

@k8s-ci-robot k8s-ci-robot requested review from natasha41575 and removed request for koba1t January 13, 2023 00:54
kust.HelmGlobals.ChartHome = locDir
}
}
if useDefaultChartHome(kust) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@natasha41575 As requested, I only localize the default chart home if a chart is present without a home.

return errors.Wrap(err)
}
pathInDst := filepath.Join(dst, pathToCreate)
if info.Mode()&os.ModeSymlink == os.ModeSymlink {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@natasha41575 As requested, I don't follow symlinks.

As discussed before, our other option is to follow all symlinks that don't leave scope and write the file contents to the nominal (uncleaned) file paths in the chart home directory.

api/internal/localizer/localizer.go Outdated Show resolved Hide resolved
return "", nil
}
return lc.localizeFile(entry)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: can we merge this function into localizeFile.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that folding it in is cleaner. If you want to ignore errors for empty entry in some cases but not others, you could add an additional parameter to localizeFile, like localizeFile(path string, errIfEmpty bool).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I added the check for the empty string to localizeFile.

Thanks for the suggestion, @natasha41575. I considered this, but want to keep the method signature of localizeFile as func(string) (string, error) for ease of use localizeBuiltinPlugins' locPathFn func(string) (string, error) in builtinplugins.go file. I also reasoned that localize doesn't have to throw errors on empty entries since kustomize build will take care of this and we don't have to re-implement build functionality.

However, to keep treatment of empty fields consistent, I added the check for empty paths to localizeRoot: https://github.com/kubernetes-sigs/kustomize/pull/4978/files#diff-25faa786bf35469d391d5eef99ed1323623023442b177c1ed3e07f3e6709dac6R385-R387
I also added the following test to demonstrate localize's consistent treatment of empty paths: https://github.com/kubernetes-sigs/kustomize/pull/4978/files#diff-c21f7b3d0afda4a64163411e90e72d2fed6c3df14c7b6f8ed07237bb5e1fc91cR1317

@yuwenma
Copy link
Contributor

yuwenma commented Jan 13, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 13, 2023
api/internal/localizer/localizer.go Outdated Show resolved Hide resolved
api/internal/localizer/localizer.go Outdated Show resolved Hide resolved
return "", nil
}
return lc.localizeFile(entry)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that folding it in is cleaner. If you want to ignore errors for empty entry in some cases but not others, you could add an additional parameter to localizeFile, like localizeFile(path string, errIfEmpty bool).

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 18, 2023
@k8s-ci-robot
Copy link
Contributor

@annasong20: This PR has multiple commits, and the default merge method is: merge.
You can request commits to be squashed using the label: tide/merge-method-squash

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 18, 2023
@annasong20
Copy link
Contributor Author

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jan 18, 2023
api/internal/localizer/localizer.go Outdated Show resolved Hide resolved
api/internal/localizer/localizer.go Outdated Show resolved Hide resolved
api/internal/localizer/localizer.go Outdated Show resolved Hide resolved
Copy link
Contributor

@natasha41575 natasha41575 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve
/hold

I'll try to update #4926 today or early tomorrow, all it should do is add a new additionalValuesFiles field to helmCharts.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 25, 2023
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 25, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: annasong20, natasha41575, yuwenma

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 25, 2023
@annasong20
Copy link
Contributor Author

/unhold
After discussing with @yuwenma @natasha41575, we agree reviews will go faster if we address the new additionalValuesFiles field introduced by #4926 in a separate PR.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 26, 2023
@k8s-ci-robot k8s-ci-robot merged commit fb29492 into kubernetes-sigs:master Jan 26, 2023
@annasong20 annasong20 deleted the localize-helm-fields branch January 26, 2023 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants