Skip to content

Commit 0469e7f

Browse files
committed
(entitySource) Use catalogd provided content for sourcing entities
This PR replaces OLM v0 catalog operator with https://github.com/operator-framework/catalogd as the source of entities for deppy. Addresses #161 Signed-off-by: Anik <[email protected]>
1 parent 3218d2c commit 0469e7f

File tree

9 files changed

+331
-364
lines changed

9 files changed

+331
-364
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
vendor
12

23
# Binaries for programs and plugins
34
*.exe

Makefile

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export IMAGE_TAG ?= devel
77
export GO_BUILD_TAGS ?= upstream
88
export CERT_MGR_VERSION ?= v1.9.0
99
export GORELEASER_VERSION ?= v1.16.2
10-
export OLM_V0_VERSION ?= v0.24.0
1110
export RUKPAK_VERSION=$(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/rukpak)
1211
export WAIT_TIMEOUT ?= 60s
1312
IMG?=$(IMAGE_REPO):$(IMAGE_TAG)
@@ -147,7 +146,7 @@ release: goreleaser ## Runs goreleaser for the operator-controller. By default,
147146
quickstart: export MANIFEST="https://github.com/operator-framework/operator-controller/releases/download/$(VERSION)/operator-controller.yaml"
148147
quickstart: kustomize generate ## Generate the installation release manifests and scripts
149148
kubectl kustomize config/default | sed "s/:devel/:$(VERSION)/g" > operator-controller.yaml
150-
envsubst '$$OLM_V0_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh
149+
envsubst '$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh
151150

152151
##@ Deployment
153152

@@ -159,7 +158,7 @@ endif
159158
install: export MANIFEST="./operator-controller.yaml"
160159
install: manifests kustomize generate ## Install CRDs into the K8s cluster specified in ~/.kube/config.
161160
kubectl kustomize config/default > operator-controller.yaml
162-
envsubst '$$OLM_V0_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
161+
envsubst '$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
163162

164163
.PHONY: uninstall
165164
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.

config/rbac/role.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ metadata:
55
creationTimestamp: null
66
name: manager-role
77
rules:
8+
- apiGroups:
9+
- catalogd.operatorframework.io
10+
resources:
11+
- bundlemetadata
12+
verbs:
13+
- get
14+
- list
15+
- watch
16+
- apiGroups:
17+
- catalogd.operatorframework.io
18+
resources:
19+
- packages
20+
verbs:
21+
- get
22+
- list
23+
- watch
824
- apiGroups:
925
- core.rukpak.io
1026
resources:

controllers/operator_controller.go

+13-10
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838

3939
operatorsv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
4040
"github.com/operator-framework/operator-controller/internal/resolution"
41+
"github.com/operator-framework/operator-controller/internal/resolution/entitysources"
4142
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/bundles_and_dependencies"
4243
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/entity"
4344
)
@@ -55,15 +56,9 @@ type OperatorReconciler struct {
5556

5657
//+kubebuilder:rbac:groups=core.rukpak.io,resources=bundledeployments,verbs=get;list;watch;create;update;patch
5758

58-
// Reconcile is part of the main kubernetes reconciliation loop which aims to
59-
// move the current state of the cluster closer to the desired state.
60-
// TODO(user): Modify the Reconcile function to compare the state specified by
61-
// the Operator object against the actual cluster state, and then
62-
// perform operations to make the cluster state reflect the state specified by
63-
// the user.
64-
//
65-
// For more details, check Reconcile and its Result here:
66-
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
59+
//+kubebuilder:rbac:groups=catalogd.operatorframework.io,resources=bundlemetadata,verbs=get;list;watch
60+
//+kubebuilder:rbac:groups=catalogd.operatorframework.io,resources=packages,verbs=get;list;watch
61+
6762
func (r *OperatorReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
6863
l := log.FromContext(ctx).WithName("reconcile")
6964
l.V(1).Info("starting")
@@ -121,7 +116,15 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
121116
})
122117
return ctrl.Result{}, nil
123118
}
124-
119+
if r.Resolver == nil {
120+
// create an entity source from operator catalogs' metadata on-cluster
121+
entitySource, err := entitysources.NewCatalogdEntitySource(ctx, r.Client)
122+
if err != nil {
123+
return ctrl.Result{}, err
124+
}
125+
// create a resolver with the entity source
126+
r.Resolver = resolution.NewOperatorResolver(r.Client, entitySource)
127+
}
125128
// run resolution
126129
solution, err := r.Resolver.Resolve(ctx)
127130
if err != nil {

go.mod

+35-41
Original file line numberDiff line numberDiff line change
@@ -4,83 +4,77 @@ go 1.19
44

55
require (
66
github.com/blang/semver/v4 v4.0.0
7-
github.com/onsi/ginkgo/v2 v2.3.1
8-
github.com/onsi/gomega v1.22.1
7+
github.com/onsi/ginkgo/v2 v2.6.0
8+
github.com/onsi/gomega v1.24.1
9+
github.com/operator-framework/catalogd v0.1.0
910
github.com/operator-framework/deppy v0.0.0-20230125110717-dc02e928470f
10-
github.com/operator-framework/operator-registry v1.26.2
11+
github.com/operator-framework/operator-registry v1.26.3
1112
github.com/operator-framework/rukpak v0.11.0
12-
go.uber.org/zap v1.21.0
13-
k8s.io/apimachinery v0.25.0
14-
k8s.io/client-go v0.25.0
15-
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
16-
sigs.k8s.io/controller-runtime v0.13.1
13+
go.uber.org/zap v1.24.0
14+
k8s.io/apimachinery v0.26.0
15+
k8s.io/client-go v0.26.0
16+
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
17+
sigs.k8s.io/controller-runtime v0.14.0
1718
)
1819

1920
require (
20-
cloud.google.com/go v0.97.0 // indirect
21-
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
22-
github.com/Azure/go-autorest/autorest v0.11.27 // indirect
23-
github.com/Azure/go-autorest/autorest/adal v0.9.20 // indirect
24-
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
25-
github.com/Azure/go-autorest/logger v0.2.1 // indirect
26-
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
27-
github.com/PuerkitoBio/purell v1.1.1 // indirect
28-
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
2921
github.com/beorn7/perks v1.0.1 // indirect
3022
github.com/cespare/xxhash/v2 v2.1.2 // indirect
3123
github.com/davecgh/go-spew v1.1.1 // indirect
32-
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
24+
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
3325
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
3426
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
35-
github.com/fsnotify/fsnotify v1.5.4 // indirect
27+
github.com/fsnotify/fsnotify v1.6.0 // indirect
3628
github.com/go-air/gini v1.0.4 // indirect
3729
github.com/go-logr/logr v1.2.3 // indirect
3830
github.com/go-logr/zapr v1.2.3 // indirect
3931
github.com/go-openapi/jsonpointer v0.19.5 // indirect
40-
github.com/go-openapi/jsonreference v0.19.5 // indirect
32+
github.com/go-openapi/jsonreference v0.20.0 // indirect
4133
github.com/go-openapi/swag v0.19.14 // indirect
4234
github.com/gogo/protobuf v1.3.2 // indirect
43-
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
4435
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
4536
github.com/golang/protobuf v1.5.2 // indirect
4637
github.com/google/gnostic v0.5.7-v3refs // indirect
47-
github.com/google/go-cmp v0.5.8 // indirect
38+
github.com/google/go-cmp v0.5.9 // indirect
4839
github.com/google/gofuzz v1.2.0 // indirect
49-
github.com/google/uuid v1.2.0 // indirect
40+
github.com/google/uuid v1.3.0 // indirect
5041
github.com/imdario/mergo v0.3.12 // indirect
5142
github.com/josharian/intern v1.0.0 // indirect
5243
github.com/json-iterator/go v1.1.12 // indirect
5344
github.com/mailru/easyjson v0.7.6 // indirect
54-
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
45+
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
5546
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5647
github.com/modern-go/reflect2 v1.0.2 // indirect
5748
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
49+
github.com/operator-framework/api v0.17.2-0.20220915200120-ff2dbc53d381 // indirect
5850
github.com/pkg/errors v0.9.1 // indirect
59-
github.com/prometheus/client_golang v1.12.2 // indirect
60-
github.com/prometheus/client_model v0.2.0 // indirect
61-
github.com/prometheus/common v0.32.1 // indirect
62-
github.com/prometheus/procfs v0.7.3 // indirect
51+
github.com/prometheus/client_golang v1.14.0 // indirect
52+
github.com/prometheus/client_model v0.3.0 // indirect
53+
github.com/prometheus/common v0.37.0 // indirect
54+
github.com/prometheus/procfs v0.8.0 // indirect
55+
github.com/sirupsen/logrus v1.9.0 // indirect
6356
github.com/spf13/pflag v1.0.5 // indirect
6457
go.uber.org/atomic v1.7.0 // indirect
6558
go.uber.org/multierr v1.6.0 // indirect
66-
golang.org/x/crypto v0.0.0-20220408190544-5352b0902921 // indirect
67-
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
68-
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
69-
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
70-
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
71-
golang.org/x/text v0.3.7 // indirect
72-
golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect
59+
golang.org/x/net v0.4.0 // indirect
60+
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
61+
golang.org/x/sys v0.3.0 // indirect
62+
golang.org/x/term v0.3.0 // indirect
63+
golang.org/x/text v0.5.0 // indirect
64+
golang.org/x/time v0.3.0 // indirect
7365
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
7466
google.golang.org/appengine v1.6.7 // indirect
75-
google.golang.org/protobuf v1.28.0 // indirect
67+
google.golang.org/protobuf v1.28.1 // indirect
7668
gopkg.in/inf.v0 v0.9.1 // indirect
7769
gopkg.in/yaml.v2 v2.4.0 // indirect
7870
gopkg.in/yaml.v3 v3.0.1 // indirect
79-
k8s.io/api v0.25.0 // indirect
80-
k8s.io/apiextensions-apiserver v0.25.0 // indirect
81-
k8s.io/component-base v0.25.0 // indirect
82-
k8s.io/klog/v2 v2.70.1 // indirect
83-
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
71+
k8s.io/api v0.26.0 // indirect
72+
k8s.io/apiextensions-apiserver v0.26.0 // indirect
73+
k8s.io/apiserver v0.26.0 // indirect
74+
k8s.io/component-base v0.26.0 // indirect
75+
k8s.io/klog/v2 v2.80.1 // indirect
76+
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
77+
sigs.k8s.io/apiserver-runtime v1.1.2-0.20221226021050-33c901856927 // indirect
8478
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
8579
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
8680
sigs.k8s.io/yaml v1.3.0 // indirect

0 commit comments

Comments
 (0)