Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mockery failing to run when having private repositories as dependencies #619

Open
1 of 5 tasks
Mendes11 opened this issue May 9, 2023 · 5 comments
Open
1 of 5 tasks

Comments

@Mendes11
Copy link

Mendes11 commented May 9, 2023

Description

Mockery failing with private repositories

Mockery Version


2.14.0

Golang Version

1.18.3

Installation Method

  • Binary Distribution
  • Docker
  • brew
  • go install
  • Other: [specify]

Steps to Reproduce

  1. Import from a module belonging to a private repository
  2. Run docker run -e GOPRIVATE=$GOPRIVATE -v "$HOME/.gitconfig:/root/.gitconfig" -v "$PWD:/src" -w /src vektra/mockery -r --all --dir=./pkg/app/ports --output ./pkg/app/mocks

Expected Behavior

Mocks to be generated with mockery identifying my .gitconfig which has that token@<git_url>.insteadof <git_url>

Actual Behavior

09 May 23 12:23 UTC INF Starting mockery dry-run=false version=v2.14.0
09 May 23 12:23 UTC INF Walking dry-run=false version=v2.14.0
09 May 23 12:23 UTC ERR Error parsing file error="/src/pkg/app/ports/licenserepository.go:6:2: could not import <package_path> (invalid package name: \"\")" dry-run=false version=v2.14.0
09 May 23 12:23 UTC ERR Error parsing file error="/src/pkg/app/ports/licenserepository.go:6:2: could not import <package_path> (invalid package name: \"\")" dry-run=false version=v2.14.0

If I replace mockery's entrypoint to /bin/sh, then run it in iterative mode, running the following commands:

  1. apk add git
  2. go mod download
  3. mockery -r --all --dir=./pkg/app/ports --output ./pkg/app/mocks`

It works and the mocks got generated

@LandonTClipp
Copy link
Contributor

Hi, please use the latest version of mockery to see if the problem still exists.

@kramen22
Copy link

For what it's worth (I know this issue seems stale) I have this issue intermittently as well. I am currently using v2.35.3 and see the same invalid package name for my private package import. I use the .mockery.yaml style configuration and running go mod download && mockery -r usually works when mockery throws this error.

@hsequeda
Copy link

Same error v2.26.1.

@kramen22
Copy link

For what it's worth (I know this issue seems stale) I have this issue intermittently as well. I am currently using v2.35.3 and see the same invalid package name for my private package import. I use the .mockery.yaml style configuration and running go mod download && mockery -r usually works when mockery throws this error.

After further investigation, I had an error that was caused by github not being properly configured to pull in private go repositories in the docker layer I was running mockery in, and after that was fixed this error went away. Maybe its possible to catch that error and print something more helpful?

@LandonTClipp
Copy link
Contributor

This problem seems centered around the docker containers specifically. This is not surprising to me. We should probably document how to configure the environment inside the container to properly allow pulling from private repos. I'm sure this is some simple credential modification that needs to be done on the git level.

If anyone could share how they did this then I can look into adding it in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants