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

add options to disable unique keys #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MeNsaaH
Copy link

@MeNsaaH MeNsaaH commented Jan 18, 2024

This is a follow up for https://github.com/kubernetes-sigs/kustomize/pull/4096/files

As @natasha41575 pointed out in her comment, the PR was pending when go-yaml is moved to a dedicated kubernetes-sigs repo.

kubernetes-sigs/kustomize#4096 (comment)

Copy link

linux-foundation-easycla bot commented Jan 18, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: MeNsaaH / name: Mmadu Manasseh (987b8fd)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jan 18, 2024
@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Jan 18, 2024
@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: MeNsaaH
Once this PR has been reviewed and has the lgtm label, please assign jpbetz for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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
Copy link

Welcome @MeNsaaH!

It looks like this is your first PR to kubernetes-sigs/yaml 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/yaml has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jan 18, 2024
@MeNsaaH
Copy link
Author

MeNsaaH commented Jan 18, 2024

/assign @jpbetz

@@ -111,6 +110,12 @@ func (dec *Decoder) KnownFields(enable bool) {
dec.knownFields = enable
}

// DisableUniqueKeys ensure function Decode not to return errors when keys exist
// more than once inside the given mapping.
func (dec *Decoder) DisableUniqueKeys(enable bool) {
Copy link

Choose a reason for hiding this comment

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

I'm confused why we need this. Duplicate keys are not valid yaml. Why would we start accepting them now when we didn't previously?

/hold

Copy link
Author

@MeNsaaH MeNsaaH Jan 18, 2024

Choose a reason for hiding this comment

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

@liggitt Duplicate yamls are not valid yamls spec but not when it comes to kubernetes manifests. With kubernetes manifests, duplicates are used to override what was formerly specified (especially with labels and annotations).

The below yaml, even tho having multiple name label is a valid kubernetes manifests. And since this yaml library aims to adapt this for kubernetes, I believe we need to have this implemented as well.

apiVersion: v1
kind: Namespace
metadata:
  labels:
    kubernetes.io/metadata.name: default
    name: default1
    name: default
  name: default

Kustomize uses this library for parsing yaml files. So, it makes sense to add this as part of the features which can be enabled on demand as in the PR I earlier sent above.

Copy link

Choose a reason for hiding this comment

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

My initial feeling was to agree with @liggitt that duplicate keys are not valid yaml so we shouldn't support them (I left the same comment in kubernetes-sigs/kustomize#4096 (comment)). This library is not intended to be adapted specifically for kubernetes. We forked it because the upstream yaml was unmaintained, but IMO it should remain a general-purpose yaml library adhering to the yaml specification. Extending its scope beyond that should be done with care and only for very good reasons, if at all.

That said, I am surprised that the above Namespace yaml is accepted by the apiserver, thank you for pointing that out. @liggitt do you have any context on duplicated keys in upstream k8s? How is k8s able to parse yaml that kustomize cannot, when both repos are depending on the same yaml library?

Copy link
Author

Choose a reason for hiding this comment

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

@natasha41575 thanks for you inputs on this. That has always been my issue. Waiting for the response as well.

@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 18, 2024
@MeNsaaH MeNsaaH requested a review from liggitt January 18, 2024 15:44
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. 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.

None yet

6 participants