Skip to content

Commit

Permalink
handle catalog or package artifacts, turn on features gates, print ch…
Browse files Browse the repository at this point in the history
…anges from default feature gates

Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
  • Loading branch information
joelanford committed Jun 15, 2023
1 parent f0e6bc2 commit 2d94e2d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
7 changes: 7 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

for f, spec := range features.CatalogdFeatureGate.GetAll() {
enabled := features.CatalogdFeatureGate.Enabled(f)
if spec.Default != enabled {
setupLog.Info("non-default feature gate in use", "name", f, "enabled", enabled)
}
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Expand Down
1 change: 1 addition & 0 deletions config/default/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ spec:
- "--health-probe-bind-address=:8081"
- "--metrics-bind-address=127.0.0.1:8080"
- "--leader-elect"
- "--feature-gates=AllAlpha=true"
4 changes: 2 additions & 2 deletions config/samples/core_v1alpha1_catalog.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: catalogd.operatorframework.io/v1alpha1
kind: Catalog
metadata:
name: rukpak
name: oci-artifacts
spec:
source:
type: ociArtifact
ociArtifact:
ref: docker.io/joelanford/rukpak:package
ref: docker.io/joelanford/catalog:catalog
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/blang/semver/v4 v4.0.0
github.com/docker/distribution v2.8.2+incompatible
github.com/joelanford/olm-oci v0.0.0-20230615031122-9f1a79d7a8d0
github.com/joelanford/olm-oci v0.0.0-20230615195914-7bf78ccd70ce
github.com/nlepage/go-tarfs v1.1.0
github.com/onsi/ginkgo/v2 v2.9.7
github.com/onsi/gomega v1.27.7
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,8 @@ github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht
github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8=
github.com/joelanford/ignore v0.0.0-20210607151042-0d25dc18b62d h1:A2/B900ip/Z20TzkLeGRNy1s6J2HmH9AmGt+dHyqb4I=
github.com/joelanford/ignore v0.0.0-20210607151042-0d25dc18b62d/go.mod h1:7HQupe4vyNxMKXmM5DFuwXHsqwMyglcYmZBtlDPIcZ8=
github.com/joelanford/olm-oci v0.0.0-20230615031122-9f1a79d7a8d0 h1:l5O1C8faChiczVSukfaXINWHvSK5jWBzr1yaeUKaHDU=
github.com/joelanford/olm-oci v0.0.0-20230615031122-9f1a79d7a8d0/go.mod h1:xUB0M2dWTR09ugrFcOzZ70MHc0IFieJT0fudQDRqRlg=
github.com/joelanford/olm-oci v0.0.0-20230615195914-7bf78ccd70ce h1:5lictZWgwAj9/LaowombYhvcMjOaMc7xSMNClYsrcsI=
github.com/joelanford/olm-oci v0.0.0-20230615195914-7bf78ccd70ce/go.mod h1:xUB0M2dWTR09ugrFcOzZ70MHc0IFieJT0fudQDRqRlg=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
Expand Down
24 changes: 17 additions & 7 deletions internal/source/ociartifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,42 @@ func (i *OCIArtifact) Unpack(ctx context.Context, catalog *catalogdv1alpha1.Cata
return nil, fmt.Errorf("parse reference: %v", err)
}

ignoreMediaTypes := []string{pkg.MediaTypeBundleContent}

desc, err := repo.Resolve(ctx, ref.String())
if err != nil {
return nil, fmt.Errorf("resolve reference: %v", err)
}
if err := oras.CopyGraph(ctx, repo, i.LocalStore, desc, oras.CopyGraphOptions{
Concurrency: runtime.NumCPU(),
FindSuccessors: fetch.IgnoreMediaTypes(pkg.MediaTypeBundleContent),
FindSuccessors: fetch.IgnoreMediaTypes(ignoreMediaTypes...),
}); err != nil {
return nil, fmt.Errorf("pull artifact to local storage: %v", err)
}

art, err := fetch.FetchArtifact(ctx, i.LocalStore, desc)
if err != nil {
return nil, fmt.Errorf("fetch artifact: %v", err)
return nil, fmt.Errorf("fetch artifact descriptor: %v", err)
}

if art.ArtifactType != pkg.MediaTypePackage {
return nil, fmt.Errorf("unsupported artifact type %q", desc.ArtifactType)
type toFBCer interface {
ToFBC(context.Context, string) (*declcfg.DeclarativeConfig, error)
}

p, err := fetch.FetchPackage(ctx, i.LocalStore, art, pkg.MediaTypeBundleContent)
var tfbc toFBCer
switch art.ArtifactType {
case pkg.MediaTypeCatalog:
tfbc, err = fetch.FetchCatalog(ctx, i.LocalStore, art, ignoreMediaTypes...)
case pkg.MediaTypePackage:
tfbc, err = fetch.FetchPackage(ctx, i.LocalStore, art, ignoreMediaTypes...)
default:
return nil, fmt.Errorf("unsupported artifact type %q", desc.ArtifactType)
}
if err != nil {
return nil, fmt.Errorf("fetch package: %v", err)
return nil, fmt.Errorf("fetch artifact: %v", err)
}

fbc, err := p.ToFBC(ctx, ref.Name(), p.Channels[0].Metadata.Name)
fbc, err := tfbc.ToFBC(ctx, ref.Name())
if err != nil {
return nil, fmt.Errorf("convert to FBC: %v", err)
}
Expand Down

0 comments on commit 2d94e2d

Please sign in to comment.