-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 resources #4912
Localize resources #4912
Conversation
/cc @yuwenma |
@@ -753,3 +753,58 @@ nameSuffix: -test | |||
addFiles(t, fSysExpected, "/localized", kustAndComponents) | |||
checkFSys(t, fSysExpected, fSys) | |||
} | |||
|
|||
func TestLocalizeResources(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a tests here with a remote resource file, and a remote resource directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that the localizeFile
and localizeDir
functions are supposed to be converting the remote URLs to local filepaths, so IMO these tests should cover that behavior. Can we get #4909 in and then add the tests here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that the
localizeFile
andlocalizeDir
functions are supposed to be converting the remote URLs to local filepaths, so IMO these tests should cover that behavior. Can we get #4909 in and then add the tests here?
Sure, sg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM on my side. Can you resolve @natasha41575 comment about the unittest before merging?
/uncc @koba1t |
d62f9cf
to
59470ac
Compare
@annasong20: This PR has multiple commits, and the default merge method is: merge. 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. |
/label tide/merge-method-squash |
/lgtm |
59470ac
to
b574f8a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests LGTM. I just have a small comment about organization.
) | ||
|
||
func prepareFs(t *testing.T, files map[string]string) (memoryFs filesys.FileSystem, actualFs filesys.FileSystem, testDir filesys.ConfirmedDir) { | ||
func prepareFs(t *testing.T, dirs []string, files map[string]string) ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have a lot of helper functions now, can we move these helpers to their own file api/krusty/localizer/testutils.go
? I think it will help keep this directory organized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved all the helper functions to the top of the file for now. I'm all for improving organization. The problem with moving the helper functions to testutils.go
is this file can't exist in package localizer_test
because the file name doesn't end in _test.go
. We don't want the test helper functions to be publicly exposed in the localizer
package either.
If moving the helper functions to the top of the file is not clean enough, I came up with a few other options:
- Create a
loctest
package underapi/testutils
and move the helper functions to a file there calledhelper.go
. - Create a
testutils
package underapi/krusty/localizer/internal
and move the helper functions to a file there calledhelper.go
. - Move the helper functions to a new
utils_test.go
file underapi/krusty/localizer
.
b574f8a
to
1f14895
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[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 |
* Localize resources * Improve readability * Add integration tests * Group test helper functions
* initial changes to rename OrgRepo to RepoPath * changes to rename Path to KustRootPath * addressed review comments * addressed review comments * docs: Add documentation for namespace transformer Add a short description of the namespace transformer and example usage to examples/transformerconfigs/README.md. References: #629 Signed-off-by: Lars Kellogg-Stedman <lars@oddbit.com> * Localize patchesJson6902, patchesStrategicMerge, replacements (#4904) * Localize patchesJson6902, patchesStrategicMerge, replacements * Address code review feedback * Improve readability * Remove deprecation warning check * Load legacy kustomization fields for `localize` (#4918) * Load legacy kustomization * Expose loadKustFile in kusttarget * remove FixKustomizationPreUnmarshalling * remove deprecated cfg and fn commands (#4930) * remove deprecated cfg and fn commands * fix lint error * run gofmt * Localize PatchTransformer, PatchJson6902Transformer (#4920) * Localize patches, patchesJson6902 custom transformers * Improve readability * Localize fields: openapi, configurations, crds (#4907) * Localize openapi, configurations, crds * Add integration test * Move krusty test * Address code review feedback * Implement locRootPath (#4909) * Implement locRootPath, and include userinfo, port in locFilePath * Strip userinfo, port * Improve readability * Localize legacy fields * Localize resources (#4912) * Localize resources * Improve readability * Add integration tests * Group test helper functions * Remove Functionality that Pulls Env Variables from Empty Keys * Update api/kv/kv.go Co-authored-by: Katrina Verey <kn.verey@gmail.com> * refactor Unmarshal Kustomization struct code * improve error messages * Run go mod tidy on all modules before update * Update sigs.k8s.io/yaml to 1.3.0 * fixed test failure because of latest commits Signed-off-by: Lars Kellogg-Stedman <lars@oddbit.com> Co-authored-by: Lars Kellogg-Stedman <lars@oddbit.com> Co-authored-by: Anna Song <annasong@google.com> Co-authored-by: yugo kobayashi <kobdotsh@gmail.com> Co-authored-by: Natasha Sarkar <natashasarkar@google.com> Co-authored-by: Cailyn Edwards <cailyn.edwards@shopify.com> Co-authored-by: Cailyn <cailyn.s.e@gmail.com> Co-authored-by: Katrina Verey <kn.verey@gmail.com> Co-authored-by: Katrina Verey <katrina.verey@shopify.com>
* Localize resources * Improve readability * Add integration tests * Group test helper functions
* initial changes to rename OrgRepo to RepoPath * changes to rename Path to KustRootPath * addressed review comments * addressed review comments * docs: Add documentation for namespace transformer Add a short description of the namespace transformer and example usage to examples/transformerconfigs/README.md. References: kubernetes-sigs#629 Signed-off-by: Lars Kellogg-Stedman <lars@oddbit.com> * Localize patchesJson6902, patchesStrategicMerge, replacements (kubernetes-sigs#4904) * Localize patchesJson6902, patchesStrategicMerge, replacements * Address code review feedback * Improve readability * Remove deprecation warning check * Load legacy kustomization fields for `localize` (kubernetes-sigs#4918) * Load legacy kustomization * Expose loadKustFile in kusttarget * remove FixKustomizationPreUnmarshalling * remove deprecated cfg and fn commands (kubernetes-sigs#4930) * remove deprecated cfg and fn commands * fix lint error * run gofmt * Localize PatchTransformer, PatchJson6902Transformer (kubernetes-sigs#4920) * Localize patches, patchesJson6902 custom transformers * Improve readability * Localize fields: openapi, configurations, crds (kubernetes-sigs#4907) * Localize openapi, configurations, crds * Add integration test * Move krusty test * Address code review feedback * Implement locRootPath (kubernetes-sigs#4909) * Implement locRootPath, and include userinfo, port in locFilePath * Strip userinfo, port * Improve readability * Localize legacy fields * Localize resources (kubernetes-sigs#4912) * Localize resources * Improve readability * Add integration tests * Group test helper functions * Remove Functionality that Pulls Env Variables from Empty Keys * Update api/kv/kv.go Co-authored-by: Katrina Verey <kn.verey@gmail.com> * refactor Unmarshal Kustomization struct code * improve error messages * Run go mod tidy on all modules before update * Update sigs.k8s.io/yaml to 1.3.0 * fixed test failure because of latest commits Signed-off-by: Lars Kellogg-Stedman <lars@oddbit.com> Co-authored-by: Lars Kellogg-Stedman <lars@oddbit.com> Co-authored-by: Anna Song <annasong@google.com> Co-authored-by: yugo kobayashi <kobdotsh@gmail.com> Co-authored-by: Natasha Sarkar <natashasarkar@google.com> Co-authored-by: Cailyn Edwards <cailyn.edwards@shopify.com> Co-authored-by: Cailyn <cailyn.s.e@gmail.com> Co-authored-by: Katrina Verey <kn.verey@gmail.com> Co-authored-by: Katrina Verey <katrina.verey@shopify.com>
* initial changes to rename OrgRepo to RepoPath * changes to rename Path to KustRootPath * addressed review comments * addressed review comments * docs: Add documentation for namespace transformer Add a short description of the namespace transformer and example usage to examples/transformerconfigs/README.md. References: kubernetes-sigs#629 Signed-off-by: Lars Kellogg-Stedman <lars@oddbit.com> * Localize patchesJson6902, patchesStrategicMerge, replacements (kubernetes-sigs#4904) * Localize patchesJson6902, patchesStrategicMerge, replacements * Address code review feedback * Improve readability * Remove deprecation warning check * Load legacy kustomization fields for `localize` (kubernetes-sigs#4918) * Load legacy kustomization * Expose loadKustFile in kusttarget * remove FixKustomizationPreUnmarshalling * remove deprecated cfg and fn commands (kubernetes-sigs#4930) * remove deprecated cfg and fn commands * fix lint error * run gofmt * Localize PatchTransformer, PatchJson6902Transformer (kubernetes-sigs#4920) * Localize patches, patchesJson6902 custom transformers * Improve readability * Localize fields: openapi, configurations, crds (kubernetes-sigs#4907) * Localize openapi, configurations, crds * Add integration test * Move krusty test * Address code review feedback * Implement locRootPath (kubernetes-sigs#4909) * Implement locRootPath, and include userinfo, port in locFilePath * Strip userinfo, port * Improve readability * Localize legacy fields * Localize resources (kubernetes-sigs#4912) * Localize resources * Improve readability * Add integration tests * Group test helper functions * Remove Functionality that Pulls Env Variables from Empty Keys * Update api/kv/kv.go Co-authored-by: Katrina Verey <kn.verey@gmail.com> * refactor Unmarshal Kustomization struct code * improve error messages * Run go mod tidy on all modules before update * Update sigs.k8s.io/yaml to 1.3.0 * fixed test failure because of latest commits Signed-off-by: Lars Kellogg-Stedman <lars@oddbit.com> Co-authored-by: Lars Kellogg-Stedman <lars@oddbit.com> Co-authored-by: Anna Song <annasong@google.com> Co-authored-by: yugo kobayashi <kobdotsh@gmail.com> Co-authored-by: Natasha Sarkar <natashasarkar@google.com> Co-authored-by: Cailyn Edwards <cailyn.edwards@shopify.com> Co-authored-by: Cailyn <cailyn.s.e@gmail.com> Co-authored-by: Katrina Verey <kn.verey@gmail.com> Co-authored-by: Katrina Verey <katrina.verey@shopify.com>
This PR localizes entries under the
resources
kustomization field.