moby: Unable to use some of the docker API due to vendoring issues
Description
I am trying to use version 1.13.0-rc3 of the docker api for golang. My imports are:
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
"github.com/docker/go-connections/nat"
"github.com/docker/go-units"
I am unable to create a HostConfig like:
portBindings := make(nat.PortMap)
var ulimits []*units.Ulimit
hostConfig := &container.HostConfig{
PortBindings: portBindings,
Resources: container.Resources{
Ulimits: ulimits,
},
}
Due to the errors:
cannot use portBindings (type "github.com/docker/go-connections/nat".PortMap) as type "github.com/docker/docker/vendor/github.com/docker/go-connections/nat".PortMap in field value
cannot use ulimits (type []*"github.com/docker/go-units".Ulimit) as type []*"github.com/docker/docker/vendor/github.com/docker/go-units".Ulimit in field value
I cannot use the vendored versions, so how can I get around this?
Steps to reproduce the issue:
- Try to create a container.HostConfig using github.com/docker/go-connections/nat.PortMap or github.com/docker/go-units.Ulimit
Describe the results you received: Failed to compile
Describe the results you expected: Compile
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 27
- Comments: 15 (4 by maintainers)
Well then… wow.
I think I worked around my issues for now, by going:
And then ensured my version of
cobra/spf13
+cobra/pflag
were up to date. Not elegant, but technically works around my issues.Just wanted to chime in here, several years later, that this is still a recurring and prevalent issue. My existing workaround was deleting the vendor folder, but this is entirely impractical and absurd. Currently trying to solve the issue with go deps. Life is pain.
@tamird I do agree it’s not the best. It’s just the current workaround, and I really wish we could somehow make it work. Having a
vendor
folder is a huge enhancement on the development on docker/docker itself as we don’t rely on some autopath hack anymore but it broke users of the client side.Still looking at some possible ideas like extracting the client
client.APIClient
to a repository for each tagged version of docker (i.e. any RC and GA releases) or something else.@SweeXordious You can take a look at this comment from @thaJeztah, he explains what procedure should be followed to get it work with
go mod
😉This rationale is beyond absurd. The API client was previously in a separate repository (https://github.com/docker/engine-api) but it was deprecated and folded into docker/docker, leaving us (your users) with no choice but to depend on docker/dcoker.
On Tue, Dec 13, 2016 at 11:05 AM, Vincent Demeester < notifications@github.com> wrote: