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

Name Prefix and Suffix Transformation for multi level level kustomize context #1378

Merged
merged 3 commits into from
Jul 24, 2019

Conversation

jbrette
Copy link
Contributor

@jbrette jbrette commented Jul 21, 2019

This PR builds on the "OuterMost" Prefix and Suffix usage for the name transformation.

Current code was unable to deal properly with a last level of kustomize that was combining two sub levels. In such as case the outermost prefix and suffix where often empty.

This PR is using the stack of prefixes and suffixes accumulated during the name prefix/suffix transformation to handle properly the namereference transformation.

The ResCtx (Resource Context) interface has been introduced. It is currently relying on name prefix and suffix but long term it should be possible to extend it to use a filename or a commit id equivalent to identify a kustomize content (a.k.a a folder with a kustomization.yaml).

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 21, 2019
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 21, 2019
@jbrette
Copy link
Contributor Author

jbrette commented Jul 22, 2019

/assign @Liujingfang1

@jbrette
Copy link
Contributor Author

jbrette commented Jul 22, 2019

@Liujingfang1 @monopole

It seems this PR fixes:

@jbrette
Copy link
Contributor Author

jbrette commented Jul 23, 2019

@Liujingfang1 Gentle bump of the PR. Rebase was successful

@Liujingfang1
Copy link
Contributor

@jbrette Thank you. Will review it today.

pkg/resmap/resmap.go Outdated Show resolved Hide resolved
pkg/resmap/resmap.go Outdated Show resolved Hide resolved
@jbrette
Copy link
Contributor Author

jbrette commented Jul 24, 2019

@Liujingfang1 This is done. I did the changes and repushed. Thanks for the review. Was able to simplify even further. Can you have a look at it again.

- Update PrefixSuffixTransfomer to add empty prefix and suffix
// Need to match more accuratly both at the time of selection and transformation.
// OutmostPrefixSuffixEquals is not accurate enough since it is only using
// the outer most suffix and the last prefix. Use PrefixedSuffixesEquals instead.
if (!inputId.IsNamespaceableKind() && r.InSameKustomizeCtx(rctxm)) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

(!inputId.IsNamespaceableKind() || !r.OrgId().IsNamespaceableKind || r.CurId.IsNsEquals(input)) && r.InSameKustomizeCtx(rctxm)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Liujingfang1 Sorry. Should have seen that. This is done now. Ready for merge I hope.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, thank you.

- Leverage nameprefix and namesuffix contextual data
@Liujingfang1
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 24, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jbrette, Liujingfang1

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 Jul 24, 2019
@k8s-ci-robot k8s-ci-robot merged commit ffd95ef into kubernetes-sigs:master Jul 24, 2019
@jbrette jbrette deleted the nameprefix branch July 24, 2019 18:59
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants