Skip to content

Commit

Permalink
Merge pull request #564 from njhale/container-mockgen
Browse files Browse the repository at this point in the history
feat(mocks): generate fakes and mocks in a container
  • Loading branch information
openshift-merge-robot authored Nov 12, 2018
2 parents a441e9b + 0f8f406 commit f8f7de9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 577 deletions.
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ SHELL := /bin/bash
PKG := github.com/operator-framework/operator-lifecycle-manager
CMDS := $(addprefix bin/, $(shell go list ./cmd/... | xargs -I{} basename {}))
CODEGEN := ./vendor/k8s.io/code-generator/generate_groups.sh
MOCKGEN := ./scripts/generate_mocks.sh
counterfeiter := $(GOBIN)/counterfeiter
mockgen := $(GOBIN)/mockgen
IMAGE_REPO := quay.io/coreos/olm
Expand Down Expand Up @@ -125,18 +126,25 @@ container-codegen:
docker cp temp-codegen:/go/src/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/. ./pkg/package-server/client
docker rm temp-codegen

container-mockgen:
docker build -t olm:mockgen -f mockgen.Dockerfile .
docker run --name temp-mockgen olm:mockgen /bin/true
docker cp temp-mockgen:/go/src/github.com/operator-framework/operator-lifecycle-manager/pkg/api/wrappers/wrappersfakes/. ./pkg/api/wrappers/wrappersfakes
docker cp temp-mockgen:/go/src/github.com/operator-framework/operator-lifecycle-manager/pkg/fakes/. ./pkg/fakes
docker cp temp-mockgen:/go/src/github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient/mock_client.go ./pkg/lib/operatorclient/mock_client.go
docker rm temp-mockgen

# Must be run in gopath: https://github.com/kubernetes/kubernetes/issues/67566
verify-codegen: codegen
git diff --exit-code

verify-catalog: schema-check
go test $(MOD_FLAGS) -v ./test/schema/catalog_versions_test.go

generate-mock-client:
go generate ./$(PKG_DIR)/...
GO111MODULE=on mockgen -source ./pkg/lib/operatorclient/client.go -destination ./pkg/lib/operatorclient/mock_client.go -package operatorclient
generate-mock-client:
$(MOCKGEN)

gen-all: gen-ci container-codegen generate-mock-client
gen-all: gen-ci container-codegen container-mockgen

# before running release, bump the version in OLM_VERSION and push to master,
# then tag those builds in quay with the version in OLM_VERSION
Expand Down
3 changes: 1 addition & 2 deletions codegen.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ COPY pkg pkg
COPY vendor vendor
COPY scripts/generate_groups.sh scripts/generate_groups.sh
COPY boilerplate.go.txt boilerplate.go.txt
RUN make codegen

RUN make codegen
9 changes: 9 additions & 0 deletions mockgen.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.10
WORKDIR /go/src/github.com/operator-framework/operator-lifecycle-manager
COPY Makefile Makefile
COPY pkg pkg
COPY vendor vendor
COPY scripts/generate_mocks.sh scripts/generate_mocks.sh
RUN chmod +x scripts/generate_mocks.sh
COPY boilerplate.go.txt boilerplate.go.txt
RUN make generate-mock-client
Loading

0 comments on commit f8f7de9

Please sign in to comment.