Skip to content

Commit

Permalink
chore: generate openapi and json schemas
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
  • Loading branch information
eddycharly committed Oct 10, 2023
1 parent 88cbfdf commit b4cc07c
Show file tree
Hide file tree
Showing 495 changed files with 407,055 additions and 2 deletions.
35 changes: 33 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ DEEPCOPY_GEN := $(TOOLS_DIR)/deepcopy-gen
CODE_GEN_VERSION := v0.28.0
REFERENCE_DOCS := $(TOOLS_DIR)/genref
REFERENCE_DOCS_VERSION := latest
TOOLS := $(CONTROLLER_GEN) $(REGISTER_GEN) $(DEEPCOPY_GEN) $(REFERENCE_DOCS)
KIND := $(TOOLS_DIR)/kind
KIND_VERSION := v0.20.0
TOOLS := $(CONTROLLER_GEN) $(REGISTER_GEN) $(DEEPCOPY_GEN) $(REFERENCE_DOCS) $(KIND)
PIP ?= "pip"
ifeq ($(GOOS), darwin)
SED := gsed
else
Expand All @@ -36,6 +39,10 @@ $(REFERENCE_DOCS):
@echo Install genref... >&2
@GOBIN=$(TOOLS_DIR) go install github.com/kubernetes-sigs/reference-docs/genref@$(REFERENCE_DOCS_VERSION)

$(KIND):
@echo Install kind... >&2
@GOBIN=$(TOOLS_DIR) go install sigs.k8s.io/kind@$(KIND_VERSION)

.PHONY: install-tools
install-tools: $(TOOLS) ## Install tools

Expand Down Expand Up @@ -83,6 +90,7 @@ GOPATH_SHIM := ${PWD}/.gopath
PACKAGE_SHIM := $(GOPATH_SHIM)/src/$(PACKAGE)
INPUT_DIRS := $(PACKAGE)/pkg/apis/v1alpha1
CRDS_PATH := ${PWD}/config/crds
KIND_IMAGE ?= kindest/node:v1.28.0

$(GOPATH_SHIM):
@echo Create gopath shim... >&2
Expand Down Expand Up @@ -158,8 +166,31 @@ codegen-mkdocs: codegen-docs ## Generate mkdocs website
@rm -rf ./website/docs/jp && mkdir -p ./website/docs/jp && cp docs/user/jp/* ./website/docs/jp
@mkdocs build -f ./website/mkdocs.yaml


.PHONY: codegen-schema-openapi
codegen-schema-openapi: $(KIND) $(HELM) ## Generate openapi schemas (v2 and v3)
@echo Generate openapi schema... >&2
@rm -rf ./schemas
@mkdir -p ./schemas/openapi/v2
@mkdir -p ./schemas/openapi/v3/apis/json.kyverno.io
@$(KIND) create cluster --name schema --image $(KIND_IMAGE)
@kubectl create -f ./config/crds
@sleep 15
@kubectl get --raw /openapi/v2 > ./schemas/openapi/v2/schema.json
@kubectl get --raw /openapi/v3/apis/json.kyverno.io/v1alpha1 > ./schemas/openapi/v3/apis/json.kyverno.io/v1alpha1.json
@$(KIND) delete cluster --name schema

.PHONY: codegen-schema-json
codegen-schema-json: codegen-schema-openapi ## Generate json schemas
@$(PIP) install openapi2jsonschema
@rm -rf ./schemas/json
@openapi2jsonschema ./schemas/openapi/v2/schema.json --kubernetes --stand-alone --expanded -o ./schemas/json

.PHONY: codegen-schema-all
codegen-schema-all: codegen-schema-openapi codegen-schema-json ## Generate openapi and json schemas

.PHONY: codegen-all
codegen-all: codegen-crds codegen-deepcopy codegen-register codegen-docs codegen-mkdocs ## Rebuild all generated code and docs
codegen-all: codegen-crds codegen-deepcopy codegen-register codegen-docs codegen-mkdocs codegen-schema-all ## Rebuild all generated code and docs

.PHONY: verify-codegen
verify-codegen: codegen-all ## Verify all generated code and docs are up to date
Expand Down
16,694 changes: 16,694 additions & 0 deletions schemas/json/_definitions.json

Large diffs are not rendered by default.

975 changes: 975 additions & 0 deletions schemas/json/affinity-v1.json

Large diffs are not rendered by default.

78 changes: 78 additions & 0 deletions schemas/json/aggregationrule-rbac-v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"description": "AggregationRule describes how to locate ClusterRoles to aggregate into the ClusterRole",
"type": "object",
"properties": {
"clusterRoleSelectors": {
"description": "ClusterRoleSelectors holds a list of selectors which will be used to find ClusterRoles and create the rules. If any of the selectors match, then the ClusterRole's permissions will be added",
"type": [
"array",
"null"
],
"items": {
"description": "A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.",
"type": [
"object",
"null"
],
"properties": {
"matchExpressions": {
"description": "matchExpressions is a list of label selector requirements. The requirements are ANDed.",
"type": [
"array",
"null"
],
"items": {
"description": "A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.",
"type": [
"object",
"null"
],
"required": [
"key",
"operator"
],
"properties": {
"key": {
"description": "key is the label key that the selector applies to.",
"type": "string"
},
"operator": {
"description": "operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.",
"type": "string"
},
"values": {
"description": "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.",
"type": [
"array",
"null"
],
"items": {
"type": [
"string",
"null"
]
}
}
}
}
},
"matchLabels": {
"description": "matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is \"key\", the operator is \"In\", and the values array contains only \"value\". The requirements are ANDed.",
"type": [
"object",
"null"
],
"additionalProperties": {
"type": [
"string",
"null"
]
}
}
},
"x-kubernetes-map-type": "atomic"
}
}
},
"$schema": "http://json-schema.org/schema#"
}
Loading

0 comments on commit b4cc07c

Please sign in to comment.