Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/containerd/errdefs v1.0.0
github.com/containerd/typeurl/v2 v2.2.3
github.com/go-logr/logr v1.4.3
github.com/google/uuid v1.6.0
github.com/ipfs/go-cid v0.5.0
github.com/libp2p/go-libp2p v0.43.0
github.com/libp2p/go-libp2p-kad-dht v0.34.0
Expand Down Expand Up @@ -66,7 +67,6 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type RegistryCmd struct {
MirrorResolveRetries int `arg:"--mirror-resolve-retries,env:MIRROR_RESOLVE_RETRIES" default:"3" help:"Max amount of mirrors to attempt."`
ResolveLatestTag bool `arg:"--resolve-latest-tag,env:RESOLVE_LATEST_TAG" default:"true" help:"When true latest tags will be resolved to digests."`
DebugWebEnabled bool `arg:"--debug-web-enabled,env:DEBUG_WEB_ENABLED" default:"false" help:"When true enables debug web page."`
registry.PushConfig
}

type CleanupCmd struct {
Expand Down Expand Up @@ -184,6 +185,7 @@ func registryCommand(ctx context.Context, args *RegistryCmd) (err error) {
registry.WithResolveTimeout(args.MirrorResolveTimeout),
registry.WithLogger(log),
registry.WithBasicAuth(username, password),
registry.WithPushConfig(args.PushConfig),
}
reg, err := registry.NewRegistry(ociStore, router, registryOpts...)
if err != nil {
Expand Down
17 changes: 16 additions & 1 deletion pkg/oci/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var (
manifestRegexTag = regexp.MustCompile(`/v2/` + nameRegex.String() + `/manifests/` + tagRegex.String() + `$`)
manifestRegexDigest = regexp.MustCompile(`/v2/` + nameRegex.String() + `/manifests/(.*)`)
blobsRegexDigest = regexp.MustCompile(`/v2/` + nameRegex.String() + `/blobs/(.*)`)
blobsUploadsRegex = regexp.MustCompile(`/v2/` + nameRegex.String() + `/blobs/uploads/(.*)`)
)

// DistributionKind represents the kind of content.
Expand All @@ -26,15 +27,17 @@ type DistributionKind string
const (
DistributionKindManifest = "manifests"
DistributionKindBlob = "blobs"
DistributionKindUpload = "uploads"
)

// DistributionPath contains the individual parameters from a OCI distribution spec request.
// DistributionPath contains the individual parameters from an OCI distribution spec request.
type DistributionPath struct {
Kind DistributionKind
Name string
Digest digest.Digest
Tag string
Registry string
Session string
}

// Reference returns the digest if set or alternatively if not the full image reference with the tag.
Expand Down Expand Up @@ -96,6 +99,18 @@ func ParseDistributionPath(u *url.URL) (DistributionPath, error) {
}
return dist, nil
}
comps = blobsUploadsRegex.FindStringSubmatch(u.Path)
if len(comps) == 6 {
dgst := digest.Digest(u.Query().Get("digest"))
dist := DistributionPath{
Kind: DistributionKindUpload,
Name: comps[1],
Digest: dgst,
Registry: registry,
Session: comps[5],
}
return dist, nil
}
comps = blobsRegexDigest.FindStringSubmatch(u.Path)
if len(comps) == 6 {
dgst, err := digest.Parse(comps[5])
Expand Down
Loading