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

replacements documentation #158

Merged
merged 1 commit into from
Jun 3, 2021

Conversation

natasha41575
Copy link
Contributor

No description provided.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 14, 2021
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label May 14, 2021
@natasha41575
Copy link
Contributor Author

/cc @monopole
/cc @KnVerey

@natasha41575 natasha41575 changed the title WIP replacements documentation replacements documentation May 19, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 19, 2021
@natasha41575
Copy link
Contributor Author

/hold

@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 May 19, 2021
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 19, 2021
@max-sixty
Copy link

As someone who saw the release notes and would be interested to use this — would it be possible to explain the delimiter more?

If we have something like:

  apiVersion: v1
  kind: ServiceAccount
  metadata:
    name: sa-foo
    annotations:
      iam.gke.io/gcp-service-account: sa@$PROJECT.iam.gserviceaccount.com

is it possible to replace that $PROJECT? Would it be written as !PROJECT!, and the delimiter be !, and the index 1?

@natasha41575
Copy link
Contributor Author

natasha41575 commented May 20, 2021

@max-sixty No unfortunately; the replacement transformer would not be able to replace vars in this case. Mentioning @justinsb because he had a similar question.

if you have something like
path: my/path/VALUE

Then the replacement transformer would have something like:

options:
  delimiter: '/'
  index: 2

and it would replace VALUE, e.g. path: my/path/NEW_VALUE - it leaves the delimiters in place.

I'll add some examples to clarify. Unfortunately, we don't have a way to replace arbitrary substrings in the middle of a string yet.

@monopole Any thoughts?

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 20, 2021
@natasha41575
Copy link
Contributor Author

@max-sixty We are considering an approach like kubernetes-sigs/kustomize#3914 for cases such as yours. If you would like to take a look and provide feedback there, that would be appreciated.

@monopole
Copy link
Contributor

@max-sixty Suggest for now using replacement, but replace the whole field, i.e. the entire string
sa@$PROJECT.iam.gserviceaccount.com

a "normalization" problem arises if $PROJECT appears in other strings, because then one has to have multiple weird strings which violates don't repeat yourself.

I think the right way to go this is with generators, so we're working on that now.

@monopole
Copy link
Contributor

/retest

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 24, 2021
@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 May 24, 2021
@max-sixty
Copy link

@max-sixty Suggest for now using replacement, but replace the whole field, i.e. the entire string
sa@$PROJECT.iam.gserviceaccount.com

I think the right way to go this is with generators, so we're working on that now.

Great, thanks! And overall this is in a tolerable place for now — even before replacements.

The sa@$PROJECT.iam.gserviceaccount.com works for that service account, though not when $PROJECT is in other strings; e.g. GoogleCloudPlatform/k8s-config-connector#271

a "normalization" problem arises if $PROJECT appears in other strings, because then one has to have multiple weird strings which violates don't repeat yourself.

FWIW I didn't understand this — isn't the current solution violating DRY, because we need to have a patch / replacement for each string containing $PROJECT?

@monopole
Copy link
Contributor

@max-sixty So ideally one would have a means of replacing just one thing

PROJECT => whatever

instead of two things (where one repeats part of the replacement)

serviceAccount:PROJECT.svc.id.goog[default/workflow-service-account] => serviceAccount:whatever.svc.id.goog[default/workflow-service-account]
sa@PROJECT.iam.gserviceaccount.com => sa@whatever.iam.gserviceaccount.com

We think this can be solved with a generator parameterized by PROJECT (and maybe some per cloud stuff)

@max-sixty
Copy link

Yes exactly @monopole !

That may be easier said than done — e.g. if something replaces PROJECT for whatever in a lower kustomization, does a higher kustomization see PROJECT or whatever. Potentially this was both a feature and a problem with vars.

Thanks!

@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 Jun 1, 2021
@natasha41575
Copy link
Contributor Author

/hold cancel

@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 Jun 1, 2021
Copy link
Contributor

@monopole monopole left a comment

Choose a reason for hiding this comment

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

/lgtm

thanks!

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: monopole, natasha41575

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:
  • OWNERS [monopole,natasha41575]

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 merged commit f9d1d72 into kubernetes-sigs:master Jun 3, 2021
wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this pull request Dec 6, 2022
Changes:
4.5.7
-----
Due to an oversight, kustomize v4.5.6 has the golang testing library
compiled in unnecessarily. This is a rerelease with the same
functionality, but without the unnecessary additional library compiled
in.

4.5.6
-----
Due to an oversight, kustomize v4.5.6 has the golang testing library
compiled in unnecessarily. It is advised that you upgrade to v4.5.7,
which doesn't have the testing library compiled in.

4.5.5
-----
This release is expected to have significant performance improvements
for a good portion of inputs, due to #4568.

4.5.4
-----
Dependencies updates.

4.5.3
-----
Misc enhancements and bug fixes.

4.5.2
-----
Bug fix release.

4.5.1
-----
Known issues:
 - kubernetes-sigs/kustomize#4455
   A regression, some HTTP urls are not working properly.

4.5.0
-----
 - This release contains a regression in the legacy sort order. Those
   using the legacy sort, i.e. `kustomize build` with `--reorder` unset
   or explicitly set to `legacy`, are advised to skip this release.
   kubernetes-sigs/kustomize#4388
 - kubernetes-sigs/kustomize#4455
   Another regression, some HTTP urls are not working properly.

 - New field in kustomization, `buildMetadata`.
 - New command `kustomize edit add buildmetadata`
 - Refactor the PrefixSuffixTransformer into separate prefix- and
   suffix transformers, enabling the user to use the PrefixTransformer or
   SuffixTransformer individually in the transformers field.
 - `kustomize build ...` now completes file paths on ZSH.
 - New command `kustomize edit add generator` (kubernetes-sigs/kustomize#4361)

 - Deprecate enable-managedby-label flag in favor of a field

4.4.1
------
Bug fix release.

4.4.0
-----
The headline feature of this release is improved support for YAML
anchors and aliases, which will be expanded by default as of this
version.

Additional features and fixes include:
- Added length check on originalFields of kustomizationFile to prevent
  panic when kustomization file began with a comment(or a blank line)
  followed by a document separator

4.3.0
-----
Misc bug fixes and enhancements.

4.2.0
-----
New experimental command to automatically migrate `vars` to
`replacements`: `kustomize edit fix —vars`. For details, run `kustomize
edit fix -h`. Warning: converting `vars` to `replacements` will
potentially overwrite many resource files and in rare scenarios may not
produce the same output when `kustomize build` is run. We recommend
doing this in a clean git repository where the change is easy to undo.

4.1.3
-----
* New experimental ReplacementTransformer, docs on the way:
  kubernetes-sigs/cli-experimental#158
  This will replace the `vars` feature.
* Allow pulls of openapi data from live API servers (openapi fetch command).
* Remote git urls can specify a timeout parameter.
* More examples of helm usage.
* Speed up cluster-scoped type checks.
* API changes towards 1.0
  - `Gvk` and `Resid` types moved to kyaml
  - `Resource` now inlines `RNode` rather than delegating to it
  - `Resmap` now accepts an `kio.Filter` visitor (that can change the ResMap size).
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants