Skip to content

Commit 5cd69cd

Browse files
author
Tatz Sekine
committed
revert all unintended changes, caused by some git operation mistakes
1 parent 4ef77e1 commit 5cd69cd

File tree

15 files changed

+52
-433
lines changed

15 files changed

+52
-433
lines changed

api/krusty/openapicustomschema_test.go

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -643,58 +643,3 @@ spec:
643643
assert.Equal(t, kubernetesapi.DefaultOpenAPI, openapi.GetSchemaVersion())
644644
})
645645
}
646-
647-
// Test for issue #5878
648-
func TestCustomOpenApiFieldWithoutMergePatchExtension(t *testing.T) {
649-
runOpenApiTest(t, func(t *testing.T) {
650-
t.Helper()
651-
th := kusttest_test.MakeHarness(t)
652-
writeTestSchema(th, "./")
653-
th.WriteF("yetanothercrd_base.yaml", `
654-
apiVersion: example.com/v1alpha1
655-
kind: MyCRD
656-
metadata:
657-
name: service
658-
spec:
659-
custom:
660-
objects:
661-
- name: foo
662-
value: foo
663-
- name: bar
664-
value: bar
665-
`)
666-
th.WriteF("yetanothercrd_patch.yaml", `
667-
apiVersion: example.com/v1alpha1
668-
kind: MyCRD
669-
metadata:
670-
name: service
671-
spec:
672-
custom:
673-
objects:
674-
- name: bar
675-
value: patched
676-
`)
677-
th.WriteK(".", `
678-
resources:
679-
- yetanothercrd_base.yaml
680-
openapi:
681-
path: mycrd_schema.json
682-
patches:
683-
- path: yetanothercrd_patch.yaml
684-
`)
685-
m := th.Run(".", th.MakeDefaultOptions())
686-
th.AssertActualEqualsExpected(m, `
687-
apiVersion: example.com/v1alpha1
688-
kind: MyCRD
689-
metadata:
690-
name: service
691-
spec:
692-
custom:
693-
objects:
694-
- name: bar
695-
value: patched
696-
- name: foo
697-
value: foo
698-
`)
699-
})
700-
}

api/krusty/testdata/customschema.json

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@
1515
"properties": {
1616
"template": {
1717
"$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec"
18-
},
19-
"custom": {
20-
"$ref": "#/definitions/com.example.v1alpha1.CustomSpec"
2118
}
2219
},
2320
"type": "object"
2421
},
2522
"status": {
26-
"properties": {
23+
"properties": {
2724
"success": {
2825
"type": "boolean"
2926
}
@@ -92,7 +89,7 @@
9289
"type": "string"
9390
},
9491
"ports": {
95-
"items": {
92+
"items": {
9693
"$ref": "#/definitions/io.k8s.api.core.v1.ContainerPort"
9794
},
9895
"type": "array",
@@ -108,7 +105,7 @@
108105
"type": "object"
109106
},
110107
"io.k8s.api.core.v1.ContainerPort": {
111-
"properties": {
108+
"properties": {
112109
"containerPort": {
113110
"format": "int32",
114111
"type": "integer"
@@ -121,27 +118,6 @@
121118
}
122119
},
123120
"type": "object"
124-
},
125-
"com.example.v1alpha1.CustomSpec": {
126-
"properties": {
127-
"objects": {
128-
"items": {
129-
"properties": {
130-
"name": {
131-
"type": "string"
132-
},
133-
"value": {
134-
"type": "string"
135-
}
136-
}
137-
},
138-
"type": "array",
139-
"x-kubernetes-list-map-keys": [
140-
"name"
141-
],
142-
"x-kubernetes-list-type": "map"
143-
}
144-
}
145121
}
146122
}
147123
}

api/krusty/testdata/customschema.yaml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ definitions:
1111
properties:
1212
template:
1313
"$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec"
14-
custom:
15-
"$ref": "#/definitions/com.example.v1alpha1.CustomSpec"
1614
type: object
1715
status:
1816
properties:
@@ -72,23 +70,9 @@ definitions:
7270
io.k8s.api.core.v1.ContainerPort:
7371
properties:
7472
containerPort:
75-
format: int32
7673
type: integer
7774
name:
7875
type: string
7976
protocol:
8077
type: string
8178
type: object
82-
com.example.v1alpha1.CustomSpec:
83-
properties:
84-
objects:
85-
items:
86-
properties:
87-
name:
88-
type: string
89-
value:
90-
type: string
91-
type: array
92-
x-kubernetes-list-map-keys:
93-
- name
94-
x-kubernetes-list-type: map

examples/customOpenAPIschema.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,24 @@ spec:
3737
EOF
3838
```
3939

40-
This resource has an image field. Let's change its value from server
41-
to nginx with a patch.
40+
This resource has an image field. Let's change its value from server
41+
to nginx with a patch.
4242

4343
Kustomize gets its merge key information from the OpenAPI data
4444
provided by the kubernetes API server. It doesn't have information
45-
about custom resources, so we will have to provide our own
46-
schema file.
45+
about custom resources, so we will have to provide our own
46+
schema file.
4747

4848
Note: CRDs support declarative validation using an OpenAPI v3 schema.
4949
See https://book.kubebuilder.io/reference/generating-crd.html#validation.
5050

5151
You can get an OpenAPI document like this by fetching the OpenAPI
5252
document from your locally favored cluster with the command
5353
`kustomize openapi fetch`. Kustomize will use the OpenAPI extensions
54-
`x-kubernetes-list-map-keys` and `x-kubernetes-list-type` to
55-
perform a strategic merge. `x-kubernetes-list-type` should be set
56-
to "map", and you can set your merge keys to whatever you like. Below,
57-
our custom resource inherits merge keys from `PodTemplateSpec`.
54+
`x-kubernetes-patch-merge-key` and `x-kubernetes-patch-strategy` to
55+
perform a strategic merge. `x-kubernetes-patch-strategy` should be set
56+
to "merge", and you can set your merge key to whatever you like. Below,
57+
our custom resource inherits merge keys from `PodTemplateSpec`.
5858

5959
<!-- @addCustomSchema @testAgainstLatestRelease -->
6060
```
@@ -124,10 +124,6 @@ cat <<EOF >>$DEMO_HOME/mycr_schema.json
124124
"\$ref": "#/definitions/io.k8s.api.core.v1.Container"
125125
},
126126
"type": "array",
127-
"x-kubernetes-list-map-keys": [
128-
"name"
129-
],
130-
"x-kubernetes-list-type": "map",
131127
"x-kubernetes-patch-merge-key": "name",
132128
"x-kubernetes-patch-strategy": "merge"
133129
}

0 commit comments

Comments
 (0)