Skip to content

Commit

Permalink
feat: add vap v1beta1 support
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 Sep 22, 2023
1 parent da1586c commit 5a4a8f5
Show file tree
Hide file tree
Showing 8 changed files with 914 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ codegen-schema-openapi: $(KIND) $(HELM) ## Generate openapi schemas (v2 and v3)
@kubectl get --raw /openapi/v3/apis/kyverno.io/v2beta1 > ./schemas/openapi/v3/apis/kyverno.io/v2beta1.json
@kubectl get --raw /openapi/v3/apis/kyverno.io/v2alpha1 > ./schemas/openapi/v3/apis/kyverno.io/v2alpha1.json
@kubectl get --raw /openapi/v3/apis/admissionregistration.k8s.io/v1alpha1 > ./schemas/openapi/v3/apis/admissionregistration.k8s.io/v1alpha1.json
@kubectl get --raw /openapi/v3/apis/admissionregistration.k8s.io/v1beta1 > ./schemas/openapi/v3/apis/admissionregistration.k8s.io/v1beta1.json
@$(KIND) delete cluster --name schema

.PHONY: codegen-schema-json
Expand Down Expand Up @@ -188,13 +189,14 @@ build-frontend: ## Build frontend
@cp schemas/json/policy-kyverno-v2beta1.json frontend/src/schemas
@cp schemas/json/policyexception-kyverno-v2alpha1.json frontend/src/schemas
@cp schemas/json/validatingadmissionpolicy-admissionregistration-v1alpha1.json frontend/src/schemas
@cp schemas/json/validatingadmissionpolicy-admissionregistration-v1beta1.json frontend/src/schemas
@cd frontend && npm install && APP_VERSION=$(APP_VERSION) npm run build

.PHONY: build-backend-assets
build-backend-assets: build-frontend ## Build backend assets
@echo Building backend assets... >&2
@rm -rf backend/pkg/server/ui/dist && cp -r frontend/dist backend/pkg/server/ui/dist
@rm -rf backend/data/schemas && cp -r schemas/openapi/v3 backend/data/schemas
@rm -rf backend/data/schemas && mkdir -p backend/data/schemas/apis/kyverno.io && cp -r schemas/openapi/v3/apis/kyverno.io backend/data/schemas/apis/kyverno.io

.PHONY: docker-build-backend-assets
docker-build-backend-assets:
Expand Down

This file was deleted.

4 changes: 3 additions & 1 deletion backend/pkg/policy/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/resource/convert"
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/resource/loader"
"k8s.io/api/admissionregistration/v1alpha1"
"k8s.io/api/admissionregistration/v1beta1"
"k8s.io/apimachinery/pkg/runtime/schema"
)

Expand All @@ -18,6 +19,7 @@ var (
clusterPolicyV1 = schema.GroupVersion(kyvernov1.GroupVersion).WithKind("ClusterPolicy")
clusterPolicyV2 = schema.GroupVersion(kyvernov2beta1.GroupVersion).WithKind("ClusterPolicy")
vapV1alpha1 = v1alpha1.SchemeGroupVersion.WithKind("ValidatingAdmissionPolicy")
vapV1beta1 = v1beta1.SchemeGroupVersion.WithKind("ValidatingAdmissionPolicy")
)

func Load(l loader.Loader, content []byte) ([]kyvernov1.PolicyInterface, []v1alpha1.ValidatingAdmissionPolicy, error) {
Expand All @@ -42,7 +44,7 @@ func Load(l loader.Loader, content []byte) ([]kyvernov1.PolicyInterface, []v1alp
return nil, nil, err
}
policies = append(policies, typed)
case vapV1alpha1:
case vapV1alpha1, vapV1beta1:
typed, err := convert.To[v1alpha1.ValidatingAdmissionPolicy](object)
if err != nil {
return nil, nil, err
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 5a4a8f5

Please sign in to comment.