Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ $(GINKGO): $(BINGO_DIR)/ginkgo.mod
@echo "(re)installing $(GOBIN)/ginkgo-v2.1.4"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=ginkgo.mod -o=$(GOBIN)/ginkgo-v2.1.4 "github.com/onsi/ginkgo/v2/ginkgo"

GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.53.3
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/golangci-lint-v1.53.3"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.53.3 "github.com/golangci/golangci-lint/cmd/golangci-lint"

GORELEASER := $(GOBIN)/goreleaser-v1.16.2
$(GORELEASER): $(BINGO_DIR)/goreleaser.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
Expand Down
2 changes: 1 addition & 1 deletion .bingo/bingo.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.19
go 1.20

require github.com/bwplotka/bingo v0.8.0
2 changes: 1 addition & 1 deletion .bingo/controller-gen.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.19
go 1.20

require sigs.k8s.io/controller-tools v0.10.0 // cmd/controller-gen
2 changes: 1 addition & 1 deletion .bingo/ginkgo.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.19
go 1.20

require github.com/onsi/ginkgo/v2 v2.1.4 // ginkgo
5 changes: 5 additions & 0 deletions .bingo/golangci-lint.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.19

require github.com/golangci/golangci-lint v1.53.3 // cmd/golangci-lint
954 changes: 954 additions & 0 deletions .bingo/golangci-lint.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .bingo/goreleaser.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.19
go 1.20

require github.com/goreleaser/goreleaser v1.16.2
2 changes: 1 addition & 1 deletion .bingo/kind.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.19
go 1.20

require sigs.k8s.io/kind v0.15.0
2 changes: 1 addition & 1 deletion .bingo/kustomize.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.19
go 1.20

require sigs.k8s.io/kustomize/kustomize/v4 v4.5.7
2 changes: 1 addition & 1 deletion .bingo/setup-envtest.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.19
go 1.20

require sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20230606045100-e54088c8c7da
2 changes: 2 additions & 0 deletions .bingo/variables.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ CONTROLLER_GEN="${GOBIN}/controller-gen-v0.10.0"

GINKGO="${GOBIN}/ginkgo-v2.1.4"

GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.53.3"

GORELEASER="${GOBIN}/goreleaser-v1.16.2"

KIND="${GOBIN}/kind-v0.15.0"
Expand Down
2 changes: 1 addition & 1 deletion .ci-operator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build_root_image:
namespace: openshift
name: release
tag: rhel-8-release-golang-1.19-openshift-4.14
tag: rhel-8-release-golang-1.20-openshift-4.14
31 changes: 31 additions & 0 deletions .github/workflows/sanity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: sanity

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
- name: Run verification checks
run: make verify
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v4
with:
go-version-file: "go.mod"

- name: Run golangci linting checks
run: make lint GOLANGCI_LINT_ARGS="--out-format github-actions"
51 changes: 51 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
run:
# Default timeout is 1m, up to give more room
timeout: 4m

linters:
enable:
- asciicheck
- bodyclose
- errorlint
- ginkgolinter
- gofmt
- goimports
- gosec
- importas
- misspell
- nestif
- nonamedreturns
- prealloc
- revive
- stylecheck
- tparallel
- unconvert
- unparam
- unused
- whitespace

linters-settings:
errorlint:
errorf: false

importas:
alias:
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
alias: metav1
- pkg: k8s.io/apimachinery/pkg/api/errors
alias: apierrors
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
alias: apiextensionsv1
- pkg: k8s.io/apimachinery/pkg/util/runtime
alias: utilruntime
- pkg: "^k8s\\.io/api/([^/]+)/(v[^/]+)$"
alias: $1$2
- pkg: sigs.k8s.io/controller-runtime
alias: ctrl
- pkg: github.com/operator-framework/rukpak/api/v1alpha1
alias: rukpakv1alpha1
goimports:
local-prefixes: github.com/operator-framework/operator-controller

output:
format: tab
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export IMAGE_REPO ?= quay.io/operator-framework/operator-controller
export IMAGE_TAG ?= devel
export CERT_MGR_VERSION ?= v1.9.0
export CATALOGD_VERSION ?= v0.2.0
export CATALOGD_VERSION ?= $(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/catalogd)
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 @@ -61,6 +61,14 @@ help: ## Display this help.

##@ Development

.PHONY: lint
lint: $(GOLANGCI_LINT) ## Run golangci linter.
$(GOLANGCI_LINT) run --build-tags $(GO_BUILD_TAGS) $(GOLANGCI_LINT_ARGS)

.PHONY: tidy
tidy: ## Update dependencies.
$(Q)go mod tidy

.PHONY: manifests
manifests: $(CONTROLLER_GEN) ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
Expand All @@ -69,6 +77,10 @@ manifests: $(CONTROLLER_GEN) ## Generate WebhookConfiguration, ClusterRole and C
generate: $(CONTROLLER_GEN) ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

.PHONY: verify
verify: tidy fmt generate ## Verify the current code generation.
git diff --exit-code

.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...
Expand Down Expand Up @@ -105,8 +117,10 @@ kind-cluster-cleanup: $(KIND) ## Delete the kind cluster

kind-load-test-artifacts: $(KIND) ## Load the e2e testdata container images into a kind cluster
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/bundles/registry-v1/prometheus-operator.v0.47.0 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v0.47.0
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/bundles/plain-v0/plain.v0.1.0 -t localhost/testdata/bundles/plain-v0/plain:v0.1.0
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/catalogs -f $(TESTDATA_DIR)/catalogs/test-catalog.Dockerfile -t localhost/testdata/catalogs/test-catalog:e2e
$(KIND) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v0.47.0 --name $(KIND_CLUSTER_NAME)
$(KIND) load docker-image localhost/testdata/bundles/plain-v0/plain:v0.1.0 --name $(KIND_CLUSTER_NAME)
$(KIND) load docker-image localhost/testdata/catalogs/test-catalog:e2e --name $(KIND_CLUSTER_NAME)

##@ Build
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/operator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type OperatorSpec struct {

//+kubebuilder:validation:MaxLength:=48
//+kubebuilder:validation:Pattern:=^[a-z0-9]+([\.-][a-z0-9]+)*$
// Channel constraint defintion
// Channel constraint definition
Channel string `json:"channel,omitempty"`
}

Expand Down
24 changes: 17 additions & 7 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"flag"
"os"

rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
"github.com/spf13/pflag"
"go.uber.org/zap/zapcore"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
Expand All @@ -30,11 +30,15 @@ import (
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

catalogd "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1"
catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
"github.com/operator-framework/deppy/pkg/deppy/solver"
rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"

operatorsv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
"github.com/operator-framework/operator-controller/internal/controllers"
"github.com/operator-framework/operator-controller/internal/resolution"
"github.com/operator-framework/operator-controller/internal/resolution/entitysources"
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/olm"
"github.com/operator-framework/operator-controller/pkg/features"
)

var (
Expand Down Expand Up @@ -65,7 +69,10 @@ func main() {
Development: true,
}
opts.BindFlags(flag.CommandLine)
flag.Parse()

pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
features.OperatorControllerFeatureGate.AddFlag(pflag.CommandLine)
pflag.Parse()

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts), zap.StacktraceLevel(zapcore.DPanicLevel)))

Expand Down Expand Up @@ -94,9 +101,12 @@ func main() {
}

if err = (&controllers.OperatorReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Resolver: resolution.NewOperatorResolver(mgr.GetClient(), entitysources.NewCatalogdEntitySource(mgr.GetClient())),
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Resolver: solver.NewDeppySolver(
entitysources.NewCatalogdEntitySource(mgr.GetClient()),
olm.NewOLMVariableSource(mgr.GetClient()),
),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Operator")
os.Exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
description: OperatorSpec defines the desired state of Operator
properties:
channel:
description: Channel constraint defintion
description: Channel constraint definition
maxLength: 48
pattern: ^[a-z0-9]+([\.-][a-z0-9]+)*$
type: string
Expand Down
4 changes: 2 additions & 2 deletions config/samples/catalogd_operatorcatalog.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: catalogd.operatorframework.io/v1beta1
apiVersion: catalogd.operatorframework.io/v1alpha1
kind: Catalog
metadata:
metadata:
name: operatorhubio
spec:
source:
Expand Down
28 changes: 14 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
module github.com/operator-framework/operator-controller

go 1.19
go 1.20

require (
github.com/blang/semver/v4 v4.0.0
github.com/go-logr/logr v1.2.3
github.com/onsi/ginkgo/v2 v2.8.3
github.com/onsi/gomega v1.27.1
github.com/operator-framework/catalogd v0.2.0
github.com/go-logr/logr v1.2.4
github.com/onsi/ginkgo/v2 v2.9.7
github.com/onsi/gomega v1.27.7
github.com/operator-framework/catalogd v0.3.0
github.com/operator-framework/deppy v0.0.0-20230602120738-cbf2c66b141b
github.com/operator-framework/operator-registry v1.26.3
github.com/operator-framework/rukpak v0.12.0
github.com/spf13/pflag v1.0.5
go.uber.org/zap v1.24.0
k8s.io/apimachinery v0.26.1
k8s.io/client-go v0.26.1
k8s.io/component-base v0.26.1
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
sigs.k8s.io/controller-runtime v0.14.4
)
Expand All @@ -31,10 +33,10 @@ require (
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
Expand All @@ -53,16 +55,15 @@ require (
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/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/net v0.10.0 // 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
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/tools v0.9.1 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
Expand All @@ -71,7 +72,6 @@ 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/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/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
Expand Down
Loading