Commit Graph

147 Commits

Author SHA1 Message Date
Davanum Srinivas
a7703f685c Drop usage of forked copies of goyaml.v2 and goyaml.v3
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-06-25 13:13:52 -04:00
Kubernetes Prow Robot
616c084805 Merge pull request #5865 from milkshake308/feat_helm_devel_arg
feat(helm): allow the use of devel alias for helmcharts
2025-05-17 12:25:16 -07:00
Kubernetes Prow Robot
2e80cebf21 Merge pull request #5630 from cunyat/feat/5516-replacement-inline-value
Add static value source for replacement
2025-03-28 05:54:40 -07:00
milkshake308
418f233314 feat: add test cases for helm devel 2025-02-21 01:15:33 +01:00
milkshake308
c5f69b002f feat: add devel options for helmcharts 2025-02-21 01:13:18 +01:00
Davanum Srinivas
d32eacf034 Remove starlark support
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2024-09-23 16:52:05 -04:00
Isar_NS
4034e36ee1 Add --helm-debug Flag to Kustomize for Enhanced Helm Debugging (#5751)
* feat: add helm-debug flag

* revert: go.work.sum

* test: add helm chart args helm-debug test

* test: helm debug flag

* refactor: helm debug output

* style: linting

* revert: go.work.sum
2024-09-12 23:43:12 +01:00
Daniel Wilson
b7cdd9168a Sort built-in Namespace kind before CRDs with the same name (#5458)
* add core api sort priority for NAmespace kind in gvkLessThan

* fix logic

* fix syntax

* fix syntax

* fix logic

* regenerate builtin plugins
2024-09-03 21:57:17 +01:00
Ramon Cunyat
6c27970019 Add static value source for replacement
Introduces `sourceValue` on replacement object for replacing from a
static value instead of sourcing from another object.

Solves #5516
2024-07-25 14:32:54 +02:00
Mauren Berti
77354d73b9 chore: add deprecation comment to commonLabels
`commonLabels` is deprecated, but the field did not have a deprecation comment,
like other fields do. Add the deprecation comment, as some IDEs use that as a
guideline to show a strikethrough in the field names (and to follow the pattern
of other deprecated fields).
2024-05-19 21:07:00 -04:00
Mauren
671de1662d feat: support labels key in transformer configuration (#5556)
* feat: support labels key in transformer configuration

Allow the usage of a separate transformer configuration for the labels key,
similar to what is currently available for commonLabels and commonAnnotations.
This aims to provide the same functionality that commonLabels currently provide
for labels, since commonLabels is deprecated and slated for removal in a future
release.

* chore(transformerconfig): add nolint hint

Add a nolint hint to the new method so the returns can stay consistent with
one another.

* fix: changes from code review

* Rename methods `AddCommonLabelFieldSpec` and `AddLabelFieldSpec` to
  `AddCommonLabelsFieldSpec` and `AddLabelsFieldSpec`.
* Add extra test to verify scenarios applying labels to Custom Resource Definitions.
2024-04-25 00:40:44 -07:00
Nick
f23d45fcb4 Add deprecation warning message to commonLabels (#5464)
* Add commonLabels deprecation warning message

* Add test

* Add warningToRunEditFix message
2023-11-30 17:41:43 +01:00
Kubernetes Prow Robot
eb7f91ffcd Merge pull request #5270 from MrFreezeex/helm-kube-api
helm: add support for kube-version and add cli args for both kube-version and api-versions
2023-11-15 21:13:59 +01:00
Kubernetes Prow Robot
e219b8864e Merge pull request #5421 from prashantrewar/swap-yaml-library
Replace gopkg.in/yaml.v2 with sigs.k8s.io/yaml/goyaml.v2
2023-11-10 17:14:41 +01:00
Carl Henrik Lunde
2fda12d220 perf: MakeDefaultConfig once (#5082)
* perf: MakeDefaultConfig once

This shaves of another 2 seconds (62%) of the remaining execution
time for a kustomization tree with 4000 documents, reducing the execution
time from 4.79s to 1.82s

    0     0%  1.38%      2.98s 37.25%  sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig.MakeDefaultConfig

before:

    (pprof) top30 -cum
    Showing nodes accounting for 1.82s, 22.75% of 8s total
    Dropped 408 nodes (cum <= 0.04s)
    Showing top 30 nodes out of 308
        flat  flat%   sum%        cum   cum%
            0     0%     0%      4.79s 59.88%  github.com/spf13/cobra.(*Command).Execute
            0     0%     0%      4.79s 59.88%  github.com/spf13/cobra.(*Command).ExecuteC
            0     0%     0%      4.79s 59.88%  github.com/spf13/cobra.(*Command).execute
            0     0%     0%      4.79s 59.88%  main.main
            0     0%     0%      4.79s 59.88%  runtime.main
            0     0%     0%      4.79s 59.88%  sigs.k8s.io/kustomize/kustomize/v5/commands/build.NewCmdBuild.func1
            0     0%     0%      4.22s 52.75%  sigs.k8s.io/kustomize/api/krusty.(*Kustomizer).Run
            0     0%     0%      4.18s 52.25%  sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).MakeCustomizedResMap (inline)
            0     0%     0%      4.18s 52.25%  sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).makeCustomizedResMap
            0     0%     0%      4.06s 50.75%  sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).AccumulateTarget
            0     0%     0%      4.06s 50.75%  sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).accumulateResources
            0     0%     0%      4.06s 50.75%  sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).accumulateTarget
            0     0%     0%      4.05s 50.62%  sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).accumulateDirectory
            0     0%     0%      3.22s 40.25%  runtime.systemstack
            0     0%     0%      3.03s 37.88%  runtime.gcBgMarkWorker
            0     0%     0%      3.03s 37.88%  runtime.gcBgMarkWorker.func2
        0.11s  1.38%  1.38%      3.03s 37.88%  runtime.gcDrain
            0     0%  1.38%      2.98s 37.25%  sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig.MakeDefaultConfig
            0     0%  1.38%      2.98s 37.25%  sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig.MakeTransformerConfig
            0     0%  1.38%      2.98s 37.25%  sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig.makeTransformerConfigFromBytes
            0     0%  1.38%      2.97s 37.12%  sigs.k8s.io/yaml.yamlUnmarshal
            0     0%  1.38%      2.91s 36.38%  sigs.k8s.io/yaml.Unmarshal (inline)
        1.34s 16.75% 18.12%      2.87s 35.88%  runtime.scanobject
            0     0% 18.12%      2.53s 31.62%  sigs.k8s.io/yaml.yamlToJSON
            0     0% 18.12%      1.91s 23.88%  gopkg.in/yaml%2ev2.unmarshal
            0     0% 18.12%      1.86s 23.25%  gopkg.in/yaml%2ev2.Unmarshal (partial-inline)
            0     0% 18.12%      1.43s 17.88%  gopkg.in/yaml%2ev2.(*parser).parse
        0.01s  0.12% 18.25%      1.27s 15.88%  gopkg.in/yaml%2ev2.(*parser).document
        0.01s  0.12% 18.38%      1.25s 15.62%  gopkg.in/yaml%2ev2.(*parser).mapping
        0.35s  4.38% 22.75%      1.21s 15.12%  runtime.mallocgc

after:

    (pprof) top30 -cum
    Showing nodes accounting for 0.84s, 24.42% of 3.44s total
    Dropped 225 nodes (cum <= 0.02s)
    Showing top 30 nodes out of 345
        flat  flat%   sum%        cum   cum%
            0     0%     0%      1.82s 52.91%  github.com/spf13/cobra.(*Command).Execute
            0     0%     0%      1.82s 52.91%  github.com/spf13/cobra.(*Command).ExecuteC
            0     0%     0%      1.82s 52.91%  github.com/spf13/cobra.(*Command).execute
            0     0%     0%      1.82s 52.91%  main.main
            0     0%     0%      1.82s 52.91%  runtime.main
            0     0%     0%      1.82s 52.91%  sigs.k8s.io/kustomize/kustomize/v5/commands/build.NewCmdBuild.func1
            0     0%     0%      1.57s 45.64%  runtime.systemstack
            0     0%     0%      1.49s 43.31%  runtime.gcBgMarkWorker
            0     0%     0%      1.49s 43.31%  runtime.gcBgMarkWorker.func2
        0.03s  0.87%  0.87%      1.49s 43.31%  runtime.gcDrain
        0.62s 18.02% 18.90%      1.45s 42.15%  runtime.scanobject
            0     0% 18.90%      1.25s 36.34%  sigs.k8s.io/kustomize/api/krusty.(*Kustomizer).Run
            0     0% 18.90%      1.21s 35.17%  sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).MakeCustomizedResMap (inline)
            0     0% 18.90%      1.21s 35.17%  sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).makeCustomizedResMap
            0     0% 18.90%      1.08s 31.40%  sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).AccumulateTarget
            0     0% 18.90%      1.08s 31.40%  sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).accumulateResources
            0     0% 18.90%      1.08s 31.40%  sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).accumulateTarget
            0     0% 18.90%      1.07s 31.10%  sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).accumulateDirectory
            0     0% 18.90%      0.57s 16.57%  sigs.k8s.io/kustomize/api/resmap.(*resWrangler).AsYaml
            0     0% 18.90%      0.57s 16.57%  sigs.k8s.io/kustomize/api/resource.(*Resource).AsYAML
        0.11s  3.20% 22.09%      0.48s 13.95%  runtime.mallocgc
            0     0% 22.09%      0.45s 13.08%  sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).accumulateFile
            0     0% 22.09%      0.45s 13.08%  sigs.k8s.io/kustomize/api/resmap.(*Factory).FromFile
            0     0% 22.09%      0.33s  9.59%  sigs.k8s.io/kustomize/kyaml/yaml.(*RNode).MarshalJSON
        0.08s  2.33% 24.42%      0.32s  9.30%  runtime.greyobject
            0     0% 24.42%      0.30s  8.72%  sigs.k8s.io/kustomize/api/resmap.(*Factory).NewResMapFromBytes
            0     0% 24.42%      0.27s  7.85%  sigs.k8s.io/yaml.JSONToYAML
            0     0% 24.42%      0.25s  7.27%  sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).runTransformers
            0     0% 24.42%      0.25s  7.27%  sigs.k8s.io/kustomize/api/resource.(*Factory).RNodesFromBytes
            0     0% 24.42%      0.25s  7.27%  sigs.k8s.io/kustomize/api/resource.(*Factory).SliceFromBytes

