You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/policygenerator.md
+31-35Lines changed: 31 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,50 +75,46 @@ DIRECTORY TREE PACKAGE DESCRIPTION
75
75
├── typohelper.go internal Helpers for identifying manifest typos
76
76
├── utils.go internal Helper/utility functions
77
77
```
78
-
## Openapi schema support
79
-
policy-genenerator-plugin supports openapi schemas as defined in https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/openapi by Kustomize. The goal of this feature is to support patching non kubernetest CR objects that contain list of objects.
80
-
The openapi object in this project has the same format of the openapi object in the kustomize project. The Path indicates the relative path of the schema json file relative to the kustomization.yaml file
81
-
```yaml
78
+
79
+
## OpenAPI schema support
80
+
The Policy Generator supports OpenAPI schemas as defined in
81
+
https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/openapi by Kustomize. The goal of this feature is
82
+
to support patching non-Kubernetes custom resource objects that contain list of objects. The OpenAPI object in this
83
+
project has the same format of the OpenAPI object in the Kustomize project. The path indicates the relative path of the
84
+
schema JSON file relative to the `kustomization.yaml` file:
85
+
```yaml
82
86
openapi:
83
-
path: schema.json
87
+
path: schema.json
84
88
```
85
-
The openapi object is part of the manifest object in the plugin file:
86
-
```yaml
89
+
The OpenAPI object is included with the manifest object in the plugin file:
90
+
```yaml
87
91
apiVersion: policy.open-cluster-management.io/v1
88
92
kind: PolicyGenerator
89
-
...
93
+
. . .
90
94
policies:
91
-
- name: myapp
92
-
manifests:
93
-
- path: input-kustomize/
94
-
patches:
95
-
openapi:
96
-
path: schema.json
95
+
- name: myapp
96
+
manifests:
97
+
- path: input-kustomize/
98
+
patches:[]
99
+
openapi:
100
+
path: schema.json
97
101
```
98
102
### How to create a Kustomize schema manually
99
-
Ideally the openapi schema should be provided by the developper of the Custom Resource (CR).
100
-
To retrieve a schema from a running kubernetes cluster manually, do the following:
101
-
102
-
```default
103
+
Ideally the OpenAPI schema is provided by the developper of the Custom Resource (CR). To retrieve a schema from a
104
+
running Kubernetes cluster manually, do the following:
105
+
```shell
103
106
kustomize openapi fetch
104
107
```
105
-
106
108
Then cut and paste the subset containing the resources that need to be patched.
107
-
108
-
Next, identify the list objects in the schema and select a key from the fields
109
-
of the object that would be use to index the list, for instance a name. After
110
-
the definition of the list, add the following text:
111
-
112
-
```default
113
-
"x-kubernetes-patch-merge-key": "name",
114
-
"x-kubernetes-patch-strategy": "merge"
109
+
Next, identify the list objects in the schema and select a key from the fields of the object that would be use to index
110
+
the list, for instance a name. After the definition of the list, add the following text:
111
+
```yaml
112
+
"x-kubernetes-patch-merge-key": "name",
113
+
"x-kubernetes-patch-strategy": "merge"
115
114
```
116
-
117
-
`x-kubernetes-patch-merge-key` indicates the field in the object that is used to
118
-
uniquely identify it in the list in this case the `name` field
119
-
`x-kubernetes-patch-strategy` indicates the patch strategy. Merge would merge
120
-
fields, replace would replace the object identified by the key with patch
121
-
content.
115
+
`x-kubernetes-patch-merge-key` indicates the field in the object that is used to uniquely identify it in the list in
116
+
this case the `name` field. `x-kubernetes-patch-strategy` indicates the patch strategy. Merge would merge fields,
117
+
replace would replace the object identified by the key with patch content.
122
118
`Note:`The "key" selected in this step is used in patches to uniquely identify a list object.
123
-
124
-
An example of schema for the ptp-operator PtpConfig CR is shown at [link](internal/testdata/OpenAPI/newptpconfig-schema.json)
0 commit comments