Add mockgen installation to the script (#6604)

* Add mockgen installation to the script

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Use go install -mod=readonly instead of installing the binary

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add mockgen installation to goget-tools target incase the user wants to run the script individually

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Update Makefile

Co-authored-by: Armel Soro <armel@rm3l.org>

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
Co-authored-by: Armel Soro <armel@rm3l.org>
This commit is contained in:
Parthvi Vala
2023-03-06 19:31:57 +05:30
committed by GitHub
parent 26c90d7c4d
commit ef6489c424
2 changed files with 34 additions and 25 deletions

View File

@@ -68,6 +68,9 @@ GOLANGCI_LINT_VERSION=1.49.0
RUN_GINKGO = go run -mod=vendor github.com/onsi/ginkgo/v2/ginkgo RUN_GINKGO = go run -mod=vendor github.com/onsi/ginkgo/v2/ginkgo
# making sure that mockgen binary version is the same as github.com/golang/mock library version
GO_MOCK_LIBRARY_VERSION = $(shell go list -mod=readonly -m -f '{{.Version}}' github.com/golang/mock)
default: bin default: bin
.PHONY: help .PHONY: help
@@ -127,8 +130,9 @@ clean:
@rm -rf $(FILES) @rm -rf $(FILES)
.PHONY: goget-tools .PHONY: goget-tools
goget-tools: goget-tools: ## Install binaries of the tools used by odo (current list: golangci-lint, mockgen)
(cd / && go install -mod=mod github.com/golangci/golangci-lint/cmd/golangci-lint@v$(GOLANGCI_LINT_VERSION)) cd / && go install -mod=mod github.com/golangci/golangci-lint/cmd/golangci-lint@v$(GOLANGCI_LINT_VERSION)
cd / && go install -mod=mod github.com/golang/mock/mockgen@$(GO_MOCK_LIBRARY_VERSION)
.PHONY: goget-ginkgo .PHONY: goget-ginkgo
goget-ginkgo: goget-ginkgo:

View File

@@ -1,92 +1,97 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Use this script to regererate generated mock files # Use this script to regenerate generated mock files
# after changing signatures of interfaces in these packages # after changing signatures of interfaces in these packages
mockgen -source=pkg/kclient/interface.go \ gomockVersion=$(go list -mod=readonly -m -f '{{.Version}}' github.com/golang/mock)
mockgen="go run -mod=readonly github.com/golang/mock/mockgen@$gomockVersion"
echo Using mockgen "$($mockgen --version)"
$mockgen -source=pkg/kclient/interface.go \
-package kclient \ -package kclient \
-destination pkg/kclient/mock_Client.go -destination pkg/kclient/mock_Client.go
mockgen -source=pkg/storage/storage.go \ $mockgen -source=pkg/storage/storage.go \
-package storage \ -package storage \
-destination pkg/storage/mock_Client.go -destination pkg/storage/mock_Client.go
mockgen -source=pkg/devfile/image/image.go \ $mockgen -source=pkg/devfile/image/image.go \
-package image \ -package image \
-destination pkg/devfile/image/mock_Backend.go -destination pkg/devfile/image/mock_Backend.go
mockgen -source=pkg/odo/cmdline/cmdline.go \ $mockgen -source=pkg/odo/cmdline/cmdline.go \
-package cmdline \ -package cmdline \
-destination pkg/odo/cmdline/mock.go -destination pkg/odo/cmdline/mock.go
mockgen -source=pkg/project/project.go \ $mockgen -source=pkg/project/project.go \
-package project \ -package project \
-destination pkg/project/mock.go -destination pkg/project/mock.go
mockgen -source=pkg/preference/preference.go \ $mockgen -source=pkg/preference/preference.go \
-package preference \ -package preference \
-destination pkg/preference/mock.go -destination pkg/preference/mock.go
mockgen -source=pkg/auth/interface.go \ $mockgen -source=pkg/auth/interface.go \
-package auth \ -package auth \
-destination pkg/auth/mock.go -destination pkg/auth/mock.go
mockgen -source=pkg/init/backend/interface.go \ $mockgen -source=pkg/init/backend/interface.go \
-package backend \ -package backend \
-destination pkg/init/backend/mock.go -destination pkg/init/backend/mock.go
mockgen -source=pkg/init/asker/interface.go \ $mockgen -source=pkg/init/asker/interface.go \
-package asker \ -package asker \
-destination pkg/init/asker/mock.go -destination pkg/init/asker/mock.go
mockgen -source=pkg/init/interface.go \ $mockgen -source=pkg/init/interface.go \
-package init \ -package init \
-destination pkg/init/mock.go -destination pkg/init/mock.go
mockgen -source=pkg/registry/interface.go \ $mockgen -source=pkg/registry/interface.go \
-package registry \ -package registry \
-destination pkg/registry/mock.go -destination pkg/registry/mock.go
mockgen -source=pkg/deploy/interface.go \ $mockgen -source=pkg/deploy/interface.go \
-package deploy \ -package deploy \
-destination pkg/deploy/mock.go -destination pkg/deploy/mock.go
mockgen -source=pkg/libdevfile/libdevfile.go \ $mockgen -source=pkg/libdevfile/libdevfile.go \
-package libdevfile \ -package libdevfile \
-destination pkg/libdevfile/handler_mock.go -destination pkg/libdevfile/handler_mock.go
mockgen -source=pkg/watch/interface.go \ $mockgen -source=pkg/watch/interface.go \
-package watch \ -package watch \
-destination pkg/watch/mock.go -destination pkg/watch/mock.go
mockgen -source=pkg/component/delete/interface.go \ $mockgen -source=pkg/component/delete/interface.go \
-package delete \ -package delete \
-destination pkg/component/delete/mock.go -destination pkg/component/delete/mock.go
mockgen -source=pkg/dev/interface.go \ $mockgen -source=pkg/dev/interface.go \
-package dev \ -package dev \
-destination pkg/dev/mock.go -destination pkg/dev/mock.go
mockgen -source=pkg/alizer/interface.go \ $mockgen -source=pkg/alizer/interface.go \
-package alizer \ -package alizer \
-destination pkg/alizer/mock.go -destination pkg/alizer/mock.go
mockgen -source=pkg/binding/interface.go \ $mockgen -source=pkg/binding/interface.go \
-package binding \ -package binding \
-destination pkg/binding/mock.go -destination pkg/binding/mock.go
mockgen -source=pkg/binding/backend/interface.go \ $mockgen -source=pkg/binding/backend/interface.go \
-package backend \ -package backend \
-destination pkg/binding/backend/mock.go -destination pkg/binding/backend/mock.go
mockgen -source=pkg/sync/interface.go \ $mockgen -source=pkg/sync/interface.go \
-package sync \ -package sync \
-destination pkg/sync/mock.go -destination pkg/sync/mock.go
mockgen -source=pkg/exec/interface.go \ $mockgen -source=pkg/exec/interface.go \
-package exec \ -package exec \
-destination pkg/exec/mock.go -destination pkg/exec/mock.go
mockgen -source=pkg/podman/interface.go \ $mockgen -source=pkg/podman/interface.go \
-package podman \ -package podman \
-destination pkg/podman/mock.go -destination pkg/podman/mock.go