* Tests and comments for MakeDefaultConfig perf work

Document updated code in MakeDefaultConfig.
Add unit tests to ensure DeepCopy works.
Add hints to other code to ensure DeepCopy is kept up to date.
2023-11-02 22:54:42 +01:00
Arthur Outhenin-Chalandre
790ca0e7b6 helm: add kube-version and api-versions on CLI args
It makes sense to add that as a CLI args since you could use one single
kustomization file/helm chart for multiple clusters. Also it's easier to
have those on the CLI if the user has some kind of tooling that will end
up calling kustomize and that could pass those (i.e.: ArgoCD is doing
that for Helm so it could do that for Kustomize as well that will end up
calling Helm as well).

Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@ledger.fr>
2023-11-02 16:46:41 +01:00
Arthur Outhenin-Chalandre
d5dd5f4567 helm: add kube-version
Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@ledger.fr>
2023-11-02 16:46:41 +01:00
Prashant Rewar
2ab117166f replace gopkg.in/yaml.v2 with sigs.k8s.io/yaml/goyaml.v2
Signed-off-by: Prashant Rewar <108176843+prashantrewar@users.noreply.github.com>
2023-11-01 14:40:41 +05:30
Mauren Berti
6ef9773c02 docs: update comment to reflect usage of namespace
Update the comment for the namespace option to reflect its real usage for both
secret and configmap.
2023-10-09 17:17:49 -04:00
Kubernetes Prow Robot
cf3e81b590 Merge pull request #4949 from koba1t/fix/add_check_kustomization_is_empty
add check that kustomization is empty
2023-05-26 10:36:53 -07:00
Tim Jacomb
75fa235498 Only override name of core api version 2023-04-18 09:41:28 +01:00
koba1t
928b823d8f fix using reflect.DeepEqual for check kustomization is empty 2023-04-06 05:52:13 +09:00
koba1t
2c2b2ab825 add check that kustomization is empty 2023-04-06 05:32:08 +09:00
Katrina Verey
dd520f8889 Revert strict decoding of Kustomization due to regression in anchor handling (#5073)
* Revert strict decoding of Kustomization due to regression in anchor handling

* Empty commit
2023-03-13 13:46:47 -07:00
Natasha Sarkar
1957d5c746 support for more helm template args (#4926)
* support for more helm template args

* move templateArgs and unit tests to api/types

* undo package name change

* use our own simple helm chart instead of forking one

* add argument to AsHelmArgs

* code review

* lint errors
2023-02-01 10:19:05 -08:00
Anna Song
fb294921f5 Localize helm fields (#4978)
* Localize helm fields

* Address readability feedback

* Handle edge cases

* Improve readability

Split copyChartHome and use existence to prevent repeated copying.
2023-01-26 12:56:26 -08:00
Kubernetes Prow Robot
89d3ca1757 Merge pull request #4973 from KnVerey/remove-inventory-field
Remove long-ignored Inventory field from Kustomization type
2023-01-20 13:15:53 -08:00
Cailyn
8ab4b8d167 remove direct dependency on github/pkg/errors (#4970) 2023-01-13 10:52:25 -08:00
Katrina Verey
d70315fed6 Remove Inventory field from Kustomization
This field has not done anything since v3.5.5. It was missed in the cleanup in https://github.com/kubernetes-sigs/kustomize/pull/2421
2023-01-12 19:11:44 -05:00
koba1t
6489e35b7c improve error messages 2023-01-07 03:30:16 +09:00
yugo kobayashi
5fed0f76c8 refactor Unmarshal Kustomization struct code 2022-12-13 21:04:50 +00:00
yugo kobayashi
faddb49c89 remove FixKustomizationPreUnmarshalling 2022-12-13 18:50:25 +00:00
Natasha Sarkar
2db573b6a0 drop support for legacy patches (#4911)
* drop support for legacy patches

* fix CI
2022-12-07 18:06:24 -08:00
Yannis Zarkadas
a502717460 Make ordering configurable (#4019)
* api: Add new types for customizeable resource ordering

Signed-off-by: Yannis Zarkadas <yanniszark@arrikto.com>

* plugins: Implement SortOrderTransformer plugin

Implement the SortOrderTransformer plugin. This plugin allows the user
to customize the order that kustomize will output resources in.

The API for the plugin is the following:

sortOptions:
  order: legacy | fifo
  legacySortOptions:
    orderFirst:
    - {GVK}
    orderLast:
    - {GVK}

Signed-off-by: Yannis Zarkadas <yanniszark@arrikto.com>

* plugins: Add boilerplate and generate code for new SortOrderTransformer

Signed-off-by: Yannis Zarkadas <yanniszark@arrikto.com>

* build: Add option to denote if the reorder flag was set by the user

We want to take different actions if the reorder flag was set by the
user or filled by the default value. Thus, we propagate this information
from build to the krusty options.

Signed-off-by: Yannis Zarkadas <yanniszark@gmail.com>

* api/krusty: Ensure sort ordering works with CLI flag and kustomization

Sort order can be defined in two places:
- (new) kustomization file
- (old) CLI flag
We want the kustomization file to take precedence over the CLI flag.

Eventually, we may want to move away from having a CLI flag altogether:
https://github.com/kubernetes-sigs/kustomize/issues/3947

Case 1: Sort order set in kustomization file AND in CLI flag.
Print a warning and let the kustomization file take precedence.

Case 2: Sort order set in CLI flag only or not at all.
Follow the CLI flag (defaults to legacy) and reorder at the end.

Case 3: Sort order set in kustomization file only.
Simply build the kustomization.

Signed-off-by: Yannis Zarkadas <yanniszark@gmail.com>

* krusty: Add e2e test for SortOrderTransformer

Signed-off-by: Yannis Zarkadas <yanniszark@arrikto.com>

* plugins: Purge LegacyOrderTransformer

Signed-off-by: Yannis Zarkadas <yanniszark@gmail.com>

* Update go.work.sum

Signed-off-by: Yannis Zarkadas <yanniszark@gmail.com>

* review: Make review changes

Signed-off-by: Yannis Zarkadas <yanniszark@gmail.com>

Signed-off-by: Yannis Zarkadas <yanniszark@arrikto.com>
Signed-off-by: Yannis Zarkadas <yanniszark@gmail.com>
2022-12-02 13:59:53 -08:00
Kubernetes Prow Robot
b20e611413 Merge pull request #4723 from koba1t/emit_a_warning_when_deprecated_fields_are_used
Emit a warning on build when deprecated fields are used
2022-11-16 08:32:50 -08:00
Kubernetes Prow Robot
7ee6dd551d Merge pull request #4733 from koba1t/feat/add_edit-fix_for_patchesStrategicMerge_to_patches
add `edit fix` for patchesStrategicMerge to patches
2022-10-21 14:57:57 -07:00
Lars Kellogg-Stedman
38da7ca15c Add support for helm --no-hooks flag
This commit adds the `skipHooks` option to the helm chart support in order
to  expose the --no-hooks flag introduced to Helm in [1].

Using Kustomize to inflate a Helm chart would in some situations result in
different results than using `helm install`. This is because `helm
template`, by default, will render chart tests in the `templates/test`
directory, which can lead to undesired resources in the output.

See [2] for additional discussion.

[1]: https://github.com/helm/helm/pull/6444
[2]: https://github.com/helm/helm/issues/6443

Signed-off-by: Lars Kellogg-Stedman <lars@oddbit.com>
2022-10-07 17:14:06 -04:00
yugo kobayashi
401cf9579c update golangci-lint v1.49.0 2022-09-22 13:24:40 +00:00
yugo kobayashi
21ee7f7125 Emit a warning when deprecated fields are used 2022-09-01 23:02:50 +00:00
yugo kobayashi
032bf3338e update checker code in patchStrategicMerge 2022-08-28 17:20:21 +00:00
yugo kobayashi
bb7ebe029c support file path patch to patchesStrategicMerge 2022-08-06 20:28:48 +00:00
yugo kobayashi
64f42ea45f add edit-fix for patchesStrategicMerge to patches 2022-08-06 20:28:48 +00:00
Agustina Barbetta
5948f6aa63 [Address #3937] Add labels to template/metadata if includeTemplates is true (#4209)
* add labels in template/metadata by default

* update comment

* fix kustomization labels test

* Add spec/template/metadata/labels when includeTemplate is true

* remove unnecessary test changes

* add error wrap

* Revert "add error wrap"

This reverts commit 0a203df83edb90a400b35d5521487b984619e919.

* add error wrap at template fieldSpec merge
2022-05-05 11:24:22 -07:00
Dipto Chakrabarty
a464ed0c59 add tagsuffix to take image tag suffix (#4364)
* add tagsuffix to take image tag suffix

* add comments to warn about specifications

* add test and error handle

* fix indent

* update comment

* fix merge errors and return updates

* update image update and fix example

* fix yamls formats

remove tabs in yamls

fix space in image name

tag error in name

* fix spacing issue

format of yaml

set example as above

* spacing of spec in testing templates

* change to switch case
2022-04-14 10:00:47 -07:00
Katrina Verey
0fa010c7e7 Add missing boilerplate 2022-04-04 14:24:04 -04:00
Katrina Verey
71bf0d5d14 Update full linter list and enable some easily resolved new ones 2022-03-31 11:37:26 -04:00
Katrina Verey
14947e449b Address new linter complaints 2022-03-31 11:37:26 -04:00
Dingzhu Lurong
b1086ac49b fix broken link 2022-03-09 16:00:59 +08:00
Natasha Sarkar
bcebad1664 new command kustomize edit add buildmetadata (#4413)
* new command kustomize edit add buildmetadata

* new commands kustomize edit set buildmetadata and kustomize edit remove buildmetadata
2022-01-26 15:34:50 -08:00
natasha41575
9577d61167 move origin to be an attribute of KustTarget 2022-01-19 17:26:19 -08:00