Davanum Srinivas
84e6594e9b
Update golangci/golangci-lint to v1.56.2
...
Signed-off-by: Davanum Srinivas <davanum@gmail.com >
2024-12-14 19:28:39 -05: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
Yusuke Abe
ed09399cd1
fix: return error instead of log.Fatalf() ( #5625 )
...
* fix: return error instead of log.Fatalf()
* chore: add meaningful message to error output
* chore: add meaningful message to fatal function
2024-04-18 03:56:51 -07:00
Varsha Prasad Narsing
7911b2c001
[refactor]: Internalize loader api
...
This PR intends to move the loader api to
internal. Only the necessary methods which
are needed for the api have been put into
`pkg/loader.go`.
Signed-off-by: Varsha Prasad Narsing <varshaprasad96@gmail.com >
2023-09-28 10:49:45 -04:00
Carl Henrik Lunde
4842d8be60
perf: Intersection: Avoid callid AllIds inside inner loop
...
This shaves of another 8.5 seconds (one third) of the remaining execution
time for a kustomization tree with 4000 documents, reducing the execution
time from 27.46s to 18.94s
0.02s 0.062% 11.14% 8.45s 26.36% sigs.k8s.io/kustomize/api/internal/accumulator.(*ResAccumulator).Intersection
0.06s 0.19% 11.32% 8.32s 25.95% sigs.k8s.io/kustomize/api/resmap.(*resWrangler).AllIds
before
(pprof) top25 -cum
Showing nodes accounting for 3.63s, 11.32% of 32.06s total
Dropped 614 nodes (cum <= 0.16s)
Showing top 25 nodes out of 171
flat flat% sum% cum cum%
0 0% 0% 27.46s 85.65% github.com/spf13/cobra.(*Command).Execute
0 0% 0% 27.46s 85.65% github.com/spf13/cobra.(*Command).ExecuteC
0 0% 0% 27.46s 85.65% github.com/spf13/cobra.(*Command).execute
0 0% 0% 27.46s 85.65% main.main
0 0% 0% 27.46s 85.65% runtime.main
0 0% 0% 27.46s 85.65% sigs.k8s.io/kustomize/kustomize/v5/commands/build.NewCmdBuild.func1
0 0% 0% 26.95s 84.06% sigs.k8s.io/kustomize/api/krusty.(*Kustomizer).Run
0 0% 0% 22.09s 68.90% sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).MakeCustomizedResMap (inline)
0 0% 0% 22.09s 68.90% sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).makeCustomizedResMap
0.29s 0.9% 0.9% 20.96s 65.38% sigs.k8s.io/kustomize/api/resource.(*Resource).CurId
0 0% 0.9% 13.61s 42.45% sigs.k8s.io/kustomize/api/resmap.(*resWrangler).Append
0 0% 0.9% 13.60s 42.42% sigs.k8s.io/kustomize/api/resmap.(*resWrangler).GetMatchingResourcesByCurrentId (partial-inline)
0.14s 0.44% 1.34% 13.60s 42.42% sigs.k8s.io/kustomize/api/resmap.(*resWrangler).filteredById
0.05s 0.16% 1.50% 12.91s 40.27% sigs.k8s.io/kustomize/api/resmap.GetCurrentId
0.25s 0.78% 2.28% 12.48s 38.93% sigs.k8s.io/kustomize/api/resource.(*Resource).GetGvk (inline)
0.49s 1.53% 3.81% 12.23s 38.15% sigs.k8s.io/kustomize/kyaml/resid.GvkFromNode
0 0% 3.81% 11.61s 36.21% sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).IgnoreLocal
0 0% 3.81% 10.47s 32.66% sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).AccumulateTarget
0 0% 3.81% 10.47s 32.66% sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).accumulateTarget
0.01s 0.031% 3.84% 10.46s 32.63% sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).accumulateResources
0 0% 3.84% 10.43s 32.53% sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).accumulateDirectory
0.64s 2.00% 5.83% 10.12s 31.57% sigs.k8s.io/kustomize/kyaml/yaml.visitMappingNodeFields
1.68s 5.24% 11.07% 9.48s 29.57% sigs.k8s.io/kustomize/kyaml/yaml.visitFieldsWhileTrue
0.02s 0.062% 11.14% 8.45s 26.36% sigs.k8s.io/kustomize/api/internal/accumulator.(*ResAccumulator).Intersection
0.06s 0.19% 11.32% 8.32s 25.95% sigs.k8s.io/kustomize/api/resmap.(*resWrangler).AllIds
after
(pprof) top30 -cum
Showing nodes accounting for 5.04s, 22.63% of 22.27s total
Dropped 540 nodes (cum <= 0.11s)
Showing top 30 nodes out of 209
flat flat% sum% cum cum%
0 0% 0% 18.94s 85.05% github.com/spf13/cobra.(*Command).Execute
0 0% 0% 18.94s 85.05% github.com/spf13/cobra.(*Command).ExecuteC
0 0% 0% 18.94s 85.05% github.com/spf13/cobra.(*Command).execute
0 0% 0% 18.94s 85.05% main.main
0 0% 0% 18.94s 85.05% runtime.main
0 0% 0% 18.94s 85.05% sigs.k8s.io/kustomize/kustomize/v5/commands/build.NewCmdBuild.func1
0 0% 0% 18.40s 82.62% sigs.k8s.io/kustomize/api/krusty.(*Kustomizer).Run
0 0% 0% 13.65s 61.29% sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).MakeCustomizedResMap (inline)
0 0% 0% 13.65s 61.29% sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).makeCustomizedResMap
0 0% 0% 13.52s 60.71% sigs.k8s.io/kustomize/api/resmap.(*resWrangler).Append
0 0% 0% 13.44s 60.35% sigs.k8s.io/kustomize/api/resmap.(*resWrangler).GetMatchingResourcesByCurrentId (inline)
0.16s 0.72% 0.72% 13.44s 60.35% sigs.k8s.io/kustomize/api/resmap.(*resWrangler).filteredById
0.04s 0.18% 0.9% 12.54s 56.31% sigs.k8s.io/kustomize/api/resmap.GetCurrentId
0.19s 0.85% 1.75% 12.49s 56.08% sigs.k8s.io/kustomize/api/resource.(*Resource).CurId
0 0% 1.75% 10.37s 46.56% sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).AccumulateTarget
0 0% 1.75% 10.37s 46.56% sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).accumulateResources
0 0% 1.75% 10.37s 46.56% sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).accumulateTarget
0 0% 1.75% 10.34s 46.43% sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).accumulateDirectory
0.19s 0.85% 2.60% 7.82s 35.11% sigs.k8s.io/kustomize/api/resource.(*Resource).GetGvk (inline)
0.42s 1.89% 4.49% 7.63s 34.26% sigs.k8s.io/kustomize/kyaml/resid.GvkFromNode
0.26s 1.17% 5.66% 6.01s 26.99% sigs.k8s.io/kustomize/kyaml/yaml.visitMappingNodeFields
0 0% 5.66% 5.76s 25.86% sigs.k8s.io/kustomize/api/internal/accumulator.(*ResAccumulator).MergeAccumulator
1.12s 5.03% 10.69% 5.75s 25.82% sigs.k8s.io/kustomize/kyaml/yaml.visitFieldsWhileTrue
0 0% 10.69% 5.57s 25.01% sigs.k8s.io/kustomize/api/resmap.(*resWrangler).appendAll (inline)
0 0% 10.69% 5.55s 24.92% sigs.k8s.io/kustomize/api/internal/accumulator.(*ResAccumulator).AppendAll (inline)
0 0% 10.69% 5.55s 24.92% sigs.k8s.io/kustomize/api/resmap.(*resWrangler).AppendAll
0 0% 10.69% 4.73s 21.24% sigs.k8s.io/kustomize/api/internal/builtins.(*SortOrderTransformerPlugin).Transform
0 0% 10.69% 4.73s 21.24% sigs.k8s.io/kustomize/api/krusty.(*Kustomizer).applySortOrder
0 0% 10.69% 4.72s 21.19% sigs.k8s.io/kustomize/api/internal/builtins.applyOrdering
2.66s 11.94% 22.63% 4.63s 20.79% sigs.k8s.io/kustomize/kyaml/yaml.visitMappingNodeFields.func2
2023-03-12 15:50:11 +01:00
Cailyn
8ab4b8d167
remove direct dependency on github/pkg/errors ( #4970 )
2023-01-13 10:52:25 -08:00
Katrina Verey
387c95be1f
Correctly detect ambiguity between potential referrers when targeting a name+namespace reference
2022-07-07 18:33:48 -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
Kubernetes Prow Robot
1c5ce6975f
Merge pull request #4312 from m-Bilal/fix-4240
...
Fixes 4240; added null check on namespace when resource is a RoleBinding
2022-01-10 09:43:13 -08:00
m-Bilal
ff7b2f20d5
Throwing error instead of silently ignoring invalid input
2022-01-01 21:52:37 +05:30
natasha41575
c659306ee2
don't surface entire node content in error message
2021-12-22 16:56:02 -08:00
natasha41575
6dfc238aa2
improve gvk and resid strings for error messages
2021-12-22 11:39:07 -08:00
Yuwen Ma
f4382738ab
[fix 4124] Skip local resource until all transformations have completed.
...
Resources annotated as "local-config" are expected to be ignored. This skip local resource happens in "accumulateResources" which happens before any transformation operations.
However, the local resource may be needed in transformations.
Thus, this change removes the "drop local resource" logic from accumulateResources and removes these local resource after all transformation operations and var operations are done.
Note:
None of the existing ResMap functions can drop the resource slice easily: "Clear" will ruin the resource order, "AppendAll" only adds non-existing resource, "AbsorbAll" only add or modify but not delete.
Thus, we introduce a new func "Intersection" for resourceAccumulator that specificaly removes the resource by ID and keep the original order.
2021-09-16 11:15:05 -07:00
Justin SB
6552b90657
Cache the OrgId for nameReferenceTransformer
...
Because this is in an inner loop and is fairly memory-allocation
expensive even on a single allocation, it comes up top-of-the-list in
memory allocation pprof profiles, for example with the coredns
ClusterAddon.
Add simple caching.
2021-09-07 14:06:38 -04:00
Natasha Sarkar
91f74e8d16
replace Resource.options with annotations ( #4061 )
2021-07-23 18:19:05 -07:00
Natasha Sarkar
a84badb834
replace Resource.refBy with annotations
2021-07-07 15:22:36 -07:00
Francesc Campoy
7fae7d1bd6
Move api/filesys to kyaml/filesys ( #3997 )
...
* Move api/filesys to kyaml/filesys
* Add deprecated version of api/filesys with aliases to new code
* Use new kyaml/filesys package and update dependencies
* Migrate to kyaml/filesys and update dependencies
* Skip tests that break on Windows
2021-06-16 11:42:00 -07:00
Mikhail Mazurskiy
a3ed120efb
Handle errors
2021-06-05 09:43:13 +10:00
monopole
5c4e363f11
Remove delegation to RNode in Resource.
2021-05-11 10:49:17 -07:00
monopole
660847225d
Simplify gvk, speed up cluster-scoped checks.
2021-05-02 13:17:33 -07:00
monopole
c8dddac5b9
Move resid package from api to kyaml
2021-04-30 20:39:32 -07:00
Gautier Delorme
86c3863bc9
remove go-openapi/spec,validate,strfmt from api/
...
Signed-off-by: Gautier Delorme <gautier.delorme@gmail.com >
2021-04-25 16:57:34 +02:00
monopole
1f837fdfec
Type alias for spec.Schema
2021-03-16 16:18:10 -07:00
Natasha Sarkar
f96ac2d61e
allow general name and kind changes via an options field in patches
2021-03-10 14:58:58 -08:00
monopole
839fd2b971
Remove branching on kyaml enablement
2021-03-09 14:29:27 -08:00
Natasha Sarkar
722b0131f0
return error for duplicate keys rather than panicking
2021-03-03 12:13:24 -08:00
monopole
d4d5fca2a5
Drop dependence on k8s.io/kube-openapi
2021-02-08 17:31:54 -08:00
Natasha Sarkar
43157f5d35
cleaned up resource refactoring
2021-02-03 14:30:25 -08:00
Natasha Sarkar
f71854a0c8
Refactored resource to store all previous names and namespaces
2021-02-03 12:01:09 -08:00
monopole
aae2be1a79
Add tests in support of Issue 3489.
2021-02-02 18:35:46 -08:00
monopole
dcb26d0901
More fieldspec tests.
2021-01-31 19:08:48 -08:00
monopole
64644643d4
Improve name reference transformer testing.
2021-01-31 08:40:47 -08:00
monopole
4287e28ff4
Add test for issue 3489 and improve error messages.
2021-01-29 06:55:23 -08:00
monopole
2a16af80bf
Simplify, document and add more tests to var replacement.
2021-01-16 16:48:26 -08:00
monopole
561cef1d5c
Merge expansion package into refvar package.
2021-01-16 13:50:56 -08:00
monopole
45b1bf17d3
Annotate decisions on issue 3304 in api.
2021-01-16 08:08:52 -08:00
monopole
2cb972de3b
Rename id annotations to build annotations.
2021-01-15 06:43:13 -08:00
Natasha Sarkar
bd4580d73a
Manage name changes (prefix/suffix) via YAML annotations rather than via in-memory-only fields.
2021-01-11 13:08:45 -08:00
monopole
14a1a0e4a8
Fix 3424 by avoiding a JSON round trip
2021-01-10 20:39:01 -08:00
monopole
30dcf38609
Add var ref replacement tests and more doc.
2021-01-10 09:16:52 -08:00
monopole
658b62c6f1
Reduce complexity in NameReferenceTransformer.
2021-01-10 06:56:06 -08:00
monopole
769f65d6c4
Short circuit anno/label transformer for performance.
2021-01-08 18:02:58 -08:00
monopole
614e853db3
Confine calls to ApplyToJSON.
2021-01-07 20:31:10 -08:00
Antonin Bas
e819a2ba9d
Add Role / ClusterRole resourceNames to ConfigMap nameref resolver
...
While it is possible to use a kustomizeconfig.yml for this, with a
custom namereference, this functionality should probably be built-in.
This is similar to previous PRs, like this one:
https://github.com/kubernetes-sigs/kustomize/pull/592
2020-12-21 21:02:19 -08:00
jregan
735befef19
Add kunstruct impl of Get/SetDataMap, replace Resource.Merge
2020-12-21 07:22:03 -08:00
jregan
a5f3d5c823
Use DepProvider in tests to access kyaml impls.
2020-11-21 14:49:44 -08:00
Donny Xia
62a8a8c57d
check Gvk in roleRef when update name reference
2020-10-19 14:01:13 -07:00
Donny Xia
f0bc926640
ignore null value in fieldspec
2020-09-14 13:20:20 -07:00
Donny Xia
a563169461
refactor namereftransformer with kyaml
2020-07-27 10:56:13 -07:00