Skip to content

Commit 950cbfd

Browse files
authored
Merge branch 'master' into multi-platform
2 parents 4ab87f4 + f9ab532 commit 950cbfd

File tree

160 files changed

+4048
-3058
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+4048
-3058
lines changed

.github/workflows/apidiff.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
go-version-file: go.work
2323
- name: Execute go-apidiff
24-
uses: joelanford/[email protected].2
24+
uses: joelanford/[email protected].3
2525
with:
2626
compare-imports: true
2727
print-compatible: true

.github/workflows/go.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,26 @@ jobs:
2525
doc:
2626
- 'site/**'
2727
28+
check-modules:
29+
name: check-synced-go-modules
30+
needs: conditional-changes
31+
# if: needs.conditional-changes.outputs.doc == 'false'
32+
runs-on: [ubuntu-latest]
33+
steps:
34+
- name: Check out code into the Go module directory
35+
uses: actions/checkout@v4
36+
with:
37+
fetch-depth: 0
38+
- name: Set up Go 1.x
39+
uses: actions/setup-go@v5
40+
with:
41+
go-version-file: go.work
42+
id: go
43+
- name: sync go modules
44+
run: make workspace-sync
45+
- name: check for changes with 'make workspace-sync'
46+
run: git diff --exit-code
47+
2848
lint:
2949
name: Lint
3050
needs: conditional-changes

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ site/.hugo_build.lock
3131

3232
# goreleaser artifacts
3333
**/dist/
34+
/output/

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ linters:
99
enable-all: true
1010
disable:
1111
- cyclop
12+
- depguard
1213
- exhaustivestruct
1314
- forbidigo
1415
- funlen
@@ -24,7 +25,9 @@ linters:
2425
- nlreturn
2526
- noctx
2627
- paralleltest
28+
- perfsprint
2729
- stylecheck
30+
- testifylint
2831
- varnamelen
2932
- wsl
3033
- exhaustruct

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Makefile for kustomize CLI and API.
55

6-
LATEST_RELEASE=v5.5.0
6+
LATEST_RELEASE=v5.7.0
77

88
SHELL := /usr/bin/env bash
99
GOOS = $(shell go env GOOS)

OWNERS_ALIASES

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ aliases:
2020
docs-reviewers:
2121
- ncapps
2222

