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

internal/mod/modregistry: some registries do not support arbitrary repo names #2816

Closed
rogpeppe opened this issue Feb 13, 2024 · 0 comments
Closed
Assignees
Labels
modules Issues related to CUE modules and the experimental implementation

Comments

@rogpeppe
Copy link
Member

rogpeppe commented Feb 13, 2024

What version of CUE are you using (cue version)?

$ cue version
v0.8.0-alpha.1

Does this issue reproduce with the latest stable release?

No. The feature didn't exist then,

What did you do?

env TOKEN=xxxx
env GITLAB_USER=rogpeppe
env CUE_REGISTRY=registry.gitlab.com/rogpeppe/registrytest
env CUE_EXPERIMENT=modules
env DOCKER_CONFIG=$WORK
exec docker login registry.gitlab.com -u $GITLAB_USER --password $TOKEN
exec cue mod publish v1.0.0

-- cue.mod/module.cue --
module: "github.com/rogpeppe/cuemodtest@v1"
-- m.cue --
package cuemodtest
x: 2

(with "xxxx" replaced with my actual personal access token):

What did you expect to see?

A passing test.

What did you see instead?

> env TOKEN=xxxx
> env GITLAB_USER=rogpeppe
> env CUE_REGISTRY=registry.gitlab.com/rogpeppe/registrytest
> env CUE_EXPERIMENT=modules
> env DOCKER_CONFIG=$WORK
> exec docker login registry.gitlab.com -u $GITLAB_USER --password $TOKEN
[stdout]
Login Succeeded
[stderr]
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in $WORK/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

> exec cue mod publish v1.0.0
[stderr]
cannot put module: cannot make scratch config: 401 Unauthorized: unauthorized: authentication required; detail: [{"Type":"repository","Class":"","Name":"rogpeppe/registrytest/github.com/rogpeppe/cuemodtest","ProjectPath":"","Action":"pull"},{"Type":"repository","Class":"","Name":"rogpeppe/registrytest/github.com/rogpeppe/cuemodtest","ProjectPath":"","Action":"push"}]
[exit status 1]
FAIL: /tmp/testscript2400730507/gitlab1.txtar/script.txtar:7: unexpected command failure

Although the response says "unauthorized", the actual reason is that the naming restriction documented here has not been followed.

If I try with a module name with fewer components, it gets further:

env TOKEN=xxxx
env GITLAB_USER=rogpeppe
env CUE_REGISTRY=registry.gitlab.com/rogpeppe/registrytest
env CUE_EXPERIMENT=modules
env DOCKER_CONFIG=$WORK
exec docker login registry.gitlab.com -u $GITLAB_USER --password $TOKEN
exec cue mod publish v1.0.0

-- cue.mod/module.cue --
module: "foo.com@v1"
-- m.cue --
package cuemodtest
x: 2

This is how it fails then:

> env TOKEN=xxxx
> env GITLAB_USER=rogpeppe
> env CUE_REGISTRY=registry.gitlab.com/rogpeppe/registrytest
> env CUE_EXPERIMENT=modules
> env DOCKER_CONFIG=$WORK
> exec docker login registry.gitlab.com -u $GITLAB_USER --password $TOKEN
[stdout]
Login Succeeded
[stderr]
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in $WORK/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

> exec cue mod publish v1.0.0
[stderr]
cannot put module: cannot tag foo.com@v1.0.0: 400 Bad Request: manifest invalid: manifest invalid; detail: "unknown media type: application/vnd.cue.module.v1+json"
[exit status 1]
FAIL: /tmp/testscript4093019353/gitlab2.txtar/script.txtar:7: unexpected command failure

