kustomize icon indicating copy to clipboard operation
kustomize copied to clipboard

Add support for extra fieldspecs in configurations for Labels

Open yutaroyamanaka opened this issue 1 year ago • 17 comments

worked on #4816

I added the support for Labels so that users can specify extra fieldspecs as well as commonLabels.

Here is the example kustomization.yaml.

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
labels:
- pairs:
    someName: someValue
resources:
  # resources.yaml contains a Gorilla and a AnimalPark
  - resources.yaml
configurations:
- labels.yaml

resources.yaml

apiVersion: animal/v1
kind: Gorilla
metadata:
  name: gg
---
apiVersion: animal/v1
kind: AnimalPark
metadata:
  name: ap
spec:
  gorillaRef:
    name: gg
    kind: Gorilla
    apiVersion: animal/v1

labels.yaml

labels:
  - path: spec/gorillaRef/metadata/labels
    kind: AnimalPark
    create: true

The output of kustomize build is as follows

apiVersion: animal/v1
kind: AnimalPark
metadata:
  labels:
    someName: someValue
  name: ap
spec:
  gorillaRef:
    apiVersion: animal/v1
    kind: Gorilla
    metadata:
      labels:
        someName: someValue
    name: gg
  template:
    name: template

Also, I added an example about this support in examples/transformerconfigs/README.md I'm not very sure where I can add the test case for this support. I would be grateful if we can discuss this.

yutaroyamanaka avatar Mar 12 '23 13:03 yutaroyamanaka

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 avatar Mar 12 '23 13:03 k8s-ci-robot

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: yutaroyamanaka / name: Taro (b909aeac5315ccd1b1228fa8f05bf07de234c354, a5d7ffbeb76e947abc1a29f778142a96af167bfa, 2f5f8ec9880cd83b9ece379e45bd06b49289e19d, d1c50ef503a7c4771a20a0b921c4184c28b75351)

Welcome @yutaroyamanaka!

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. :smiley:

k8s-ci-robot avatar Mar 12 '23 13:03 k8s-ci-robot

Hi @yutaroyamanaka. 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 avatar Mar 12 '23 13:03 k8s-ci-robot

/triage accepted /kind feature /priority backlog

Thanks for the PR! Please add some tests for this new feature. For example, api/internal/plugins/builtinconfig/transformerconfig_test.go has TestMerge that could be enhanced to cover the labels merge, and api/krusty/customconfig_test.go would be a good place for an integration test.

KnVerey avatar Mar 22 '23 19:03 KnVerey

@KnVerey Thanks you for providing that information.

  • added a unit test to TestMerge in api/internal/plugins/builtinconfig/transformerconfig_test.go
  • added an integration test called TestCustomConfigLabelsMerge in api/krusty/customconfig_test.go
  • fix a typo in TestMerge < https://github.com/kubernetes-sigs/kustomize/blob/master/api/internal/plugins/builtinconfig/transformerconfig_test.go#L137

yutaroyamanaka avatar Mar 23 '23 10:03 yutaroyamanaka

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-triage-robot avatar Jun 21 '23 10:06 k8s-triage-robot

/remove-lifecycle stale

koba1t avatar Jul 04 '23 12:07 koba1t

/ok-to-test

koba1t avatar Jul 04 '23 12:07 koba1t

@yutaroyamanaka Thanks for your contribution! Katrina is still very busy. I'll check your PR instead.

koba1t avatar Jul 04 '23 12:07 koba1t

/retest

koba1t avatar Jul 04 '23 12:07 koba1t

/lgtm Please wait for the review by the maintainers.

/cc @natasha41575 @annasong20

koba1t avatar Jul 04 '23 12:07 koba1t

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-triage-robot avatar Jan 20 '24 09:01 k8s-triage-robot

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yutaroyamanaka Once this PR has been reviewed and has the lgtm label, please ask for approval from koba1t. 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 avatar Jan 28 '24 20:01 k8s-ci-robot

Hi @yutaroyamanaka This PR almost looks good to me. I plan to merge it because I got merge to master permission now.

Looks like this PR contains a few lint failures. Could you check and fix it?

koba1t avatar Jan 29 '24 16:01 koba1t

The Kubernetes project currently lacks enough active 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 rotten
  • Close this PR with /close
  • Offer to help out with Issue Triage

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

/lifecycle rotten

k8s-triage-robot avatar Feb 28 '24 17:02 k8s-triage-robot

/remove-lifecycle rotten

stormqueen1990 avatar Mar 05 '24 00:03 stormqueen1990

Superseded by #5556

/close

stormqueen1990 avatar Apr 28 '24 17:04 stormqueen1990

@stormqueen1990: Closed this PR.

In response to this:

Superseded by #5556

/close

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 avatar Apr 28 '24 17:04 k8s-ci-robot

PR needs rebase.

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 avatar Apr 28 '24 17:04 k8s-ci-robot