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

feat: support inline configurations #5657

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

TLDMain
Copy link

@TLDMain TLDMain commented Apr 12, 2024

Relevant issue #1966

Copy link

linux-foundation-easycla bot commented Apr 12, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Apr 12, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @TLDMain!

It looks like this is your first PR to kubernetes-sigs/kustomize 🎉. 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/kustomize 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 the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 12, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @TLDMain. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 12, 2024
@k8s-ci-robot k8s-ci-robot added 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 Apr 12, 2024
Copy link
Member

@stormqueen1990 stormqueen1990 left a comment

Choose a reason for hiding this comment

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

Hi there, @TLDMain!

Thanks for your contribution!

This PR is referring to an old issue that was closed before it was triaged. Could you please elaborate on what is the use case you're trying to address here?

/hold

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 21, 2024
@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 Jul 24, 2024
@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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 6, 2024
@TLDMain
Copy link
Author

TLDMain commented Aug 6, 2024

Hi there, @stormqueen1990!

Thanks for your feedback!

This PR addresses the need to streamline kustomize configurations by allowing inlined configurations directly within the kustomization.yaml file, similar to how patches are currently handled. The use case here is to simplify the sharing and management of kustomize configurations by embedding them within a single file, eliminating the need for separate configuration files. This makes it easier to provide comprehensive and portable examples.

For instance, with this change, configurations can be inlined as follows:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - helmrelease.yaml
configMapGenerator:
  - name: helmrelease-values
    files:
      - values.yaml=helmrelease.values.yaml
configurations:
  - |
    nameReference:
      - kind: ConfigMap
        version: v1
        fieldSpecs:
          - path: spec/valuesFrom/name
            kind: HelmRelease

This enhancement allows users to consolidate their configurations, making it more convenient to manage and share kustomize setups.

/remove-lifecycle stale
/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Aug 6, 2024
@stormqueen1990
Copy link
Member

/triage under-consideration

Copy link
Member

@varshaprasad96 varshaprasad96 left a comment

Choose a reason for hiding this comment

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

This looks good to me! Thank you!
/lgtm

I'll wait for approval, still some other maintainer can also take a look.
cc: @stormqueen1990 @antoooks

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

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: stormqueen1990, TLDMain
Once this PR has been reviewed and has the lgtm label, please ask for approval from varshaprasad96. 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

@stormqueen1990
Copy link
Member

/remove-triage under-consideration
/ok-to-test
/unhold

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. triage/under-consideration labels Aug 12, 2024
Copy link
Member

@stormqueen1990 stormqueen1990 left a comment

Choose a reason for hiding this comment

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

Hi there, @TLDMain!

After reviewing this change, I noticed that the configurations field was meant to explicitly only accept paths to transformer configuration files:

// Configurations is a list of transformer configuration files
Configurations []string `json:"configurations,omitempty" yaml:"configurations,omitempty"`

Accepting paths and inline configurations in the same configuration list without separate fields for each is inconsistent with how other configurations in the Kustomization API work right now -- for instance, patches have separate fields for a file path (path) and an inline patch (patch):

type Patch struct {
// Path is a relative file path to the patch file.
Path string `json:"path,omitempty" yaml:"path,omitempty"`
// Patch is the content of a patch.
Patch string `json:"patch,omitempty" yaml:"patch,omitempty"`
// Target points to the resources that the patch is applied to
Target *Selector `json:"target,omitempty" yaml:"target,omitempty"`
// Options is a list of options for the patch
Options map[string]bool `json:"options,omitempty" yaml:"options,omitempty"`
}

Could you please add a new field in the Kustomization type for these inline patches?

I suggest inlineConfigurations as the name. The type can still be a string slice, just like the current configurations field.

Thanks in advance!

@koba1t
Copy link
Member

koba1t commented Aug 12, 2024

Hi @stormqueen1990

I suggest inlineConfigurations as the name. The type can still be a string slice, just like the current configurations field.

type Kustomization struct is our most important top-level configuration.
I feel we need to write The Enhancement Proposal and discuss the interface If we try to introduce any changes to that structure.
https://github.com/kubernetes-sigs/kustomize/blob/master/proposals/README.md

@TLDMain
Copy link
Author

TLDMain commented Aug 13, 2024

Hi there, @stormqueen1990!

Apologies for the incorrect analogy. I based these changes on the behavior of the transformers and generators fields, not on patches. Here's a similar PR: #3225. However, I can create a separate field if that's critical.

Also, the comments for these fields are similar to those in the configurations:

// Generators is a list of files containing custom generators
Generators []string `json:"generators,omitempty" yaml:"generators,omitempty"`
// Transformers is a list of files containing transformers
Transformers []string `json:"transformers,omitempty" yaml:"transformers,omitempty"`

I'll wait for your decision.

@koba1t
Copy link
Member

koba1t commented Aug 15, 2024

Hi @TLDMain

I think there is a many consideration point and need take a time that add new inlineConfigurations field for Kustomization struct.
I believe that is a better to use current Configurations []string field in this case and add carefully path check in code avoid some bugs.

Please add more strict check for string in Configurations field.

@TLDMain
Copy link
Author

TLDMain commented Aug 16, 2024

Hi @koba1t.

I suggest two options for checking: either use regex to verify that the string contains a file path, or check if the string contains multiple lines.

Alternatively, you can propose your own method for checking.

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants