Vault: Cannot import certain packages in module-enabled repositories

Created on 29 May 2019  Â·  4Comments  Â·  Source: hashicorp/vault

Describe the bug
In module-aware repos other than this one, it is not possible to import several of the subpackages in this rep . For example, github.com/hashicorp/vault/command/agent/auth will produce an error.

To Reproduce
Steps to reproduce the behavior:

  1. Open a new directory off the gopath.
  2. Run go mod init foo to get a module-enabled repo
  3. Create a file with the following contents:
package main

import _ "github.com/hashicorp/vault/command/agent/auth"

func main() {}
  1. Run go mod tidy
  2. Run go get
  3. See error:
build foo: cannot load github.com/hashicorp/vault/api: ambiguous import: found github.com/hashicorp/vault/api in multiple modules:
    github.com/hashicorp/vault v1.1.2 ($GOPATH/pkg/mod/github.com/hashicorp/[email protected]/api)
    github.com/hashicorp/vault/api v1.0.1 ($GOPATH/pkg/mod/github.com/hashicorp/vault/[email protected])

Expected behavior
go get should get the dependencies and throw no errors.

Environment:

  • Vault Server Version (retrieve with vault status): N/A
  • Vault CLI Version (retrieve with vault version): N/A
  • Vault Source Code Version: v1.1.2
  • Server Operating System/Architecture:

    Environment Details
GOARCH="amd64"
GOOS="linux"

Vault server configuration file(s): N/A

Additional context
The use case for importing those packages externally is to allow Docker Credential Helper for Vault-stored Credentials to migrate to modules.

I tried setting up similar module dependency relationships with submodules/tagging for a sample package to see if I could debug the exact issue, but was unsuccessful.

It seems related to packages that import github.com/hashicorp/vault/api, but importing that package directly does not cause issues.

Most helpful comment

We don't yet have a tagged release for the main repo that uses modules. That will come with the 1.2.0 release. In the meantime you can use @master for the version target for go get so that you'll import module-aware code.

All 4 comments

We don't yet have a tagged release for the main repo that uses modules. That will come with the 1.2.0 release. In the meantime you can use @master for the version target for go get so that you'll import module-aware code.

I'm having this issue as well and go get github.com/hashicorp/vault@master is resulting in errors:

rnikoopour➜  go get github.com/hashicorp/vault@master
go: finding github.com/hashicorp/vault master
go: extracting github.com/hashicorp/vault v1.1.2-0.20190606175134-946164180d24
go: extracting github.com/hashicorp/hcl v1.0.0
go: extracting github.com/hashicorp/vault-plugin-auth-jwt v0.5.1
go: extracting github.com/hashicorp/vault/sdk v0.1.11
go: extracting github.com/hashicorp/consul/api v1.0.1
go: extracting github.com/hashicorp/vault/api v1.0.1
go: extracting github.com/hashicorp/go-uuid v1.0.1
go: extracting github.com/hashicorp/vault-plugin-auth-alicloud v0.5.1
go: extracting github.com/hashicorp/go-sockaddr v1.0.2
go: extracting github.com/hashicorp/go-retryablehttp v0.5.3
go: extracting github.com/hashicorp/errwrap v1.0.0
go: extracting github.com/hashicorp/go-gcp-common v0.5.0
go: extracting github.com/hashicorp/go-rootcerts v1.0.0
go: extracting github.com/hashicorp/vault-plugin-secrets-alicloud v0.5.1
go: extracting github.com/hashicorp/vault-plugin-auth-azure v0.5.1
go: extracting github.com/hashicorp/vault-plugin-secrets-gcp v0.5.2
go: extracting github.com/hashicorp/go-memdb v1.0.0
go: extracting github.com/hashicorp/vault-plugin-secrets-azure v0.5.1
go: extracting github.com/hashicorp/vault-plugin-auth-centrify v0.5.1
go: extracting github.com/hashicorp/go-syslog v1.0.0
go: extracting github.com/hashicorp/nomad/api v0.0.0-20190412184103-1c38ced33adf
go: extracting github.com/hashicorp/go-hclog v0.8.0
go: extracting github.com/hashicorp/serf v0.8.2
go: extracting github.com/hashicorp/vault-plugin-auth-gcp v0.5.1
go: extracting github.com/hashicorp/vault-plugin-secrets-kv v0.5.2-0.20190416155133-fd495225dea0
go: extracting github.com/hashicorp/go-version v1.1.0
go: extracting github.com/hashicorp/vault-plugin-secrets-gcpkms v0.5.1
go: extracting github.com/hashicorp/vault-plugin-secrets-ad v0.5.1
go: extracting github.com/hashicorp/vault-plugin-auth-kubernetes v0.5.1
go: extracting github.com/hashicorp/go-cleanhttp v0.5.1
go: extracting github.com/hashicorp/golang-lru v0.5.1
go: extracting github.com/hashicorp/go-immutable-radix v1.0.0
go: extracting github.com/hashicorp/go-plugin v1.0.0
go: extracting github.com/hashicorp/go-multierror v1.0.0
go: extracting github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d
# github.com/hashicorp/vault/audit
../../go/pkg/mod/github.com/hashicorp/[email protected]/audit/format.go:58:15: in.Request.Connection undefined (type interface {} is interface with no methods)
../../go/pkg/mod/github.com/hashicorp/[email protected]/audit/format.go:59:25: in.Request.Connection undefined (type interface {} is interface with no methods)
../../go/pkg/mod/github.com/hashicorp/[email protected]/audit/format.go:66:14: in.Request.Connection undefined (type interface {} is interface with no methods)
../../go/pkg/mod/github.com/hashicorp/[email protected]/audit/format.go:68:15: in.Request.Connection undefined (type interface {} is interface with no methods)
../../go/pkg/mod/github.com/hashicorp/[email protected]/audit/format.go:86:24: req.Data undefined (type interface {} is interface with no methods)
../../go/pkg/mod/github.com/hashicorp/[email protected]/audit/format.go:94:8: req.Data undefined (type interface {} is interface with no methods)
../../go/pkg/mod/github.com/hashicorp/[email protected]/audit/format.go:115:47: req.ClientTokenAccessor undefined (type interface {} is interface with no methods)
../../go/pkg/mod/github.com/hashicorp/[email protected]/audit/format.go:116:29: req.ClientTokenAccessor undefined (type interface {} is interface with no methods)
../../go/pkg/mod/github.com/hashicorp/[email protected]/audit/format.go:122:7: req.ClientTokenAccessor undefined (type interface {} is interface with no methods)
../../go/pkg/mod/github.com/hashicorp/[email protected]/audit/format.go:158:34: req.ClientTokenRemainingUses undefined (type interface {} is interface with no methods)
../../go/pkg/mod/github.com/hashicorp/[email protected]/audit/format.go:158:34: too many errors
# github.com/hashicorp/vault/builtin/logical/transit
../../go/pkg/mod/github.com/hashicorp/[email protected]/builtin/logical/transit/backend.go:75:12: assignment mismatch: 2 variables but keysutil.NewLockManager returns 1 values
../../go/pkg/mod/github.com/hashicorp/[email protected]/builtin/logical/transit/backend.go:75:37: too many arguments in call to keysutil.NewLockManager
    have (bool, int)
    want (bool)
../../go/pkg/mod/github.com/hashicorp/[email protected]/builtin/logical/transit/path_cache_config.go:76:10: b.lm.GetUseCache undefined (type *keysutil.LockManager has no field or method GetUseCache)
../../go/pkg/mod/github.com/hashicorp/[email protected]/builtin/logical/transit/path_cache_config.go:83:26: b.lm.GetCacheSize undefined (type *keysutil.LockManager has no field or method GetCacheSize)

any news?

Yes, you need to import either api/ or sdk/ and for now you should use @master for each. With go modules you shouldn't import the main repo.

Was this page helpful?
0 / 5 - 0 ratings