Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KOGITO-7840] - Add validation on Workflow Metadata with admission we… #239

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ci/jenkins/Jenkinsfile.promote
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ pipeline {
withCredentials([usernamePassword(credentialsId: helper.getGitAuthorCredsID(), usernameVariable: 'GH_USER', passwordVariable: 'GH_TOKEN')]) {
sh """
gh release upload ${helper.getGitTag()} "operator.yaml"
gh release upload ${helper.getGitTag()} "operator-no-webhooks.yaml"
"""
}
}
Expand Down
51 changes: 37 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ help: ## Display this help.
manifests: generate ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:allowDangerousTypes=true webhook paths="./api/..." paths="./controllers/..." output:crd:artifacts:config=config/crd/bases

.PHONY: manifests-crd-no-webhooks
manifests-crd-no-webhooks: generate ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:allowDangerousTypes=true webhook paths="./api/..." paths="./controllers/..." output:crd:artifacts:config=config/crd-no-webhooks/bases

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./api/..." paths="./container-builder/api/..."
Expand All @@ -119,7 +123,7 @@ test: manifests generate envtest vet fmt test-api ## Run tests.

.PHONY: test-api
test-api:
cd api && make test
cd api && make test KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)"

.PHONY: test-container-builder
test-container-builder:
Expand All @@ -139,9 +143,10 @@ build: generate ## Build manager binary.
build-4-debug: generate ## Build manager binary with debug options.
go build -gcflags="all=-N -l" -o bin/manager main.go

ENABLE_WEBHOOKS ?= false
.PHONY: run
run: manifests generate ## Run a controller from your host.
go run ./main.go
ENABLE_WEBHOOKS=${ENABLE_WEBHOOKS} go run ./main.go

.PHONY: debug
debug: build-4-debug ## Run a controller from your host from binary
Expand All @@ -159,6 +164,10 @@ podman-build: test ## Build container image with the manager.
docker-push: ## Push docker image with the manager.
docker push ${IMG}

.PHONY: podman-push
podman-push: ## Push container image with the manager.
podman push ${PODMAN_PUSH_PARAMS} ${IMG}

# This is currently done directly into the CI
# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
Expand All @@ -177,10 +186,6 @@ docker-buildx: test ## Build and push docker image for the manager for cross-pla
- docker buildx rm project-v3-builder
rm Dockerfile.cross

.PHONY: podman-push
podman-push: ## Push container image with the manager.
podman push ${PODMAN_PUSH_PARAMS} ${IMG}

.PHONY: container-build
container-build: test ## Build the container image
cekit -v --descriptor image.yaml build ${build_options} $(BUILDER)
Expand All @@ -202,24 +207,34 @@ endif
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl create -f -

.PHONY: install-no-webhooks
install-no-webhooks: manifests-crd-no-webhooks kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd-no-webhooks | kubectl apply -f -

.PHONY: uninstall
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: deploy
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
deploy: manifests kustomize install-cert-manager ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default | kubectl create -f -

.PHONY: generate-deploy
generate-deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
.PHONY: deploy-no-webhooks
deploy-no-webhooks: manifests-crd-no-webhooks kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default > operator.yaml
$(KUSTOMIZE) build config/default-no-webhooks | kubectl apply -f -

.PHONY: undeploy
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
undeploy: uninstall-cert-manager ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: generate-deploy
generate-deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default > operator.yaml
$(KUSTOMIZE) build config/default-no-webhooks > operator-no-webhooks.yaml

##@ Build Dependencies

## Location to install dependencies to
Expand Down Expand Up @@ -265,7 +280,7 @@ bundle-build: ## Build the bundle image.

.PHONY: bundle-push
bundle-push: ## Push the bundle image.
$(MAKE) contianer-push IMG=$(BUNDLE_IMG)
$(MAKE) container-push IMG=$(BUNDLE_IMG)

.PHONY: opm
OPM = ./bin/opm
Expand Down Expand Up @@ -330,7 +345,15 @@ generate-all: generate generate-deploy bundle addheaders vet fmt

.PHONY: test-e2e # You will need to have a Minikube/Kind cluster up in running to run this target, and run container-builder before the test
test-e2e: install-operator-sdk
go test ./test/e2e/* -v -ginkgo.v
go test -timeout=20m ./test/e2e/* -v -ginkgo.v

.PHONY: before-pr
before-pr: test generate-all
before-pr: test generate-all

.PHONY: install-cert-manager
install-cert-manager:
./hack/local/cert-manager.sh install

.PHONY: uninstall-cert-manager
uninstall-cert-manager:
./hack/local/cert-manager.sh uninstall
4 changes: 4 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ resources:
kind: SonataFlow
path: github.com/kiegroup/kogito-serverless-operator/api/v1alpha08
version: v1alpha08
webhooks:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
Expand Down
2 changes: 1 addition & 1 deletion api/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.PHONY: test
test:
go test $(shell go list ./... | grep -v /test/) -coverprofile cover.out
KUBEBUILDER_ASSETS=${KUBEBUILDER_ASSETS} go test $(shell go list ./... | grep -v /test/) -coverprofile cover.out
13 changes: 9 additions & 4 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ go 1.19

require (
github.com/serverlessworkflow/sdk-go/v2 v2.2.4
github.com/onsi/ginkgo/v2 v2.9.5
github.com/onsi/gomega v1.27.7
k8s.io/api v0.27.2
k8s.io/apimachinery v0.27.2
k8s.io/client-go v0.27.2
k8s.io/klog/v2 v2.100.1
knative.dev/pkg v0.0.0-20230525143525-9bda38b21643
sigs.k8s.io/controller-runtime v0.15.0
sigs.k8s.io/yaml v1.3.0
Expand All @@ -20,18 +24,21 @@ require (
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand All @@ -52,25 +59,23 @@ require (
github.com/stretchr/testify v1.8.2 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.9.1 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.27.2 // indirect
k8s.io/client-go v0.27.2 // indirect
k8s.io/component-base v0.27.2 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
Loading