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

tools: Go Dep tool #91

Closed
akutz opened this issue Aug 24, 2017 · 1 comment
Closed

tools: Go Dep tool #91

akutz opened this issue Aug 24, 2017 · 1 comment

Comments

@akutz
Copy link
Contributor

akutz commented Aug 24, 2017

I discovered that the official Go dependency management tool (Dep) has issues with this repository:

$ dep ensure 
ensure Solve(): No versions of github.com/container-storage-interface/spec met constraints:
    70e7ca5be45bd1c87c2a46836b9e930e9fcdc128: Could not introduce github.com/container-storage-interface/spec@70e7ca5be45bd1c87c2a46836b9e930e9fcdc128, as its subpackage github.com/container-storage-interface/spec does not contain usable Go code (*build.NoGoError).. (Package is required by (root).)
    master: Could not introduce github.com/container-storage-interface/spec@master, as its subpackage github.com/container-storage-interface/spec does not contain usable Go code (*build.NoGoError).. (Package is required by (root).)
    jdef-protobuf-headers: Could not introduce github.com/container-storage-interface/spec@jdef-protobuf-headers, as it is not allowed by constraint 70e7ca5be45bd1c87c2a46836b9e930e9fcdc128 from project github.com/codedellemc/gocsi.
    jdef_github_api_token: Could not introduce github.com/container-storage-interface/spec@jdef_github_api_token, as it is not allowed by constraint 70e7ca5be45bd1c87c2a46836b9e930e9fcdc128 from project github.com/codedellemc/gocsi.

The error occurs because there are no Go sources at the root of the repository. When I nil import github.com/container-storage-interface/spec/lib/go/csi in order to force the Dep tool to see that my project does depend on this repo via one of its sub-dirs with Go sources the tool will allow it.

However, this causes its own issues. See, this repo's lib/go/csi directory contains a Go source file generated by the protoc compiler using the gRPC Go plug-in. Importing this package into a Go program causes gRPC to reregister all of the types found in the aforementioned package. However, that means it's not possible to import this repo without also being forced to use the generated Go gRPC types from the repo.

The only reason I want to depend on this repo, and thus vendor it in my own project, is to make it easy to obtain this repo's spec.md file so I'm able to generate the protobuf sources myself. I shouldn't be forced to use the sources provided by this repository. But as I said, I cannot import this repo without also using those types. The side-effect is that no other Go-based project that depends upon CSI types must also use the types from this repo.

I recommend one of two solutions:

Solution 1

A file spec.go be placed at the root of this repo like so:

// Package spec is the Container Storage Interface (CSI) specification
// repository. This package contains no functional code, and this file
// exists only to make it possible to import this repository with a Go
// dependency manager such as Dep (https://github.com/golang/dep).
package spec

Solution 2

Create the file lib/go/csi.go:

// Package csi is the Container Storage Interface (CSI) specification
// repository. This package contains no functional code, and this file
// exists only to make it possible to import this repository with a Go
// dependency manager such as Dep (https://github.com/golang/dep).
package csi

FWIW, this is not an issue with the Go dependency manager Glide, only the new, official Dep tool.

cc @mattfarina & @sdboyer

akutz added a commit to akutz/csi-spec that referenced this issue Aug 24, 2017
This patch fixes issue container-storage-interface#91 by adding support for the official Go
dependency tool, Dep. The solution is a nearly-empty Go source file at
"lib/go/csi.go" that defines a package with no functional code. However,
this package will enable the ability to nil-import
"github.com/container-storage-interface/spec/lib/go" so that the Dep
tool discovers a valid Go package (a directory with one or more Go
sources in it).

For information on why the resolution is not to simply import
"github.com/container-storage-interface/spec/lib/go/csi" please see
issue container-storage-interface#91.
@akutz akutz mentioned this issue Aug 24, 2017
@saad-ali
Copy link
Member

Closed with #93

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

2 participants