23-
commands-approvers:
24-
- stormqueen1990
23+
commands-approvers: []
2524
commands-reviewers:
2625
- stormqueen1990
2726

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,18 @@ kustomization.yaml deployment.yaml
7676
+---------------------------------------------+ +-------------------------------------------------------+ +-----------------------------------+
7777
| apiVersion: kustomize.config.k8s.io/v1beta1 | | apiVersion: apps/v1 | | apiVersion: v1 |
7878
| kind: Kustomization | | kind: Deployment | | kind: Service |
79-
| commonLabels: | | metadata: | | metadata: |
80-
| app: myapp | | name: myapp | | name: myapp |
81-
| resources: | | spec: | | spec: |
82-
| - deployment.yaml | | selector: | | selector: |
83-
| - service.yaml | | matchLabels: | | app: myapp |
84-
| configMapGenerator: | | app: myapp | | ports: |
85-
| - name: myapp-map | | template: | | - port: 6060 |
86-
| literals: | | metadata: | | targetPort: 6060 |
87-
| - KEY=value | | labels: | +-----------------------------------+
88-
+---------------------------------------------+ | app: myapp |
89-
| spec: |
90-
| containers: |
79+
| labels: | | metadata: | | metadata: |
80+
| - includeSelectors: true | | name: myapp | | name: myapp |
81+
| pairs: | | spec: | | spec: |
82+
| app: myapp | | selector: | | selector: |
83+
| resources: | | matchLabels: | | app: myapp |
84+
| - deployment.yaml | | app: myapp | | ports: |
85+
| - service.yaml | | template: | | - port: 6060 |
86+
| configMapGenerator: | | metadata: | | targetPort: 6060 |
87+
| - name: myapp-map | | labels: | +-----------------------------------+
88+
| literals: | | app: myapp |
89+
| - KEY=value | | spec: |
90+
+---------------------------------------------+ | containers: |
9191
| - name: myapp |
9292
| image: myapp |
9393
| resources: |
@@ -142,16 +142,16 @@ kustomization.yaml replica_count.yaml
142142
+-----------------------------------------------+ +-------------------------------+ +------------------------------------------+
143143
| apiVersion: kustomize.config.k8s.io/v1beta1 | | apiVersion: apps/v1 | | apiVersion: apps/v1 |
144144
| kind: Kustomization | | kind: Deployment | | kind: Deployment |
145-
| commonLabels: | | metadata: | | metadata: |
146-
| variant: prod | | name: myapp | | name: myapp |
147-
| resources: | | spec: | | spec: |
148-
| - ../../base | | replicas: 80 | | template: |
149-
| patches: | +-------------------------------+ | spec: |
150-
| - path: replica_count.yaml | | containers: |
151-
| - path: cpu_count.yaml | | - name: myapp |
152-
+-----------------------------------------------+ | resources: |
153-
| limits: |
154-
| memory: "128Mi" |
145+
| labels: | | metadata: | | metadata: |
146+
| - includeSelectors: true | | name: myapp | | name: myapp |
147+
| pairs: | | spec: | | spec: |
148+
| variant: prod | | replicas: 80 | | template: |
149+
| resources: | +-------------------------------+ | spec: |
150+
| - ../../base | | containers: |
151+
| patches: | | - name: myapp |
152+
| - path: replica_count.yaml | | resources: |
153+
| - path: cpu_count.yaml | | limits: |
154+
+-----------------------------------------------+ | memory: "128Mi" |
155155
| cpu: "7000m" |
156156
+------------------------------------------+
157157
```

api/filters/imagetag/imagetag_test.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,84 @@ spec:
879879
},
880880
},
881881
},
882+
"update image volume in pod template": {
883+
input: `
884+
group: apps
885+
apiVersion: v1
886+
kind: Deployment
887+
metadata:
888+
name: imagevolume
889+
spec:
890+
template:
891+
spec:
892+
volumes:
893+
- name: volume
894+
image:
895+
reference: nginx
896+
`,
897+
expectedOutput: `
898+
group: apps
899+
apiVersion: v1
900+
kind: Deployment
901+
metadata:
902+
name: imagevolume
903+
spec:
904+
template:
905+
spec:
906+
volumes:
907+
- name: volume
908+
image:
909+
reference: apache@12345
910+
`,
911+
filter: Filter{
912+
ImageTag: types.Image{
913+
Name: "nginx",
914+
NewName: "apache",
915+
Digest: "12345",
916+
},
917+
},
918+
fsSlice: []types.FieldSpec{
919+
{
920+
Path: "spec/template/spec/volumes[]/image/reference",
921+
},
922+
},
923+
},
924+
"update image volume in pod spec": {
925+
input: `
926+
apiVersion: v1
927+
kind: Pod
928+
metadata:
929+
name: imagevolume
930+
spec:
931+
volumes:
932+
- name: volume
933+
image:
934+
reference: nginx
935+
`,
936+
expectedOutput: `
937+
apiVersion: v1
938+
kind: Pod
939+
metadata:
940+
name: imagevolume
941+
spec:
942+
volumes:
943+
- name: volume
944+
image:
945+
reference: apache@12345
946+
`,
947+
filter: Filter{
948+
ImageTag: types.Image{
949+
Name: "nginx",
950+
NewName: "apache",
951+
Digest: "12345",
952+
},
953+
},
954+
fsSlice: []types.FieldSpec{
955+
{
956+
Path: "spec/volumes[]/image/reference",
957+
},
958+
},
959+
},
882960
}
883961

884962
for tn, tc := range testCases {

api/filters/replacement/replacement.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type Filter struct {
2323
// Filter replaces values of targets with values from sources
2424
func (f Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
2525
for i, r := range f.Replacements {
26-
if r.Source == nil || r.Targets == nil {
26+
if (r.SourceValue == nil && r.Source == nil) || r.Targets == nil {
2727
return nil, fmt.Errorf("replacements must specify a source and at least one target")
2828
}
2929
value, err := getReplacement(nodes, &f.Replacements[i])
@@ -39,6 +39,13 @@ func (f Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
3939
}
4040

4141
func getReplacement(nodes []*yaml.RNode, r *types.Replacement) (*yaml.RNode, error) {
42+
if r.SourceValue != nil && r.Source != nil {
43+
return nil, fmt.Errorf("value and resource selectors are mutually exclusive")
44+
}
45+
if r.SourceValue != nil {
46+
return yaml.NewScalarRNode(*r.SourceValue), nil
47+
}
48+
4249
source, err := selectSourceNode(nodes, r.Source)
4350
if err != nil {
4451
return nil, err
@@ -192,14 +199,14 @@ func copyValueToTarget(target *yaml.RNode, value *yaml.RNode, selector *types.Ta
192199
Path: kyaml_utils.SmarterPathSplitter(fp, "."),
193200
Create: createKind})
194201
if err != nil {
195-
return errors.WrapPrefixf(err, fieldRetrievalError(fp, createKind != 0))
202+
return errors.WrapPrefixf(err, fieldRetrievalError(fp, createKind != 0)) //nolint:govet
196203
}
197204
targetFields, err := targetFieldList.Elements()
198205
if err != nil {
199-
return errors.WrapPrefixf(err, fieldRetrievalError(fp, createKind != 0))
206+
return errors.WrapPrefixf(err, fieldRetrievalError(fp, createKind != 0)) //nolint:govet
200207
}
201208
if len(targetFields) == 0 {
202-
return errors.Errorf(fieldRetrievalError(fp, createKind != 0))
209+
return errors.Errorf(fieldRetrievalError(fp, createKind != 0)) //nolint:govet
203210
}
204211

205212
for _, t := range targetFields {

api/filters/replacement/replacement_test.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2829,6 +2829,70 @@ spec:
28292829
create: true
28302830
`,
28312831
expectedErr: "unable to find or create field \"spec.tls.5.hosts.5\" in replacement target: index 5 specified but only 0 elements found",
2832+
}, "replace with static value": {
2833+
input: `apiVersion: v1
2834+
kind: Deployment
2835+
metadata:
2836+
name: deploy
2837+
spec:
2838+
template:
2839+
spec:
2840+
containers:
2841+
- image: nginx:1.7.9
2842+
name: nginx-tagged
2843+
- image: postgres:1.8.0
2844+
name: postgresdb
2845+
`,
2846+
replacements: `replacements:
2847+
- sourceValue: custom/postgres:1.9.0
2848+
targets:
2849+
- select:
2850+
kind: Deployment
2851+
name: deploy
2852+
fieldPaths:
2853+
- spec.template.spec.containers.[name=postgresdb].image
2854+
`,
2855+
expected: `apiVersion: v1
2856+
kind: Deployment
2857+
metadata:
2858+
name: deploy
2859+
spec:
2860+
template:
2861+
spec:
2862+
containers:
2863+
- image: nginx:1.7.9
2864+
name: nginx-tagged
2865+
- image: custom/postgres:1.9.0
2866+
name: postgresdb
2867+
`,
2868+
}, "source value and selector error": {
2869+
input: `apiVersion: v1
2870+
kind: Deployment
2871+
metadata:
2872+
name: deploy
2873+
spec:
2874+
replicas: 1
2875+
template:
2876+
spec:
2877+
containers:
2878+
- image: nginx:1.7.9
2879+
name: nginx-tagged
2880+
- image: postgres:1.8.0
2881+
name: postgresdb
2882+
`,
2883+
replacements: `replacements:
2884+
- source:
2885+
kind: Deployment
2886+
name: deploy
2887+
sourceValue: 2
2888+
targets:
2889+
- select:
2890+
kind: Deployment
2891+
name: deploy
2892+
fieldPaths:
2893+
- spec.replicas
2894+
`,
2895+
expectedErr: "value and resource selectors are mutually exclusive",
28322896
},
28332897
}
28342898

0 commit comments

Comments
 (0)