Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
feat(crdvalidator): nesting crdvalidator components to better integra…
Browse files Browse the repository at this point in the history
…te with core Rukpak

Signed-off-by: Tyler Slaton <tyslaton@redhat.com>
  • Loading branch information
Tyler Slaton committed Apr 13, 2022
1 parent 58b3f57 commit 6deb19d
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 272 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ WORKDIR /
COPY plain plain
COPY unpack unpack
COPY core core
COPY crdvalidator crdvalidator

EXPOSE 8080
ENTRYPOINT ["/plain"]
37 changes: 7 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ install-apis: cert-mgr generate kustomize ## Install the core rukpak CRDs
install-plain: install-apis ## Install the rukpak CRDs and the plain provisioner
$(KUSTOMIZE) build manifests/provisioners/plain | kubectl apply -f -

install-crdvalidator: cert-mgr kustomize ## Install the crdvalidator webhook manifests to the current cluster.
$(KUSTOMIZE) build manifests/crdvalidator | kubectl apply -f -

install: install-plain ## Install all rukpak core CRDs and provisioners

deploy: install-apis install-crdvalidator ## Deploy the operator to the current cluster
Expand All @@ -122,7 +125,7 @@ cert-mgr: ## Install the certification manager

# Binary builds
VERSION_FLAGS=-ldflags "-X $(VERSION_PATH).GitCommit=$(GIT_COMMIT)"
build: plain unpack core
build: plain unpack core crdvalidator

plain:
CGO_ENABLED=0 go build $(VERSION_FLAGS) -o $(BIN_DIR)/$@ ./internal/provisioner/plain
Expand All @@ -133,6 +136,9 @@ unpack:
core:
CGO_ENABLED=0 go build $(VERSION_FLAGS) -o $(BIN_DIR)/$@ ./cmd/core/...

crdvalidator:
CGO_ENABLED=0 go build $(VERSION_FLAGS) -o $(BIN_DIR)/$@ ./cmd/crdvalidator

build-container: export GOOS=linux
build-container: BIN_DIR:=$(BIN_DIR)/$(GOOS)
build-container: build ## Builds provisioner container image locally
Expand All @@ -159,35 +165,6 @@ kind-load-bundles: ## Load the e2e testdata container images into a kind cluster
kind-load: ## Loads the currently constructed image onto the cluster
${KIND} load docker-image $(IMAGE) --name $(KIND_CLUSTER_NAME)

##################################
# CRDValidator Webhook Targets #
##################################
.PHONY: crdvalidator build-crdvalidator-image kind-load-crdvalidator install-crdvalidator deploy-crdvalidator

##@ crdvalidator:

crdvalidator:
CGO_ENABLED=0 go build $(VERSION_FLAGS) -o $(BIN_DIR)/$@ ./cmd/crdvalidator

CRD_WEBHOOK_IMAGE_REPO=quay.io/operator-framework/crd-validation-webhook
CRD_WEBHOOK_IMAGE=$(CRD_WEBHOOK_IMAGE_REPO):main
build-crdvalidator-image: ## Builds crd-validation-webhook container image locally
docker build -f Dockerfile.crdvalidator -t $(CRD_WEBHOOK_IMAGE) .

kind-load-crdvalidator: ## Loads the currently constructed crd-validation-webhook onto the cluster
${KIND} load docker-image $(CRD_WEBHOOK_IMAGE) --name $(KIND_CLUSTER_NAME)

install-crdvalidator: build-crdvalidator-image kind-load-crdvalidator ## Install the crdvalidator manifests to the current cluster. Requires that cert-manager is installed prior.
kubectl apply -f cmd/crdvalidator/manifests

deploy-crdvalidator: cert-mgr install-crdvalidator ## Install the crdvalidator manifests to the current cluster and ensures that cert-manager is installed prior.

test-crdvalidator-e2e: ginkgo ## Run the crdvalidator e2e tests. Assumes you have already installed the crdvalidator webhook.
$(GINKGO) -trace -progress $(FOCUS) cmd/crdvalidator/test/e2e

crdvalidator-e2e: KIND_CLUSTER_NAME=crdvalidator-e2e
crdvalidator-e2e: kind-cluster deploy-crdvalidator test-crdvalidator-e2e ## Run the crdvalidator e2e tests. Assumes you have already installed the crdvalidator webhook.

################
# Hack / Tools #
################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"net/http"

"github.com/go-logr/logr"
"github.com/operator-framework/rukpak/cmd/crdvalidator/internal/crd"
"github.com/operator-framework/rukpak/internal/crd"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
Expand Down
2 changes: 1 addition & 1 deletion cmd/crdvalidator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package main
import (
"os"

"github.com/operator-framework/rukpak/cmd/crdvalidator/internal/handlers"
"github.com/operator-framework/rukpak/cmd/crdvalidator/handlers"

"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client/config"
Expand Down
39 changes: 0 additions & 39 deletions cmd/crdvalidator/test/e2e/crdvalidator_suite_test.go

This file was deleted.

File renamed without changes.
192 changes: 0 additions & 192 deletions internal/util/crd.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ spec:
spec:
serviceAccountName: crd-validation-webhook
containers:
- image: quay.io/operator-framework/crd-validation-webhook:main
- image: quay.io/operator-framework/plain-provisioner:latest
imagePullPolicy: IfNotPresent
command: ["/crdvalidator"]
name: crd-validation-webhook
volumeMounts:
- name: tls
Expand Down
8 changes: 8 additions & 0 deletions manifests/crdvalidator/kustomization.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resources:
- 00_namespace.yaml
- 01_cluster_role.yaml
- 01_service_account.yaml
- 02_cluster_role_binding.yaml
- 03_service.yaml
- 04_webhook.yaml
- 05_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ var _ = Describe("crd validation webhook", func() {
},
)

err := c.Create(ctx, crd)
Expect(err).To(BeNil())

Eventually(func() error {
return c.Get(ctx, client.ObjectKeyFromObject(crd), crd)
return c.Create(ctx, crd)
}).Should(Succeed(), "should be able to create a safe crd but was not")
})

Expand Down Expand Up @@ -126,11 +123,8 @@ var _ = Describe("crd validation webhook", func() {
},
)

err := c.Create(ctx, crd)
Expect(err).To(BeNil())

Eventually(func() error {
return c.Get(ctx, client.ObjectKeyFromObject(crd), crd)
return c.Create(ctx, crd)
}).Should(Succeed(), "should be able to create a safe crd but was not")
})

Expand Down

0 comments on commit 6deb19d

Please sign in to comment.