Skip to content

Commit

Permalink
Add mockgen installation to the script (#6604)
Browse files Browse the repository at this point in the history
* Add mockgen installation to the script

Signed-off-by: Parthvi Vala <[email protected]>

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

Signed-off-by: Parthvi Vala <[email protected]>

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

Signed-off-by: Parthvi Vala <[email protected]>

* Update Makefile

Co-authored-by: Armel Soro <[email protected]>

---------

Signed-off-by: Parthvi Vala <[email protected]>
Co-authored-by: Armel Soro <[email protected]>
Co-authored-by: Armel Soro <[email protected]>
  • Loading branch information
3 people authored Mar 6, 2023
1 parent 26c90d7 commit ef6489c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ GOLANGCI_LINT_VERSION=1.49.0

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

.PHONY: help
Expand Down Expand Up @@ -127,8 +130,9 @@ clean:
@rm -rf $(FILES)

.PHONY: goget-tools
goget-tools:
(cd / && go install -mod=mod github.com/golangci/golangci-lint/cmd/golangci-lint@v$(GOLANGCI_LINT_VERSION))
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/golang/mock/mockgen@$(GO_MOCK_LIBRARY_VERSION)

.PHONY: goget-ginkgo
goget-ginkgo:
Expand Down
51 changes: 28 additions & 23 deletions scripts/mockgen.sh
Original file line number Diff line number Diff line change
@@ -1,92 +1,97 @@
#!/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

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 \
-destination pkg/kclient/mock_Client.go

mockgen -source=pkg/storage/storage.go \
$mockgen -source=pkg/storage/storage.go \
-package storage \
-destination pkg/storage/mock_Client.go

mockgen -source=pkg/devfile/image/image.go \
$mockgen -source=pkg/devfile/image/image.go \
-package image \
-destination pkg/devfile/image/mock_Backend.go

mockgen -source=pkg/odo/cmdline/cmdline.go \
$mockgen -source=pkg/odo/cmdline/cmdline.go \
-package cmdline \
-destination pkg/odo/cmdline/mock.go

mockgen -source=pkg/project/project.go \
$mockgen -source=pkg/project/project.go \
-package project \
-destination pkg/project/mock.go

mockgen -source=pkg/preference/preference.go \
$mockgen -source=pkg/preference/preference.go \
-package preference \
-destination pkg/preference/mock.go

mockgen -source=pkg/auth/interface.go \
$mockgen -source=pkg/auth/interface.go \
-package auth \
-destination pkg/auth/mock.go

mockgen -source=pkg/init/backend/interface.go \
$mockgen -source=pkg/init/backend/interface.go \
-package backend \
-destination pkg/init/backend/mock.go

mockgen -source=pkg/init/asker/interface.go \
$mockgen -source=pkg/init/asker/interface.go \
-package asker \
-destination pkg/init/asker/mock.go

mockgen -source=pkg/init/interface.go \
$mockgen -source=pkg/init/interface.go \
-package init \
-destination pkg/init/mock.go

mockgen -source=pkg/registry/interface.go \
$mockgen -source=pkg/registry/interface.go \
-package registry \
-destination pkg/registry/mock.go

mockgen -source=pkg/deploy/interface.go \
$mockgen -source=pkg/deploy/interface.go \
-package deploy \
-destination pkg/deploy/mock.go

mockgen -source=pkg/libdevfile/libdevfile.go \
$mockgen -source=pkg/libdevfile/libdevfile.go \
-package libdevfile \
-destination pkg/libdevfile/handler_mock.go

mockgen -source=pkg/watch/interface.go \
$mockgen -source=pkg/watch/interface.go \
-package watch \
-destination pkg/watch/mock.go

mockgen -source=pkg/component/delete/interface.go \
$mockgen -source=pkg/component/delete/interface.go \
-package delete \
-destination pkg/component/delete/mock.go

mockgen -source=pkg/dev/interface.go \
$mockgen -source=pkg/dev/interface.go \
-package dev \
-destination pkg/dev/mock.go

mockgen -source=pkg/alizer/interface.go \
$mockgen -source=pkg/alizer/interface.go \
-package alizer \
-destination pkg/alizer/mock.go

mockgen -source=pkg/binding/interface.go \
$mockgen -source=pkg/binding/interface.go \
-package binding \
-destination pkg/binding/mock.go

mockgen -source=pkg/binding/backend/interface.go \
$mockgen -source=pkg/binding/backend/interface.go \
-package backend \
-destination pkg/binding/backend/mock.go

mockgen -source=pkg/sync/interface.go \
$mockgen -source=pkg/sync/interface.go \
-package sync \
-destination pkg/sync/mock.go

mockgen -source=pkg/exec/interface.go \
$mockgen -source=pkg/exec/interface.go \
-package exec \
-destination pkg/exec/mock.go

mockgen -source=pkg/podman/interface.go \
$mockgen -source=pkg/podman/interface.go \
-package podman \
-destination pkg/podman/mock.go

0 comments on commit ef6489c

Please sign in to comment.