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 check that kustomization is empty #4949

Conversation

koba1t
Copy link
Member

@koba1t koba1t commented Dec 28, 2022

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 28, 2022
@koba1t
Copy link
Member Author

koba1t commented Dec 28, 2022

cc @KnVerey

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 28, 2022
@koba1t koba1t force-pushed the fix/add_check_kustomization_is_empty branch 2 times, most recently from 7a2d5db to 1ae8490 Compare December 28, 2022 13:04
@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 Mar 28, 2023
@koba1t
Copy link
Member Author

koba1t commented Mar 28, 2023

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 28, 2023
@natasha41575
Copy link
Contributor

/triage accepted
/priority important-soon

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Mar 28, 2023
@@ -301,6 +301,27 @@ func (k *Kustomization) FixKustomizationPreMarshalling(fSys filesys.FileSystem)
return nil
}

func (k *Kustomization) CheckEmpty() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I right to think that we want to throw an error on any file that does not contain any transformers? The code below effectively excludes files that specifically contain only Kustomization type metadata, but I suspect it would actually allow fully empty files or files with partial type meta (which is currently allowed, for better or for worse). I suggest changing the tests to be against raw yaml input rather than struct input to demonstrate the various cases more thoroughly. I also suggest trying the opposite approach for the comparison: deep copy the input Kustomization, clear its type meta, and then compare it to a completely empty object (in object form, not as yaml). LMK what you think of that approach.

Copy link
Member Author

@koba1t koba1t Apr 5, 2023

Choose a reason for hiding this comment

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

Thanks for your advice!
I agree with your opinions.

I fixed these codes.

@k8s-ci-robot
Copy link
Contributor

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 added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 5, 2023
@koba1t koba1t force-pushed the fix/add_check_kustomization_is_empty branch from 0126d4b to a7ec04e Compare April 5, 2023 20:33
@natasha41575
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 May 26, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: koba1t, 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:

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 May 26, 2023
@k8s-ci-robot k8s-ci-robot merged commit cf3e81b into kubernetes-sigs:master May 26, 2023
6 checks passed
@koba1t koba1t deleted the fix/add_check_kustomization_is_empty branch May 26, 2023 17:39
@Striar-Yunis
Copy link

This was a breaking change with kustomize localize (though the issue could be argued to be the localize command). Localize strips empty resources to save space.

apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
resources: []

Gets localized as:

apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component

The localized version in 5.1.0 is unable to build with this change.

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. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants