Skip to content

Commit

Permalink
fix issue with openapi schema from components
Browse files Browse the repository at this point in the history
  • Loading branch information
natasha41575 committed Sep 28, 2021
1 parent f30e45c commit 0d8c107
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 10 additions & 3 deletions api/krusty/openapicustomschema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ openapi:
path: openapi.json
`)

openapi.ResetOpenAPI()
m := th.Run("overlays/overlay-component-openapi", th.MakeDefaultOptions())
th.AssertActualEqualsExpected(m, `apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
Expand All @@ -427,17 +428,23 @@ spec:
template:
spec:
containers:
- name: container
- env:
- name: foo
value: bar
name: container
volumeMounts:
- mountPath: /mnt
name: additional-cm
- mountPath: /opt/cm
name: cm
initContainers:
- name: init
volumes:
- configMap:
name: additional-cm
name: additional-cm
- configMap:
name: cm
name: cm
`)


}
3 changes: 3 additions & 0 deletions kyaml/openapi/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,9 @@ func SetSchema(openAPIField map[string]string, schema []byte, reset bool) error
return nil
}

// if the schema is changed, initSchema should parse the new schema
defer func() { globalSchema.schemaInit = false }()

version, exists := openAPIField["version"]
if exists && schema != nil {
return fmt.Errorf("builtin version and custom schema provided, cannot use both")
Expand Down

0 comments on commit 0d8c107

Please sign in to comment.