Merge pull request #4112 from natasha41575/updateOpenAPI

update openapi to v1.21.2
This commit is contained in:
Kubernetes Prow Robot
2021-08-10 10:44:40 -07:00
committed by GitHub
7 changed files with 5820 additions and 1319 deletions

View File

@@ -230,3 +230,92 @@ spec:
name: configmap-in-base
`)
}
func TestPathWithCronJobV1(t *testing.T) {
th := kusttest_test.MakeHarness(t)
th.WriteK(".", `
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- resources.yaml
patches:
- patch: |
apiVersion: batch/v1
kind: CronJob
metadata:
name: test
spec:
jobTemplate:
spec:
template:
spec:
containers:
- name: test
env:
- name: ENV_NEW
value: val_new
target:
kind: CronJob
name: test
`)
th.WriteF("resources.yaml", `
apiVersion: batch/v1
kind: CronJob
metadata:
name: test
spec:
schedule: "5 10 * * 1"
concurrencyPolicy: Forbid
jobTemplate:
spec:
backoffLimit: 3
template:
spec:
restartPolicy: Never
containers:
- name: test
image: bash
command:
- /bin/sh
- -c
- echo "test"
env:
- name: ENV1
value: val1
- name: ENV2
value: val2
- name: ENV3
value: val3`)
m := th.Run(".", th.MakeDefaultOptions())
th.AssertActualEqualsExpected(m, `
apiVersion: batch/v1
kind: CronJob
metadata:
name: test
spec:
concurrencyPolicy: Forbid
jobTemplate:
spec:
backoffLimit: 3
template:
spec:
containers:
- command:
- /bin/sh
- -c
- echo "test"
env:
- name: ENV_NEW
value: val_new
- name: ENV1
value: val1
- name: ENV2
value: val2
- name: ENV3
value: val3
image: bash
name: test
restartPolicy: Never
schedule: 5 10 * * 1
`)
}

View File

@@ -131,7 +131,7 @@ func TestCustomOpenApiFieldBothPathAndVersion(t *testing.T) {
resources:
- mycrd.yaml
openapi:
version: v1.20.4
version: v1.21.2
path: mycrd_schema.json
`+customSchemaPatch)
writeCustomResource(th, "mycrd.yaml")
@@ -217,7 +217,7 @@ openapi:
resources:
- ../base
openapi:
version: v1.20.4
version: v1.21.2
`+customSchemaPatch)
writeCustomResource(th, "base/mycrd.yaml")
writeTestSchema(th, "base/")
@@ -235,7 +235,7 @@ spec:
- image: nginx
name: server
`)
assert.Equal(t, "v1204", openapi.GetSchemaVersion())
assert.Equal(t, "v1212", openapi.GetSchemaVersion())
}
func TestCustomOpenAPIFieldFromComponent(t *testing.T) {

View File

@@ -16,7 +16,7 @@ func TestOpenApiFieldBasicUsage(t *testing.T) {
th := kusttest_test.MakeHarness(t)
th.WriteK(".", `
openapi:
version: v1.20.4
version: v1.21.2
resources:
- deployment.yaml
`)
@@ -44,7 +44,8 @@ spec:
containers:
- image: whatever
`)
assert.Equal(t, "v1204", openapi.GetSchemaVersion())
assert.Equal(t, "v1212", openapi.GetSchemaVersion())
openapi.ResetOpenAPI()
}
func TestOpenApiFieldNotBuiltin(t *testing.T) {
@@ -71,6 +72,7 @@ spec:
if err == nil {
t.Fatalf("expected an error")
}
openapi.ResetOpenAPI()
}
func TestOpenApiFieldDefaultVersion(t *testing.T) {
@@ -104,4 +106,5 @@ spec:
- image: whatever
`)
assert.Equal(t, kubernetesapi.DefaultOpenAPI, openapi.GetSchemaVersion())
openapi.ResetOpenAPI()
}

View File

@@ -6,13 +6,13 @@
package kubernetesapi
import (
"sigs.k8s.io/kustomize/kyaml/openapi/kubernetesapi/v1204"
"sigs.k8s.io/kustomize/kyaml/openapi/kubernetesapi/v1212"
)
const Info = "{title:Kubernetes,version:v1.20.4}"
const Info = "{title:Kubernetes,version:v1.21.2}"
var OpenAPIMustAsset = map[string]func(string) []byte{
"v1204": v1204.MustAsset,
var OpenAPIMustAsset = map[string]func(string)[]byte{
"v1212": v1212.MustAsset,
}
const DefaultOpenAPI = "v1204"
const DefaultOpenAPI = "v1212"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long