Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Registry support #1381

Closed
wants to merge 6 commits into from
Closed

Registry support #1381

wants to merge 6 commits into from

Conversation

romangurevitch
Copy link

What does this do / why do we need it?

A go dep registry will host packaged versions of go "projects" in self-contained format.
Developers will be able to publish new project versions to the registry and resolve them back from the registry as project dependencies.

The primary use case for a registry is to support development isolation against an in-house repository that serves immutable project dependencies. These dependencies can be external dependencies or internal projects used in-house as 3rd party dependencies.
The registry will support authentication via user tokens.

This pull request adds the functionality of downloading dependencies from a registry.
Set the following environment variables to use registry:
DEPREGISTRYURL
DEPREGISTRYTOKEN

@romangurevitch
Copy link
Author

This PR is based on #1172 with review fixes.

gps/registry.go Outdated
return nil, err
}

req.Header.Set("Authorization", "BEARER "+s.token)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's usually spelled "Bearer" with only the B capitalized.

Copy link
Member

@sdboyer sdboyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some incremental comments

cmd/dep/main.go Outdated
@@ -19,6 +19,8 @@ import (

"github.com/golang/dep"
"github.com/golang/dep/internal/fs"
"github.com/golang/dep/gps"
"net/url"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please run gofmt or goimports to keep imports sorted

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, interesting, i wasn't even looking at the ""github.com/golang/dep/internal/fs" import - i was looking at "net/url". that should be in the first block of stdlib imports.

cmd/dep/main.go Outdated
registryURL := getEnv(c.Env, "DEPREGISTRYURL")
token := getEnv(c.Env, "DEPREGISTRYTOKEN")

// check if url is not define do not create registry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complete sentences for inline comments, please

dc.mut.Unlock()

// Trigger the HTTP-backed deduction process for this requestor.
return rd.deduce(ctx, path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entails at least one HTTP request for each root path, including the known path case (which was removed above, compared with deductionCoordinator.deduceRootPath()). This will be a notable performance hit for the user vs. the current behavior.

More importantly, though, as long as we are guaranteeing that any proxy registry can access and passthrough-cache any upstream VCS source that a dep client would be able to access itself without an intermediate registry, then, then i see no compelling use case for having this extra request. In fact, all i see is a vector for confusion and errors, as we become reliant on registries to respect naming invariants that are presently universal, by virtue of being encoded in the tool. It seems like it should be possible - at least as a first pass approach - to just rely on the existing static deduction subsystem, then perform some structured transformations on the pathDeductions that they return.

Is there a crucial use case that's serviced by making this request to the registry?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Yes, it would be preferable to deduct the root project path without HTTP request. I added the known paths deduction to address this issue.

However, for imports that are not using well known URLs, passthrough upstream VCS source is not always possible. For instance, in a closed network environment that work exclusively through a private registry deducing the project root by querying the VCS repository for the goget metadata cannot work (leaving aside the fact that most of the benefits of having a local private registry are lost by bypassing and accessing the sources directly).
Therefore, there is a valid use case IMO for having the registry know about the project roots it hosts. Once, we allowed static deduction to kick in first I don't think the performance impact (a single HEAD call) would be an issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it would be preferable to deduct the root project path without HTTP request.

great 😄

However, for imports that are not using well known URLs,

for sure, i'm entirely in agreement that anything requiring normal go-get HTTP metadata deduction can be forwarded to the registry.

Once, we allowed static deduction to kick in first I don't think the performance impact (a single HEAD call) would be an issue.

agreed, that's no net increase in the number of HTTP requests, so no harm done.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Is it ready to be merged?

@sdboyer
Copy link
Member

sdboyer commented Jan 4, 2018 via email

@pfremm
Copy link

pfremm commented Feb 22, 2018

Out of curiosity what were you using as a registry?

@mvdan
Copy link
Member

mvdan commented Sep 4, 2020

Dep was officially deprecated earlier this year, and the proposal to archive this repository was accepted. As such, I'm closing outstanding issues before archiving the repository. For any further comments, please use the proposal thread on the Go issue tracker. Thanks!

@mvdan mvdan closed this Sep 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants