Skip to content

Commit

Permalink
Merge pull request #39 from cscetbon/bundle-validate
Browse files Browse the repository at this point in the history
Bundle validate
  • Loading branch information
cscetbon authored Apr 12, 2022
2 parents 0057e53 + c2ba268 commit 18333c0
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 446 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ jobs:
tags: |
ghcr.io/cscetbon/casskop-build:latest
ghcr.io/cscetbon/casskop-build:${{ github.event.inputs.alias }}
build-args: OPERATOR_SDK_VERSION=v1.13.0
push: true
11 changes: 5 additions & 6 deletions .github/workflows/tests-and-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
container: ghcr.io/cscetbon/casskop-build:v1.13.0
container: ghcr.io/cscetbon/casskop-build

steps:
- name: Checkout repository
Expand All @@ -48,18 +48,17 @@ jobs:
- name: Vendor dependencies
run: go mod vendor

- name: Generate k8s & crds
- name: Validate operator-sdk Bundle
run: |
GO111MODULE=on go install github.com/mikefarah/yq/v4@latest
make generate
make bundle-validate
- name: Ensure there are no missing changes
- name: Ensure there are no missing CRDs changes
run: |
[ "$(git ls-files -m | grep -cE 'zz_generated|crds')" -eq 0 ]
unit-tests:
runs-on: ubuntu-latest
container: ghcr.io/cscetbon/casskop-build:v1.13.0
container: ghcr.io/cscetbon/casskop-build

steps:
- name: Checkout repository
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ update-crds:
yq -i e '$(FIRST_VERSION).storage = false' $$crd; \
done
for chart in $(ls charts); do \
cp -v config/crd/bases/* charts/${chart}/crds/; \
cp -v config/crd/bases/*.yaml charts/${chart}/crds/; \
done

include shared.mk
Expand Down Expand Up @@ -170,10 +170,10 @@ endif
bundle: generate
operator-sdk generate kustomize manifests -q;\
VERSION=$$(cat ./version/version.go | grep -Po '(?<=Version =\s").*(?=")');\
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $${VERSION} $(BUNDLE_METADATA_OPTS);\
operator-sdk bundle validate ./bundle;\
$(KUSTOMIZE) build config/crd | operator-sdk generate bundle -q --overwrite --version $${VERSION} $(BUNDLE_METADATA_OPTS)

# Build the bundle image.
bundle-build:
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
bundle-validate: bundle
operator-sdk bundle validate ./bundle

docker-generate:
docker run --rm -ti -v ${PWD}:/go/casskop ghcr.io/cscetbon/casskop-build:latest make generate
3 changes: 2 additions & 1 deletion docker/ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ RUN curl -L https://github.com/gotestyourself/gotestsum/releases/download/v0.3.4
RUN go get -u golang.org/x/lint/golint
RUN go get sigs.k8s.io/controller-tools/cmd/[email protected]
RUN go get sigs.k8s.io/kustomize/kustomize/[email protected]
RUN go install github.com/mikefarah/yq/v4@latest

# Install kubectl cli
RUN curl -o /usr/local/bin/kubectl -L https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl \
Expand All @@ -59,7 +60,7 @@ RUN curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 |

# Install Operator SDK
ARG OPERATOR_SDK_VERSION
RUN curl -o /usr/local/bin/operator-sdk -L https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk-${OPERATOR_SDK_VERSION}-x86_64-linux-gnu \
RUN curl -o /usr/local/bin/operator-sdk -L https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk_linux_amd64 \
&& chmod +x /usr/local/bin/operator-sdk

WORKDIR /go/casskop
Expand Down
86 changes: 6 additions & 80 deletions multi-casskop/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ KUBESQUASH_REGISTRY:=

KUBECONFIG ?= ~/.kube/config

MINIKUBE_CONFIG ?= ~/.minikube
MINIKUBE_CONFIG_MOUNT ?= /home/ci/.minikube

HELM_VERSION := $(shell cat helm/multi-casskop/Chart.yaml| grep version | awk -F"version: " '{print $$2}')
HELM_TARGET_DIR ?= ../docs/helm

params:
@echo "CIRCLE_BRANCH = '$(CIRCLE_BRANCH)'"
@echo "CIRCLE_TAG = '$(CIRCLE_TAG)'"
Expand All @@ -41,24 +35,13 @@ params:
# CMDs
MOCKS_CMD := go generate ./mocks


#
#
################################################################################

# The default action of this Makefile is to build the development docker image
default: build

clean:
@rm -rf $(OUT_BIN) || true
@rm -f apis/db/v2/zz_generated.deepcopy.go || true

helm-package:
@echo Packaging $(HELM_VERSION)
helm package helm/multi-casskop
mv multi-casskop-$(HELM_VERSION).tgz $(HELM_TARGET_DIR)
helm repo index $(HELM_TARGET_DIR)/

# Build casskop executable file in local go env

export CGO_ENABLED:=0
Expand All @@ -71,50 +54,19 @@ CRD_V1 = deploy/crds/multicluster_v1alpha1_cassandramulticluster_crd.yaml
CRD = config/crd/bases/db.orange.com_multicasskops.yaml
FIRST_VERSION = .spec.versions[0]

.PHONY: update-crds
update-crds:
echo Update CRD - Remove protocol and set config type to object CRD
# # We checkout v1alpha1 CRD and add it to v2 CRD as it must be known to do an upgrade
git show v1.1.5-release:./$(CRD_V1) > /tmp/$$(basename $(CRD))
sed -e '1,/versions/d' $(CRD) >> /tmp/$$(basename $(CRD))
cp /tmp/$$(basename $(CRD)) $(CRD)
yq -i e '$(FIRST_VERSION).storage = false' $(CRD)
cp -v config/crd/bases/* helm/*/crds/

