Skip to content

Commit

Permalink
(entitySource) Use catalogd provided content for sourcing entities
Browse files Browse the repository at this point in the history
This PR replaces OLM v0 catalog operator with https://github.com/operator-framework/catalogd
as the source of entities for deppy.

Addresses operator-framework#161

Signed-off-by: Anik <anikbhattacharya93@gmail.com>
  • Loading branch information
anik120 committed Apr 27, 2023
1 parent 29a5cc9 commit 61d29dc
Show file tree
Hide file tree
Showing 14 changed files with 319 additions and 124 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor

# Binaries for programs and plugins
*.exe
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export IMAGE_REPO ?= quay.io/operator-framework/operator-controller
export IMAGE_TAG ?= devel
export GO_BUILD_TAGS ?= upstream
export CERT_MGR_VERSION ?= v1.9.0
export CATALOGD_VERSION ?= v0.1.2
export GORELEASER_VERSION ?= v1.16.2
export OLM_V0_VERSION ?= v0.24.0
export RUKPAK_VERSION=$(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/rukpak)
export WAIT_TIMEOUT ?= 60s
IMG?=$(IMAGE_REPO):$(IMAGE_TAG)
Expand Down Expand Up @@ -147,7 +147,7 @@ release: goreleaser ## Runs goreleaser for the operator-controller. By default,
quickstart: export MANIFEST="https://github.com/operator-framework/operator-controller/releases/download/$(VERSION)/operator-controller.yaml"
quickstart: kustomize generate ## Generate the installation release manifests and scripts
kubectl kustomize config/default | sed "s/:devel/:$(VERSION)/g" > operator-controller.yaml
envsubst '$$OLM_V0_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh
envsubst '$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$CATALOGD_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh

##@ Deployment

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

.PHONY: uninstall
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.
Expand Down
16 changes: 16 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ metadata:
creationTimestamp: null
name: manager-role
rules:
- apiGroups:
- catalogd.operatorframework.io
resources:
- bundlemetadata
verbs:
- get
- list
- watch
- apiGroups:
- catalogd.operatorframework.io
resources:
- packages
verbs:
- get
- list
- watch
- apiGroups:
- core.rukpak.io
resources:
Expand Down
6 changes: 6 additions & 0 deletions config/samples/catalogd_operatorcatalog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: catalogd.operatorframework.io/v1beta1
kind: CatalogSource
metadata:
name: operatorhubio
spec:
image: quay.io/operatorhubio/catalog:latest
2 changes: 1 addition & 1 deletion config/samples/operators_v1alpha1_operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ metadata:
name: operator-sample
spec:
# TODO(user): Add fields here
packageName: prometheus
packageName: argocd-operator
15 changes: 4 additions & 11 deletions controllers/operator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,11 @@ type OperatorReconciler struct {

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

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
// TODO(user): Modify the Reconcile function to compare the state specified by
// the Operator object against the actual cluster state, and then
// perform operations to make the cluster state reflect the state specified by
// the user.
//
// For more details, check Reconcile and its Result here:
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.13.1/pkg/reconcile
//+kubebuilder:rbac:groups=catalogd.operatorframework.io,resources=bundlemetadata,verbs=get;list;watch
//+kubebuilder:rbac:groups=catalogd.operatorframework.io,resources=packages,verbs=get;list;watch

func (r *OperatorReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
l := log.FromContext(ctx).WithName("reconcile")
l := log.FromContext(ctx).WithName("operator-controller")
l.V(1).Info("starting")
defer l.V(1).Info("ending")

Expand Down Expand Up @@ -121,7 +115,6 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
})
return ctrl.Result{}, nil
}

// run resolution
solution, err := r.Resolver.Resolve(ctx)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion controllers/operator_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
operatorutil "github.com/operator-framework/operator-controller/internal/util"
)

var _ = Describe("Reconcile Test", func() {
var _ = Describe("Operator Controller Test", func() {
var (
ctx context.Context
reconciler *controllers.OperatorReconciler
Expand Down
11 changes: 8 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ require (
github.com/blang/semver/v4 v4.0.0
github.com/onsi/ginkgo/v2 v2.8.3
github.com/onsi/gomega v1.27.1
github.com/operator-framework/catalogd v0.1.0
github.com/operator-framework/deppy v0.0.0-20230125110717-dc02e928470f
github.com/operator-framework/operator-registry v1.26.2
github.com/operator-framework/operator-registry v1.26.3
github.com/operator-framework/rukpak v0.12.0
go.uber.org/zap v1.24.0
k8s.io/apimachinery v0.26.1
Expand Down Expand Up @@ -38,7 +39,7 @@ require (
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -47,16 +48,18 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/operator-framework/api v0.17.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
Expand All @@ -70,9 +73,11 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.26.1 // indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/apiserver v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
sigs.k8s.io/apiserver-runtime v1.1.2-0.20221226021050-33c901856927 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
Expand Down
Loading

0 comments on commit 61d29dc

Please sign in to comment.