Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #195 from cscetbon/deepcopy
Browse files Browse the repository at this point in the history
Ensure generated deepcopy files are always up to date
  • Loading branch information
cscetbon authored Feb 20, 2020
2 parents a8e327f + c20d02e commit 31746af
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
10 changes: 4 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,21 @@ orbs:
command: if [ ! -d vendor ]; then go mod vendor; fi
- run:
name: Generate k8s
command: make generate
command: |
make generate
[ "$(git ls-files -m |grep -c zz_generated)" -eq 0 ]
# Create artifacts
- persist_to_workspace:
root: /home/circleci
paths:
- << parameters.operatorDir >>/build/_output
- << parameters.operatorDir >>/pkg/apis/db/v1alpha1/zz_generated.deepcopy.go
- << parameters.operatorDir >>/vendor
# Cache configuration
- save_cache:
name: Save build artefacts in cache
key: << parameters.operatorName >>-generate-{{ .Branch }}-{{ checksum "go.sum" }}
paths:
- build/_output
- pkg/apis/db/v1alpha1/zz_generated.deepcopy.go
- vendor

# Build job, which build operator docker image (with operator-sdk build)
Expand All @@ -191,7 +191,6 @@ orbs:
root: /home/circleci
paths:
- << parameters.operatorDir >>/build/_output
- << parameters.operatorDir >>/pkg/apis/db/v1alpha1/zz_generated.deepcopy.go
- << parameters.operatorDir >>/vendor
# Deploy steps
- deploy:
Expand All @@ -209,7 +208,6 @@ orbs:
key: << parameters.operatorName >>-build-{{ .Branch }}-{{ checksum "go.sum" }}
paths:
- build/_output
- pkg/apis/db/v1alpha1/zz_generated.deepcopy.go
- vendor

# Unit test job, will execute makefile 'unit-test-with-vendor' step
Expand Down Expand Up @@ -300,7 +298,7 @@ orbs:
-Dsonar.projectBaseDir=/home/circleci/<< parameters.operatorDir >> \
-Dsonar.sources=. \
-Dsonar.sources.inclusions="**/**.go" \
-Dsonar.exclusions="**/*_test.go,**/vendor/**,**/sonar-scanner-3.3.0.1492-linux/**,**docs/**,**/**/zz_generated*" \
-Dsonar.exclusions="**/*_test.go,**/vendor/**,**/sonar-scanner-3.3.0.1492-linux/**,**docs/**" \
-Dsonar.coverage.exclusions="**/vendor/**,**/test/**,**docs/**" \
-Dsonar.tests=. \
-Dsonar.language=go \
Expand Down
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,31 @@ generate:
#@TODO : `opetator-sdk generate openapî` deprecated
# Build casskop executable file in local go env
.PHONY: build
build:
echo "Generate zzz-deepcopy objects"
operator-sdk version
operator-sdk generate k8s
operator-sdk generate openapi
build: generate
echo "Build Cassandra Operator"
operator-sdk build $(REPOSITORY):$(VERSION) --image-build-args "--build-arg https_proxy=$$https_proxy --build-arg http_proxy=$$http_proxy"
ifdef PUSHLATEST
docker tag $(REPOSITORY):$(VERSION) $(REPOSITORY):latest
endif

#@TODO : `opetator-sdk generate openapî` deprecated
#@TODO : `opetator-sdk generate openapi` deprecated
# Run a shell into the development docker image
docker-build: ## Build the Operator and it's Docker Image
echo "Generate zzz-deepcopy objects"
docker run --rm -v $(PWD):$(WORKDIR) -v $(GOPATH)/pkg/mod:/go/pkg/mod -v $(shell go env GOCACHE):/root/.cache/go-build --env GO111MODULE=on --env https_proxy=$(https_proxy) --env http_proxy=$(http_proxy) $(BUILD_IMAGE):$(OPERATOR_SDK_VERSION) /bin/bash -c 'operator-sdk generate k8s'
docker run --rm -v $(PWD):$(WORKDIR) -v $(GOPATH)/pkg/mod:/go/pkg/mod -v $(shell go env GOCACHE):/root/.cache/go-build --env GO111MODULE=on --env https_proxy=$(https_proxy) --env http_proxy=$(http_proxy) $(BUILD_IMAGE):$(OPERATOR_SDK_VERSION) /bin/bash -c 'operator-sdk generate openapi'
docker run --rm -v $(PWD):$(WORKDIR) -v $(GOPATH)/pkg/mod:/go/pkg/mod \
-v $(shell go env GOCACHE):/root/.cache/go-build --env GO111MODULE=on \
--env https_proxy=$(https_proxy) --env http_proxy=$(http_proxy) \
$(BUILD_IMAGE):$(OPERATOR_SDK_VERSION) /bin/bash -c 'operator-sdk generate k8s'
docker run --rm -v $(PWD):$(WORKDIR) -v $(GOPATH)/pkg/mod:/go/pkg/mod \
-v $(shell go env GOCACHE):/root/.cache/go-build --env GO111MODULE=on \
--env https_proxy=$(https_proxy) --env http_proxy=$(http_proxy) \
$(BUILD_IMAGE):$(OPERATOR_SDK_VERSION) /bin/bash -c 'operator-sdk generate openapi'
echo "Build Cassandra Operator. Using cache from "$(shell go env GOCACHE)
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(PWD):$(WORKDIR) -v $(GOPATH)/pkg/mod:/go/pkg/mod -v $(shell go env GOCACHE):/root/.cache/go-build --env GO111MODULE=on --env https_proxy=$(https_proxy) --env http_proxy=$(http_proxy) $(BUILD_IMAGE):$(OPERATOR_SDK_VERSION) /bin/bash -c 'operator-sdk build $(REPOSITORY):$(VERSION) --image-build-args "--build-arg https_proxy=$$https_proxy --build-arg http_proxy=$$http_proxy"'
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(PWD):$(WORKDIR) \
-v $(GOPATH)/pkg/mod:/go/pkg/mod -v $(shell go env GOCACHE):/root/.cache/go-build \
--env GO111MODULE=on --env https_proxy=$(https_proxy) --env http_proxy=$(http_proxy) \
$(BUILD_IMAGE):$(OPERATOR_SDK_VERSION) /bin/bash -c 'operator-sdk build $(REPOSITORY):$(VERSION) \
--image-build-args "--build-arg https_proxy=$$https_proxy --build-arg http_proxy=$$http_proxy"'
ifdef PUSHLATEST
docker tag $(REPOSITORY):$(VERSION) $(REPOSITORY):latest
endif
Expand Down

0 comments on commit 31746af

Please sign in to comment.