include ../shared.mk
include ../kube.mk

BUILD_CMD = docker build -f multi-casskop/Dockerfile . -t $(REPOSITORY):$(VERSION) --build-arg https_proxy=$$https_proxy --build-arg http_proxy=$$http_proxy

DOCKER_BUILD = docker run --rm -v $(MOUNTDIR):$(WORKDIR) -v $(GOPATH)/pkg/mod:/go/pkg/mod:delegated \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(shell go env GOCACHE):/root/.cache/go-build:delegated \
--env CGO_ENABLED=$(CGO_ENABLED) --env GOOS=linux --env GOARCH=amd64 \
--env https_proxy=$(https_proxy) --env http_proxy=$(http_proxy) \
$(BUILD_IMAGE):$(OPERATOR_SDK_VERSION) /bin/bash -c

docker-generate-files:
cd ../ && make docker-generate-files
cp -v ../config/crd/bases/* helm/*/crds/
$(MAKE) docker-generate-k8s
$(DOCKER_BUILD) 'cd $(BUILD_FOLDER); $(GENERATE_CMD)'
cp config/crd/bases/* helm/*/crds/

docker-build-operator:
echo "Build Cassandra Operator. Using cache from "$(shell go env GOCACHE)
$(DOCKER_BUILD) '$(BUILD_CMD)'

# Build the Operator and its Docker Image
docker-build: docker-generate-files docker-build-operator

# Override generate as controller-gen crashes
.PHONY: generate
generate:
cd .. && make generate
cp -v ../config/crd/bases/* helm/*/crds/
$(MAKE) -C .. generate
cp -v ../config/crd/bases/*.yaml ../charts/multi-casskop/crds/
$(MAKE) generate-k8s
$(GENERATE_CMD)
cp config/crd/bases/* helm/*/crds/
cp config/crd/bases/*.yaml ../charts/multi-casskop/crds/

docker-generate:
docker run --rm -ti -v $PWD:/go/casskop ghcr.io/cscetbon/casskop-build:latest make -C multi-casskop generate

# Build CassKop executable file in local go env
.PHONY: build
Expand All @@ -125,7 +77,6 @@ ifdef PUSHLATEST
docker tag $(REPOSITORY):$(VERSION) $(REPOSITORY):latest
endif


build-local: generate
@echo "Build Cassandra Operator for $(GOOS)"
go build -o build/_output/bin/multi-casskop-$(GOOS) -gcflags all=-trimpath=github.com/cscetbon -asmflags all=-trimpath=github.com/cscetbon github.com/cscetbon/casskop/multi-casskop/cmd/manager
Expand Down Expand Up @@ -186,28 +137,3 @@ release: tag image publish

unit-test-with-vendor:
echo TODO

kustomize:
ifeq (, $(shell which kustomize))
@{ \
set -e ;\
KUSTOMIZE_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$KUSTOMIZE_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/kustomize/kustomize/[email protected] ;\
rm -rf $$KUSTOMIZE_GEN_TMP_DIR ;\
}
KUSTOMIZE=$(GOBIN)/kustomize
else
KUSTOMIZE=$(shell which kustomize)
endif

# Generate bundle manifests and metadata, then validate generated files.
bundle: manifests
operator-sdk generate kustomize manifests -q
kustomize build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
operator-sdk bundle validate ./bundle

# Build the bundle image.
bundle-build:
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
5 changes: 4 additions & 1 deletion shared.mk
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ WORKDIR := /go/casskop
.PHONY: generate
generate:
echo "Generate zzz-deepcopy objects"
$(MAKE) controller-gen
$(MAKE) generate-k8s
@rm -f */crds/*
$(CONTROLLER_GEN) $(CONTROLLER_GEN_OPTIONS)
$(MAKE) update-crds

# Build the bundle image.
bundle-build:
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
31 changes: 0 additions & 31 deletions tools/configure-dind-local-storage.sh

This file was deleted.

31 changes: 0 additions & 31 deletions tools/create_dind_cluster.sh

This file was deleted.

7 changes: 0 additions & 7 deletions tools/e2e_test_cleanup.sh

This file was deleted.

5 changes: 0 additions & 5 deletions tools/health/go.mod

This file was deleted.

10 changes: 0 additions & 10 deletions tools/health/go.sum

This file was deleted.

37 changes: 0 additions & 37 deletions tools/health/main.go

This file was deleted.

Loading

0 comments on commit 18333c0

Please sign in to comment.