Skip to content

Commit 1b6a967

Browse files
authored
Merge pull request #19 from stacklok/oci-skills-store
Add OCI skills store, interfaces, and mocks
2 parents d1c91d9 + e24e12f commit 1b6a967

6 files changed

Lines changed: 751 additions & 0 deletions

File tree

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ module github.com/stacklok/toolhive-core
33
go 1.25.7
44

55
require (
6+
github.com/adrg/xdg v0.5.3
67
github.com/google/cel-go v0.27.0
8+
github.com/opencontainers/go-digest v1.0.0
79
github.com/stretchr/testify v1.11.1
810
go.uber.org/mock v0.6.0
911
golang.org/x/net v0.49.0
@@ -15,6 +17,7 @@ require (
1517
github.com/davecgh/go-spew v1.1.1 // indirect
1618
github.com/pmezard/go-difflib v1.0.0 // indirect
1719
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 // indirect
20+
golang.org/x/sys v0.40.0 // indirect
1821
golang.org/x/text v0.33.0 // indirect
1922
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect
2023
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cel.dev/expr v0.25.1 h1:1KrZg61W6TWSxuNZ37Xy49ps13NUovb66QLprthtwi4=
22
cel.dev/expr v0.25.1/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4=
3+
github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78=
4+
github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ=
35
github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=
46
github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw=
57
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -8,6 +10,8 @@ github.com/google/cel-go v0.27.0 h1:e7ih85+4qVrBuqQWTW4FKSqZYokVuc3HnhH5keboFTo=
810
github.com/google/cel-go v0.27.0/go.mod h1:tTJ11FWqnhw5KKpnWpvW9CJC3Y9GK4EIS0WXnBbebzw=
911
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
1012
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
13+
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
14+
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
1115
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1216
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1317
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
@@ -20,6 +24,8 @@ golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 h1:kx6Ds3MlpiUHKj7syVnbp57++
2024
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
2125
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
2226
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
27+
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
28+
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
2329
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
2430
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
2531
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 h1:YcyjlL1PRr2Q17/I0dPk2JmYS5CDXfcdb2Z3YRioEbw=

oci/skills/interfaces.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// SPDX-FileCopyrightText: Copyright 2026 Stacklok, Inc.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package skills
5+
6+
//go:generate mockgen -source=interfaces.go -destination=mocks/mock_interfaces.go -package=mocks
7+
8+
import (
9+
"context"
10+
"time"
11+
12+
"github.com/opencontainers/go-digest"
13+
)
14+
15+
// RegistryClient provides remote OCI registry operations for skills.
16+
type RegistryClient interface {
17+
// Push pushes an artifact from the local store to a remote registry.
18+
Push(ctx context.Context, store *Store, manifestDigest digest.Digest, ref string) error
19+
20+
// Pull pulls an artifact from a remote registry into the local store.
21+
Pull(ctx context.Context, store *Store, ref string) (digest.Digest, error)
22+
}
23+
24+
// SkillPackager creates OCI artifacts from skill directories.
25+
type SkillPackager interface {
26+
// Package packages a skill directory into an OCI artifact in the local store.
27+
Package(ctx context.Context, skillDir string, opts PackageOptions) (*PackageResult, error)
28+
}
29+
30+
// PackageOptions configures skill packaging.
31+
type PackageOptions struct {
32+
// Epoch is the timestamp to use for reproducible builds.
33+
Epoch time.Time
34+
35+
// Platforms specifies target platforms for the image index.
36+
// If empty, defaults to DefaultPlatforms.
37+
Platforms []Platform
38+
}
39+
40+
// PackageResult contains the result of packaging a skill.
41+
type PackageResult struct {
42+
IndexDigest digest.Digest
43+
ManifestDigest digest.Digest
44+
ConfigDigest digest.Digest
45+
LayerDigest digest.Digest
46+
Config *SkillConfig
47+
Platforms []Platform
48+
}

oci/skills/mocks/mock_interfaces.go

Lines changed: 111 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)