aws / aws/aws-signer-notation-plugin

Error when generating mock client using mockgen package

Open
#72 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
17
Forks
8
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Encountering issues when generating mocks using `make generate-mocks`

**Steps to reproduce**
From the root of the package repo use `make generate-mocks` and you should see the error

**What did you expect to see?**
I expected the command to sun successfully and see the following
```
make generate-mocks ─╯
Installing mockgen as it is not present in the system...
/home/pg/go/bin/mockgen
Generating Mocks...
mockgen -package client -destination=./internal/client/mock_client.go "github.com/aws/aws-signer-notation-plugin/internal/client" Interface
Mocks generated successfully.
```

**What did you see instead?**
Saw error relating to a package that is referred to by `mockgen`
```
make generate-mocks ─╯
Installing mockgen as it is not present in the system...
/home/pg/go/bin/mockgen
Generating Mocks...
mockgen -package client -destination=./internal/client/mock_client.go "github.com/aws/aws-signer-notation-plugin/internal/client" Interface
prog.go:12:2: cannot find module providing package github.com/golang/mock/mockgen/model: import lookup disabled by -mod=vendor
(Go version in go.mod is at least 1.14 and vendor directory exists.)
prog.go:12:2: cannot find module providing package github.com/golang/mock/mockgen/model: import lookup disabled by -mod=vendor
(Go version in go.mod is at least 1.14 and vendor directory exists.)
prog.go:14:2: no required module provides package github.com/aws/aws-signer-notation-plugin/internal/client: go.mod file not found in current directory or any parent directory; see 'go help modules'
prog.go:12:2: no required module provides package github.com/golang/mock/mockgen/model: go.mod file not found in current directory or any parent directory; see 'go help modules'
2024/07/25 20:58:48 Loading input failed: exit status 1
make: *** [Makefile:30: generate-mocks] Error 1
```

**What plugin version did you use?**
`1.0.350`

**What config did you use?**
Config: N/A

**Environment**
OS: Ubuntu 20.04.6 LTS
notation version : 1.0.0
Notation Go version: go1.20.7
Local Go Version: go1.22.0 linux/amd64

**Additional context**
I was able to resolve this issue by including an empty import to the `internal/client/client.go` file by adding `_ "github.com/golang/mock/mockgen/model"` to the import block. Pritesh found a related issue in the mock package ref. https://github.com/golang/mock/issues/494 . Further reference to the specific comment - https://github.com/golang/mock/issues/494#issuecomment-715609711

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.