Skip to content

Commit 355dcf4

Browse files
Merge pull request #315 from openshift-bot/synchronize-upstream
NO-ISSUE: Synchronize From Upstream Repositories
2 parents ad55882 + 68f8273 commit 355dcf4

File tree

49 files changed

+6116
-282
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+6116
-282
lines changed

Makefile

+8-5
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,13 @@ custom-linter-build: #EXHELP Build custom linter
120120
lint-custom: custom-linter-build #EXHELP Call custom linter for the project
121121
go vet -tags=$(GO_BUILD_TAGS) -vettool=./bin/custom-linter ./...
122122

123-
.PHONY: tidy
124-
tidy: #HELP Update dependencies.
125-
# Force tidy to use the version already in go.mod
126-
$(Q)go mod tidy -go=$(GOLANG_VERSION)
123+
.PHONY: k8s-pin
124+
k8s-pin: #EXHELP Pin k8s staging modules based on k8s.io/kubernetes version (in go.mod or from K8S_IO_K8S_VERSION env var) and run go mod tidy.
125+
K8S_IO_K8S_VERSION='$(K8S_IO_K8S_VERSION)' go run hack/tools/k8smaintainer/main.go
126+
127+
.PHONY: tidy #HELP Run go mod tidy.
128+
tidy:
129+
go mod tidy
127130

128131
.PHONY: manifests
129132
KUSTOMIZE_CATD_CRDS_DIR := config/base/catalogd/crd/bases
@@ -151,7 +154,7 @@ generate: $(CONTROLLER_GEN) #EXHELP Generate code containing DeepCopy, DeepCopyI
151154
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) object:headerFile="hack/boilerplate.go.txt" paths="./..."
152155

153156
.PHONY: verify
154-
verify: tidy fmt generate manifests crd-ref-docs generate-test-data #HELP Verify all generated code is up-to-date.
157+
verify: k8s-pin fmt generate manifests crd-ref-docs generate-test-data #HELP Verify all generated code is up-to-date. Runs k8s-pin instead of just tidy.
155158
git diff --exit-code
156159

157160
# Renders registry+v1 bundles in test/convert

cmd/operator-controller/main.go

+19-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/containers/image/v5/types"
3232
"github.com/spf13/cobra"
3333
corev1 "k8s.io/api/core/v1"
34+
rbacv1 "k8s.io/api/rbac/v1"
3435
apiextensionsv1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1"
3536
"k8s.io/apimachinery/pkg/fields"
3637
k8slabels "k8s.io/apimachinery/pkg/labels"
@@ -56,6 +57,7 @@ import (
5657
"github.com/operator-framework/operator-controller/internal/operator-controller/action"
5758
"github.com/operator-framework/operator-controller/internal/operator-controller/applier"
5859
"github.com/operator-framework/operator-controller/internal/operator-controller/authentication"
60+
"github.com/operator-framework/operator-controller/internal/operator-controller/authorization"
5961
"github.com/operator-framework/operator-controller/internal/operator-controller/catalogmetadata/cache"
6062
catalogclient "github.com/operator-framework/operator-controller/internal/operator-controller/catalogmetadata/client"
6163
"github.com/operator-framework/operator-controller/internal/operator-controller/contentmanager"
@@ -178,6 +180,9 @@ func validateMetricsFlags() error {
178180
func run() error {
179181
setupLog.Info("starting up the controller", "version info", version.String())
180182

183+
// log feature gate status after parsing flags and setting up logger
184+
features.LogFeatureGateStates(setupLog, features.OperatorControllerFeatureGate)
185+
181186
authFilePath := filepath.Join(os.TempDir(), fmt.Sprintf("%s-%s.json", authFilePrefix, apimachineryrand.String(8)))
182187
var globalPullSecretKey *k8stypes.NamespacedName
183188
if cfg.globalPullSecret != "" {
@@ -197,8 +202,12 @@ func run() error {
197202
setupLog.Info("set up manager")
198203
cacheOptions := crcache.Options{
199204
ByObject: map[client.Object]crcache.ByObject{
200-
&ocv1.ClusterExtension{}: {Label: k8slabels.Everything()},
201-
&ocv1.ClusterCatalog{}: {Label: k8slabels.Everything()},
205+
&ocv1.ClusterExtension{}: {Label: k8slabels.Everything()},
206+
&ocv1.ClusterCatalog{}: {Label: k8slabels.Everything()},
207+
&rbacv1.ClusterRole{}: {Label: k8slabels.Everything()},
208+
&rbacv1.ClusterRoleBinding{}: {Label: k8slabels.Everything()},
209+
&rbacv1.Role{}: {Namespaces: map[string]crcache.Config{}, Label: k8slabels.Everything()},
210+
&rbacv1.RoleBinding{}: {Namespaces: map[string]crcache.Config{}, Label: k8slabels.Everything()},
202211
},
203212
DefaultNamespaces: map[string]crcache.Config{
204213
cfg.systemNamespace: {LabelSelector: k8slabels.Everything()},
@@ -403,10 +412,18 @@ func run() error {
403412
crdupgradesafety.NewPreflight(aeClient.CustomResourceDefinitions()),
404413
}
405414

415+
// determine if PreAuthorizer should be enabled based on feature gate
416+
var preAuth authorization.PreAuthorizer
417+
if features.OperatorControllerFeatureGate.Enabled(features.PreflightPermissions) {
418+
preAuth = authorization.NewRBACPreAuthorizer(mgr.GetClient())
419+
}
420+
421+
// now initialize the helmApplier, assigning the potentially nil preAuth
406422
helmApplier := &applier.Helm{
407423
ActionClientGetter: acg,
408424
Preflights: preflights,
409425
BundleToHelmChartFn: convert.RegistryV1ToHelmChart,
426+
PreAuthorizer: preAuth,
410427
}
411428

412429
cm := contentmanager.NewManager(clientRestConfigMapper, mgr.GetConfig(), mgr.GetRESTMapper())

codecov.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ coverage:
88
paths:
99
- "api/"
1010
- "cmd/"
11-
- "internal/"
11+
- "internal/"
12+

commitchecker.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
expectedMergeBase: c54b57144310a918a7e835b50f25be41496d2ab2
1+
expectedMergeBase: 543f099faf8fc2f2681498f74757a3251271670c
22
upstreamBranch: main
33
upstreamOrg: operator-framework
44
upstreamRepo: operator-controller

config/base/operator-controller/rbac/role.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ rules:
4747
verbs:
4848
- patch
4949
- update
50+
- apiGroups:
51+
- rbac.authorization.k8s.io
52+
resources:
53+
- clusterrolebindings
54+
- clusterroles
55+
- rolebindings
56+
- roles
57+
verbs:
58+
- list
59+
- watch
5060
---
5161
apiVersion: rbac.authorization.k8s.io/v1
5262
kind: Role

0 commit comments

Comments
 (0)