It turns out that gitlab does not support unknown artifact types for historical reasons (see https://gitlab.com/gitlab-org/container-registry/-/issues/973). If CUE is changed to avoid the custom artifact type, the test above passes.

@rogpeppe rogpeppe added NeedsInvestigation Triage Requires triage/attention modules Issues related to CUE modules and the experimental implementation and removed NeedsInvestigation Triage Requires triage/attention labels Feb 13, 2024
cueckoo pushed a commit that referenced this issue Feb 16, 2024
In-the-wild registries can have significant restrictions on the names
that can be stored.  Here we implement a more general resolver that
can be configured with a configuration file.

The schema for that configuration file is held in internal/mod/modresolve/schema.cue;
all the field names and arrangement of that configuration are provisional.

The key property here is that a module is always stored with exactly the
same blob and manifest files regardless of the registry, but the mapping
from (module, version) to (repository, tag) can vary arbitrarily according
to the configuration.

The existing `modmux` registry multiplexer is now no longer sufficient,
because there is no longer always a one-to-one relationship between
modules and OCI repositories.

So we change the layering so that the modregistry package directly
knows about multiple registries, using the new `modresolve.Resolver`
interface to tell it where modules live.

The `modcache` package now takes a `*modregistry.Client` directly,
which doesn't actually affect its core logic much at all because it
only ever used that type internally anyway.

We don't yet wire up the new configuration file logic inside
`cmd/cue`: we'll do that in a subsequent change. For now, we
verify that all the old behavior is still maintained despite the
internal refactoring.

As part of this work, also implement an `AllHosts` method that
we can use to address the duplicate registry parsing logic
in `cue login` by allowing that command to introspect all
the hosts that need to be logged into.

For #2816.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I5a5d7576c237e4844a0e7b3455cbdd781dc7fa19
cueckoo pushed a commit that referenced this issue Feb 16, 2024
In-the-wild registries can have significant restrictions on the names
that can be stored.  Here we implement a more general resolver that
can be configured with a configuration file.

The schema for that configuration file is held in internal/mod/modresolve/schema.cue;
all the field names and arrangement of that configuration are provisional.

The key property here is that a module is always stored with exactly the
same blob and manifest files regardless of the registry, but the mapping
from (module, version) to (repository, tag) can vary arbitrarily according
to the configuration.

The existing `modmux` registry multiplexer is now no longer sufficient,
because there is no longer always a one-to-one relationship between
modules and OCI repositories.

So we change the layering so that the modregistry package directly
knows about multiple registries, using the new `modresolve.Resolver`
interface to tell it where modules live.

The `modcache` package now takes a `*modregistry.Client` directly,
which doesn't actually affect its core logic much at all because it
only ever used that type internally anyway.

We don't yet wire up the new configuration file logic inside
`cmd/cue`: we'll do that in a subsequent change. For now, we
verify that all the old behavior is still maintained despite the
internal refactoring.

As part of this work, also implement an `AllHosts` method that
we can use to address the duplicate registry parsing logic
in `cue login` by allowing that command to introspect all
the hosts that need to be logged into.

For #2816.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I5a5d7576c237e4844a0e7b3455cbdd781dc7fa19
cueckoo pushed a commit that referenced this issue Feb 16, 2024
In-the-wild registries can have significant restrictions on the names
that can be stored. Here we implement a more general resolver that can
be configured with a configuration file.

The schema for that configuration file is held in
internal/mod/modresolve/schema.cue; all the field names and arrangement
of that configuration are provisional.

The key property here is that a module is always stored with exactly the
same blob and manifest files regardless of the registry, but the mapping
from (module, version) to (repository, tag) can vary arbitrarily
according to the configuration.

The existing `modmux` registry multiplexer is now no longer sufficient,
because there is no longer always a one-to-one relationship between
modules and OCI repositories.

So we change the layering so that the modregistry package directly knows
about multiple registries, using the new `modresolve.Resolver` interface
to tell it where modules live.

The `modcache` package now takes a `*modregistry.Client` directly, which
doesn't actually affect its core logic much at all because it only ever
used that type internally anyway.

We don't yet wire up the new configuration file logic inside `cmd/cue`:
we'll do that in a subsequent change. For now, we verify that all the
old behavior is still maintained despite the internal refactoring.

As part of this work, also implement an `AllHosts` method that we can
use to address the duplicate registry parsing logic in `cue login` by
allowing that command to introspect all the hosts that need to be logged
into.

Also update the `ociregistry` dependency to the latest version so we
can use the new `ociref.IsValid*` functions.

For #2816.

It provides a way to fix (most of) that specific issue by using the `hashAsPath`
path encoding, which avoids the restriction on the number of path
elements in a repository. It does not address #2817.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I5a5d7576c237e4844a0e7b3455cbdd781dc7fa19
cueckoo pushed a commit that referenced this issue Feb 16, 2024
In-the-wild registries can have significant restrictions on the names
that can be stored. Here we implement a more general resolver that can
be configured with a configuration file.

The schema for that configuration file is held in
internal/mod/modresolve/schema.cue; all the field names and arrangement
of that configuration are provisional.

The key property here is that a module is always stored with exactly the
same blob and manifest files regardless of the registry, but the mapping
from (module, version) to (repository, tag) can vary arbitrarily
according to the configuration.

The existing `modmux` registry multiplexer is now no longer sufficient,
because there is no longer always a one-to-one relationship between
modules and OCI repositories.

So we change the layering so that the modregistry package directly knows
about multiple registries, using the new `modresolve.Resolver` interface
to tell it where modules live.

The `modcache` package now takes a `*modregistry.Client` directly, which
doesn't actually affect its core logic much at all because it only ever
used that type internally anyway.

We don't yet wire up the new configuration file logic inside `cmd/cue`:
we'll do that in a subsequent change. For now, we verify that all the
old behavior is still maintained despite the internal refactoring.

As part of this work, also implement an `AllHosts` method that we can
use to address the duplicate registry parsing logic in `cue login` by
allowing that command to introspect all the hosts that need to be logged
into.

Also update the `ociregistry` dependency to the latest version so we
can use the new `ociref.IsValid*` functions.

For #2816.

It provides a way to fix (most of) that specific issue by using the `hashAsPath`
path encoding, which avoids the restriction on the number of path
elements in a repository. It does not address #2817.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I5a5d7576c237e4844a0e7b3455cbdd781dc7fa19
cueckoo pushed a commit that referenced this issue Feb 19, 2024
In-the-wild registries can have significant restrictions on the names
that can be stored. Here we implement a more general resolver that can
be configured with a configuration file.

The schema for that configuration file is held in
internal/mod/modresolve/schema.cue; all the field names and arrangement
of that configuration are provisional.

The key property here is that a module is always stored with exactly the
same blob and manifest files regardless of the registry, but the mapping
from (module, version) to (repository, tag) can vary arbitrarily
according to the configuration.

The existing `modmux` registry multiplexer is now no longer sufficient,
because there is no longer always a one-to-one relationship between
modules and OCI repositories.

So we change the layering so that the modregistry package directly knows
about multiple registries, using the new `modresolve.Resolver` interface
to tell it where modules live.

The `modcache` package now takes a `*modregistry.Client` directly, which
doesn't actually affect its core logic much at all because it only ever
used that type internally anyway.

We don't yet wire up the new configuration file logic inside `cmd/cue`:
we'll do that in a subsequent change. For now, we verify that all the
old behavior is still maintained despite the internal refactoring.

As part of this work, also implement an `AllHosts` method that we can
use to address the duplicate registry parsing logic in `cue login` by
allowing that command to introspect all the hosts that need to be logged
into.

Also update the `ociregistry` dependency to the latest version so we
can use the new `ociref.IsValid*` functions.

For #2816.

It provides a way to fix (most of) that specific issue by using the `hashAsPath`
path encoding, which avoids the restriction on the number of path
elements in a repository. It does not address #2817.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I5a5d7576c237e4844a0e7b3455cbdd781dc7fa19
cueckoo pushed a commit that referenced this issue Feb 19, 2024
In-the-wild registries can have significant restrictions on the names
that can be stored. Here we implement a more general resolver that can
be configured with a configuration file.

The schema for that configuration file is held in
internal/mod/modresolve/schema.cue; all the field names and arrangement
of that configuration are provisional.

The key property here is that a module is always stored with exactly the
same blob and manifest files regardless of the registry, but the mapping
from (module, version) to (repository, tag) can vary arbitrarily
according to the configuration.

The existing `modmux` registry multiplexer is now no longer sufficient,
because there is no longer always a one-to-one relationship between
modules and OCI repositories.

So we change the layering so that the modregistry package directly knows
about multiple registries, using the new `modresolve.Resolver` interface
to tell it where modules live.

The `modcache` package now takes a `*modregistry.Client` directly, which
doesn't actually affect its core logic much at all because it only ever
used that type internally anyway.

We don't yet wire up the new configuration file logic inside `cmd/cue`:
we'll do that in a subsequent change. For now, we verify that all the
old behavior is still maintained despite the internal refactoring.

As part of this work, also implement an `AllHosts` method that we can
use to address the duplicate registry parsing logic in `cue login` by
allowing that command to introspect all the hosts that need to be logged
into.

Also update the `ociregistry` dependency to the latest version so we
can use the new `ociref.IsValid*` functions.

For #2816.

It provides a way to fix (most of) that specific issue by using the `hashAsPath`
path encoding, which avoids the restriction on the number of path
elements in a repository. It does not address #2817.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I5a5d7576c237e4844a0e7b3455cbdd781dc7fa19
cueckoo pushed a commit that referenced this issue Feb 19, 2024
In-the-wild registries can have significant restrictions on the names
that can be stored. Here we implement a more general resolver that can
be configured with a configuration file.

The schema for that configuration file is held in
internal/mod/modresolve/schema.cue; all the field names and arrangement
of that configuration are provisional.

The key property here is that a module is always stored with exactly the
same blob and manifest files regardless of the registry, but the mapping
from (module, version) to (repository, tag) can vary arbitrarily
according to the configuration.

The existing `modmux` registry multiplexer is now no longer sufficient,
because there is no longer always a one-to-one relationship between
modules and OCI repositories.

So we change the layering so that the modregistry package directly knows
about multiple registries, using the new `modresolve.Resolver` interface
to tell it where modules live.

The `modcache` package now takes a `*modregistry.Client` directly, which
doesn't actually affect its core logic much at all because it only ever
used that type internally anyway.

We don't yet wire up the new configuration file logic inside `cmd/cue`:
we'll do that in a subsequent change. For now, we verify that all the
old behavior is still maintained despite the internal refactoring.

As part of this work, also implement an `AllHosts` method that we can
use to address the duplicate registry parsing logic in `cue login` by
allowing that command to introspect all the hosts that need to be logged
into.

Also update the `ociregistry` dependency to the latest version so we
can use the new `ociref.IsValid*` functions.

For #2816.

It provides a way to fix (most of) that specific issue by using the `hashAsPath`
path encoding, which avoids the restriction on the number of path
elements in a repository. It does not address #2817.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I5a5d7576c237e4844a0e7b3455cbdd781dc7fa19
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1176978
Reviewed-by: Paul Jolly <paul@myitcv.io>
TryBot-Result: CUEcueckoo <cueckoo@gmail.com>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
cueckoo pushed a commit that referenced this issue Feb 19, 2024
This hooks up the support for registry configuration added
in https://cuelang.org/cl/1176978 to the `cue` command.
This allows a user to affect how modules are stored
in a custom registry, allowing them to work around
some common restrictions such as repository name depth
or availability.

Fixes #2816.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: Id76337bcdda9103c84ccb23b372161c1f62d6da3
cueckoo pushed a commit that referenced this issue Feb 19, 2024
This hooks up the support for registry configuration added in
https://cuelang.org/cl/1176978 to the `cue` command. This allows a user
to affect how modules are stored in a custom registry, allowing them to
work around some common restrictions such as repository name depth or
availability.

Fixes #2816.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: Id76337bcdda9103c84ccb23b372161c1f62d6da3
cueckoo pushed a commit that referenced this issue Feb 19, 2024
This hooks up the support for registry configuration added in
https://cuelang.org/cl/1176978 to the `cue` command. This allows a user
to affect how modules are stored in a custom registry, allowing them to
work around some common restrictions such as repository name depth or
availability.

We still need to document this format in the help, but that's
substantial enough that we'll leave it for another CL.

Fixes #2816.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: Id76337bcdda9103c84ccb23b372161c1f62d6da3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules Issues related to CUE modules and the experimental implementation
Projects
Archived in project
Status: v0.8.0-alpha.3
Development

No branches or pull requests

1 participant