Skip to content

Commit d2f369f

Browse files
authored
Merge pull request #20 from stacklok/oci-skills-registry-client
Add OCI skills registry client for push/pull operations
2 parents 1b6a967 + f05a75e commit d2f369f

5 files changed

Lines changed: 914 additions & 5 deletions

File tree

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ require (
66
github.com/adrg/xdg v0.5.3
77
github.com/google/cel-go v0.27.0
88
github.com/opencontainers/go-digest v1.0.0
9+
github.com/opencontainers/image-spec v1.1.1
910
github.com/stretchr/testify v1.11.1
1011
go.uber.org/mock v0.6.0
1112
golang.org/x/net v0.49.0
13+
oras.land/oras-go/v2 v2.6.0
1214
)
1315

1416
require (
@@ -17,6 +19,7 @@ require (
1719
github.com/davecgh/go-spew v1.1.1 // indirect
1820
github.com/pmezard/go-difflib v1.0.0 // indirect
1921
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 // indirect
22+
golang.org/x/sync v0.19.0 // indirect
2023
golang.org/x/sys v0.40.0 // indirect
2124
golang.org/x/text v0.33.0 // indirect
2225
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
1212
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
1313
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
1414
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
15+
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=
16+
github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M=
1517
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1618
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1719
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
@@ -24,6 +26,8 @@ golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 h1:kx6Ds3MlpiUHKj7syVnbp57++
2426
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
2527
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
2628
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
29+
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
30+
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
2731
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
2832
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
2933
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
@@ -38,3 +42,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+
3842
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3943
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
4044
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
45+
oras.land/oras-go/v2 v2.6.0 h1:X4ELRsiGkrbeox69+9tzTu492FMUu7zJQW6eJU+I2oc=
46+
oras.land/oras-go/v2 v2.6.0/go.mod h1:magiQDfG6H1O9APp+rOsvCPcW1GD2MM7vgnKY0Y+u1o=

oci/skills/doc.go

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
/*
5-
Package skills provides OCI artifact types, media types, and local storage for
6-
ToolHive skill packages.
5+
Package skills provides OCI artifact types, media types, local storage, and
6+
remote registry operations for ToolHive skill packages.
77
88
A skill is an OCI artifact containing MCP server configuration, prompt files,
9-
and metadata. This package defines the constants, data structures, and storage
10-
layer that the rest of the ToolHive ecosystem uses to package, push, pull, and
11-
cache skills as OCI images.
9+
and metadata. This package defines the constants, data structures, storage
10+
layer, and registry client that the rest of the ToolHive ecosystem uses to
11+
package, push, pull, and cache skills as OCI images.
1212
1313
# Media Types and Constants
1414
@@ -25,6 +25,26 @@ Standard OCI media types and ToolHive-specific annotation/label keys:
2525
skills.LabelSkillName
2626
skills.LabelSkillFiles
2727
28+
# Registry Client
29+
30+
The [Registry] type implements [RegistryClient] for pushing and pulling skill
31+
artifacts to/from OCI-compliant registries (GHCR, ECR, Docker Hub, etc.).
32+
It uses ORAS for registry operations and the Docker credential store for
33+
authentication by default:
34+
35+
reg, err := skills.NewRegistry()
36+
// Push an artifact
37+
err = reg.Push(ctx, store, indexDigest, "ghcr.io/myorg/my-skill:v1.0.0")
38+
// Pull an artifact
39+
digest, err := reg.Pull(ctx, store, "ghcr.io/myorg/my-skill:v1.0.0")
40+
41+
Use functional options to customise behaviour:
42+
43+
reg, err := skills.NewRegistry(
44+
skills.WithPlainHTTP(true), // for local dev registries
45+
skills.WithCredentialStore(myStore), // custom auth
46+
)
47+
2848
# Stability
2949
3050
This package is Alpha. Breaking changes are possible between minor versions.

0 commit comments

Comments
 (0)