Skip to content

Commit dbd541f

Browse files
author
Per Goncalves da Silva
committed
fixes
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent 9db6178 commit dbd541f

Some content is hidden

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

58 files changed

+1661
-830
lines changed

.bingo/Variables.mk

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ $(KIND): $(BINGO_DIR)/kind.mod
4141
@echo "(re)installing $(GOBIN)/kind-v0.23.0"
4242
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=kind.mod -o=$(GOBIN)/kind-v0.23.0 "sigs.k8s.io/kind"
4343

44-
SETUP_ENVTEST := $(GOBIN)/setup-envtest-v0.0.0-20240522175850-2e9781e9fc60
44+
SETUP_ENVTEST := $(GOBIN)/setup-envtest-v0.0.0-20240813183042-b901db121e1f
4545
$(SETUP_ENVTEST): $(BINGO_DIR)/setup-envtest.mod
4646
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
47-
@echo "(re)installing $(GOBIN)/setup-envtest-v0.0.0-20240522175850-2e9781e9fc60"
48-
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=setup-envtest.mod -o=$(GOBIN)/setup-envtest-v0.0.0-20240522175850-2e9781e9fc60 "sigs.k8s.io/controller-runtime/tools/setup-envtest"
47+
@echo "(re)installing $(GOBIN)/setup-envtest-v0.0.0-20240813183042-b901db121e1f"
48+
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=setup-envtest.mod -o=$(GOBIN)/setup-envtest-v0.0.0-20240813183042-b901db121e1f "sigs.k8s.io/controller-runtime/tools/setup-envtest"
4949

5050
YQ := $(GOBIN)/yq-v3.0.0-20201202084205-8846255d1c37
5151
$(YQ): $(BINGO_DIR)/yq.mod

.bingo/setup-envtest.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ go 1.22.0
44

55
toolchain go1.22.3
66

7-
require sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20240522175850-2e9781e9fc60
7+
require sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20240813183042-b901db121e1f

.bingo/setup-envtest.sum

+9
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
22
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
33
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
44
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
5+
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
6+
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
57
github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ=
68
github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg=
9+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
710
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
811
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
912
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
@@ -27,12 +30,18 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
2730
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
2831
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
2932
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
33+
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
34+
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
3035
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
3136
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3237
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
3338
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
3439
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
3540
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20240522175850-2e9781e9fc60 h1:ihaeBTCFuEYPL1T1/FqAavDY7z5UcKSnWpnb+I3DYeM=
3641
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20240522175850-2e9781e9fc60/go.mod h1:4+4tM2Es0ycqPedATtzPer5RTrUq3Xab59BYogt0mCE=
42+
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20240813183042-b901db121e1f h1:RIqUbZQO5yizUt9nozxQdzyLRD1sG6s2oi/QZrlg/hs=
43+
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20240813183042-b901db121e1f/go.mod h1:IaDsO8xSPRxRG1/rm9CP7+jPmj0nMNAuNi/yiHnLX8k=
3744
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
3845
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
46+
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
47+
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=

.bingo/variables.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ HELM="${GOBIN}/helm-v3.15.1"
1616

1717
KIND="${GOBIN}/kind-v0.23.0"
1818

19-
SETUP_ENVTEST="${GOBIN}/setup-envtest-v0.0.0-20240522175850-2e9781e9fc60"
19+
SETUP_ENVTEST="${GOBIN}/setup-envtest-v0.0.0-20240813183042-b901db121e1f"
2020

2121
YQ="${GOBIN}/yq-v3.0.0-20201202084205-8846255d1c37"
2222

go.mod

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ require (
4848
k8s.io/kube-aggregator v0.31.0
4949
k8s.io/kube-openapi v0.0.0-20240816214639-573285566f34
5050
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
51-
sigs.k8s.io/controller-runtime v0.18.5
51+
sigs.k8s.io/controller-runtime v0.19.0
5252
sigs.k8s.io/controller-tools v0.16.1
5353
)
5454

@@ -180,10 +180,10 @@ require (
180180

181181
// pin to v1.18.0 until k8s.io/component-base updates its prometheus dependency
182182
// issue: https://github.com/operator-framework/operator-lifecycle-manager/issues/3283
183-
replace (
184-
github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.18.0
185-
github.com/prometheus/common => github.com/prometheus/common v0.47.0
186-
)
183+
//replace (
184+
// github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.18.0
185+
// github.com/prometheus/common => github.com/prometheus/common v0.47.0
186+
//)
187187

188188
// v1.64.0 breaks our e2e tests as it affects the grpc connection state transition
189189
// issue: https://github.com/operator-framework/operator-lifecycle-manager/issues/3284

go.sum

+6-6
Original file line numberDiff line numberDiff line change
@@ -1842,17 +1842,17 @@ github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qR
18421842
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
18431843
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
18441844
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1845-
github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk=
1846-
github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA=
1845+
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
1846+
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
18471847
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
18481848
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
18491849
github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
18501850
github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU=
18511851
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
18521852
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
18531853
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
1854-
github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k=
1855-
github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc=
1854+
github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
1855+
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
18561856
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
18571857
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
18581858
github.com/redis/go-redis/extra/rediscmd/v9 v9.0.5 h1:EaDatTxkdHG+U3Bk4EUr+DZ7fOGwTfezUiUJMaIcaho=
@@ -2916,8 +2916,8 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
29162916
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
29172917
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 h1:2770sDpzrjjsAtVhSeUFseziht227YAWYHLGNM8QPwY=
29182918
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw=
2919-
sigs.k8s.io/controller-runtime v0.18.5 h1:nTHio/W+Q4aBlQMgbnC5hZb4IjIidyrizMai9P6n4Rk=
2920-
sigs.k8s.io/controller-runtime v0.18.5/go.mod h1:TVoGrfdpbA9VRFaRnKgk9P5/atA0pMwq+f+msb9M8Sg=
2919+
sigs.k8s.io/controller-runtime v0.19.0 h1:nWVM7aq+Il2ABxwiCizrVDSlmDcshi9llbaFbC0ji/Q=
2920+
sigs.k8s.io/controller-runtime v0.19.0/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4=
29212921
sigs.k8s.io/controller-tools v0.16.1 h1:gvIsZm+2aimFDIBiDKumR7EBkc+oLxljoUVfRbDI6RI=
29222922
sigs.k8s.io/controller-tools v0.16.1/go.mod h1:0I0xqjR65YTfoO12iR+mZR6s6UAVcUARgXRlsu0ljB0=
29232923
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=

pkg/controller/install/attributes_util.go

+22-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package install
22

33
import (
4+
"fmt"
5+
46
log "github.com/sirupsen/logrus"
57
corev1 "k8s.io/api/core/v1"
68
rbacv1 "k8s.io/api/rbac/v1"
@@ -12,7 +14,7 @@ import (
1214
// toAttributesSet converts the given user, namespace, and PolicyRule into a set of Attributes expected. This is useful for checking
1315
// if a composed set of Roles/RoleBindings satisfies a PolicyRule.
1416
func toAttributesSet(user user.Info, namespace string, rule rbacv1.PolicyRule) []authorizer.Attributes {
15-
set := map[authorizer.AttributesRecord]struct{}{}
17+
set := map[string]authorizer.Attributes{}
1618

1719
// add empty string for empty groups, resources, resource names, and non resource urls
1820
groups := rule.APIGroups
@@ -37,18 +39,18 @@ func toAttributesSet(user user.Info, namespace string, rule rbacv1.PolicyRule) [
3739
for _, resource := range resources {
3840
for _, name := range names {
3941
for _, nonResourceURL := range nonResourceURLs {
40-
set[attributesRecord(user, namespace, verb, group, resource, name, nonResourceURL)] = struct{}{}
42+
attr := attributesRecord(user, namespace, verb, group, resource, name, nonResourceURL)
43+
key := attributesKey(user, namespace, verb, group, resource, name, nonResourceURL)
44+
set[key] = attr
4145
}
4246
}
4347
}
4448
}
4549
}
4650

47-
attributes := make([]authorizer.Attributes, len(set))
48-
i := 0
49-
for attribute := range set {
50-
attributes[i] = attribute
51-
i++
51+
attributes := make([]authorizer.Attributes, 0, len(set))
52+
for _, attribute := range set {
53+
attributes = append(attributes, attribute)
5254
}
5355
log.Debugf("attributes set %+v", attributes)
5456

@@ -77,3 +79,16 @@ func toDefaultInfo(sa *corev1.ServiceAccount) *user.DefaultInfo {
7779
UID: string(sa.GetUID()),
7880
}
7981
}
82+
83+
func attributesKey(user user.Info, namespace, verb, apiGroup, resource, name, path string) string {
84+
return fmt.Sprintf("%s|%s|%s|%s|%s|%s|%s|%s",
85+
user.GetName(),
86+
verb,
87+
namespace,
88+
apiGroup,
89+
resource,
90+
name,
91+
resource,
92+
path,
93+
)
94+
}

pkg/controller/install/attributes_util_test.go

+34-33
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestToAttributeSet(t *testing.T) {
1919
tests := []struct {
2020
description string
2121
rule rbacv1.PolicyRule
22-
expectedAttributes map[authorizer.AttributesRecord]struct{}
22+
expectedAttributes map[string]authorizer.AttributesRecord
2323
}{
2424
{
2525
description: "SimpleRule",
@@ -28,8 +28,8 @@ func TestToAttributeSet(t *testing.T) {
2828
APIGroups: []string{"*"},
2929
Resources: []string{"*"},
3030
},
31-
expectedAttributes: map[authorizer.AttributesRecord]struct{}{
32-
attributesRecord(user, namespace, "*", "*", "*", "", ""): {},
31+
expectedAttributes: map[string]authorizer.AttributesRecord{
32+
attributesKey(user, namespace, "*", "*", "*", "", ""): attributesRecord(user, namespace, "*", "*", "*", "", ""),
3333
},
3434
},
3535
{
@@ -38,8 +38,8 @@ func TestToAttributeSet(t *testing.T) {
3838
Verbs: []string{"*"},
3939
NonResourceURLs: []string{"/api"},
4040
},
41-
expectedAttributes: map[authorizer.AttributesRecord]struct{}{
42-
attributesRecord(user, namespace, "*", "", "", "", "/api"): {},
41+
expectedAttributes: map[string]authorizer.AttributesRecord{
42+
attributesKey(user, namespace, "*", "", "", "", "/api"): attributesRecord(user, namespace, "*", "", "", "", "/api"),
4343
},
4444
},
4545
{
@@ -49,9 +49,9 @@ func TestToAttributeSet(t *testing.T) {
4949
APIGroups: []string{"*"},
5050
Resources: []string{"*"},
5151
},
52-
expectedAttributes: map[authorizer.AttributesRecord]struct{}{
53-
attributesRecord(user, namespace, "create", "*", "*", "", ""): {},
54-
attributesRecord(user, namespace, "delete", "*", "*", "", ""): {},
52+
expectedAttributes: map[string]authorizer.AttributesRecord{
53+
attributesKey(user, namespace, "create", "*", "*", "", ""): attributesRecord(user, namespace, "create", "*", "*", "", ""),
54+
attributesKey(user, namespace, "delete", "*", "*", "", ""): attributesRecord(user, namespace, "delete", "*", "*", "", ""),
5555
},
5656
},
5757
{
@@ -60,11 +60,11 @@ func TestToAttributeSet(t *testing.T) {
6060
Verbs: []string{"get", "update"},
6161
Resources: []string{"donuts", "coffee"},
6262
},
63-
expectedAttributes: map[authorizer.AttributesRecord]struct{}{
64-
attributesRecord(user, namespace, "get", "", "donuts", "", ""): {},
65-
attributesRecord(user, namespace, "update", "", "donuts", "", ""): {},
66-
attributesRecord(user, namespace, "get", "", "coffee", "", ""): {},
67-
attributesRecord(user, namespace, "update", "", "coffee", "", ""): {},
63+
expectedAttributes: map[string]authorizer.AttributesRecord{
64+
attributesKey(user, namespace, "get", "", "donuts", "", ""): attributesRecord(user, namespace, "get", "", "donuts", "", ""),
65+
attributesKey(user, namespace, "update", "", "donuts", "", ""): attributesRecord(user, namespace, "update", "", "donuts", "", ""),
66+
attributesKey(user, namespace, "get", "", "coffee", "", ""): attributesRecord(user, namespace, "get", "", "coffee", "", ""),
67+
attributesKey(user, namespace, "update", "", "coffee", "", ""): attributesRecord(user, namespace, "update", "", "coffee", "", ""),
6868
},
6969
},
7070
{
@@ -73,9 +73,9 @@ func TestToAttributeSet(t *testing.T) {
7373
Verbs: []string{"*"},
7474
NonResourceURLs: []string{"/capybaras", "/caviidaes"},
7575
},
76-
expectedAttributes: map[authorizer.AttributesRecord]struct{}{
77-
attributesRecord(user, namespace, "*", "", "", "", "/capybaras"): {},
78-
attributesRecord(user, namespace, "*", "", "", "", "/caviidaes"): {},
76+
expectedAttributes: map[string]authorizer.AttributesRecord{
77+
attributesKey(user, namespace, "*", "", "", "", "/capybaras"): attributesRecord(user, namespace, "*", "", "", "", "/capybaras"),
78+
attributesKey(user, namespace, "*", "", "", "", "/caviidaes"): attributesRecord(user, namespace, "*", "", "", "", "/caviidaes"),
7979
},
8080
},
8181
{
@@ -85,11 +85,11 @@ func TestToAttributeSet(t *testing.T) {
8585
Resources: []string{"donuts", "coffee"},
8686
ResourceNames: []string{"nyc"},
8787
},
88-
expectedAttributes: map[authorizer.AttributesRecord]struct{}{
89-
attributesRecord(user, namespace, "get", "", "donuts", "nyc", ""): {},
90-
attributesRecord(user, namespace, "update", "", "donuts", "nyc", ""): {},
91-
attributesRecord(user, namespace, "get", "", "coffee", "nyc", ""): {},
92-
attributesRecord(user, namespace, "update", "", "coffee", "nyc", ""): {},
88+
expectedAttributes: map[string]authorizer.AttributesRecord{
89+
attributesKey(user, namespace, "get", "", "donuts", "nyc", ""): attributesRecord(user, namespace, "get", "", "donuts", "nyc", ""),
90+
attributesKey(user, namespace, "update", "", "donuts", "nyc", ""): attributesRecord(user, namespace, "update", "", "donuts", "nyc", ""),
91+
attributesKey(user, namespace, "get", "", "coffee", "nyc", ""): attributesRecord(user, namespace, "get", "", "coffee", "nyc", ""),
92+
attributesKey(user, namespace, "update", "", "coffee", "nyc", ""): attributesRecord(user, namespace, "update", "", "coffee", "nyc", ""),
9393
},
9494
},
9595
{
@@ -100,21 +100,21 @@ func TestToAttributeSet(t *testing.T) {
100100
APIGroups: []string{"apps.coreos.com", "apps.redhat.com"},
101101
ResourceNames: []string{"nyc"},
102102
},
103-
expectedAttributes: map[authorizer.AttributesRecord]struct{}{
104-
attributesRecord(user, namespace, "get", "apps.coreos.com", "donuts", "nyc", ""): {},
105-
attributesRecord(user, namespace, "update", "apps.coreos.com", "donuts", "nyc", ""): {},
106-
attributesRecord(user, namespace, "get", "apps.coreos.com", "coffee", "nyc", ""): {},
107-
attributesRecord(user, namespace, "update", "apps.coreos.com", "coffee", "nyc", ""): {},
108-
attributesRecord(user, namespace, "get", "apps.redhat.com", "donuts", "nyc", ""): {},
109-
attributesRecord(user, namespace, "update", "apps.redhat.com", "donuts", "nyc", ""): {},
110-
attributesRecord(user, namespace, "get", "apps.redhat.com", "coffee", "nyc", ""): {},
111-
attributesRecord(user, namespace, "update", "apps.redhat.com", "coffee", "nyc", ""): {},
103+
expectedAttributes: map[string]authorizer.AttributesRecord{
104+
attributesKey(user, namespace, "get", "apps.coreos.com", "donuts", "nyc", ""): attributesRecord(user, namespace, "get", "apps.coreos.com", "donuts", "nyc", ""),
105+
attributesKey(user, namespace, "update", "apps.coreos.com", "donuts", "nyc", ""): attributesRecord(user, namespace, "update", "apps.coreos.com", "donuts", "nyc", ""),
106+
attributesKey(user, namespace, "get", "apps.coreos.com", "coffee", "nyc", ""): attributesRecord(user, namespace, "get", "apps.coreos.com", "coffee", "nyc", ""),
107+
attributesKey(user, namespace, "update", "apps.coreos.com", "coffee", "nyc", ""): attributesRecord(user, namespace, "update", "apps.coreos.com", "coffee", "nyc", ""),
108+
attributesKey(user, namespace, "get", "apps.redhat.com", "donuts", "nyc", ""): attributesRecord(user, namespace, "get", "apps.redhat.com", "donuts", "nyc", ""),
109+
attributesKey(user, namespace, "update", "apps.redhat.com", "donuts", "nyc", ""): attributesRecord(user, namespace, "update", "apps.redhat.com", "donuts", "nyc", ""),
110+
attributesKey(user, namespace, "get", "apps.redhat.com", "coffee", "nyc", ""): attributesRecord(user, namespace, "get", "apps.redhat.com", "coffee", "nyc", ""),
111+
attributesKey(user, namespace, "update", "apps.redhat.com", "coffee", "nyc", ""): attributesRecord(user, namespace, "update", "apps.redhat.com", "coffee", "nyc", ""),
112112
},
113113
},
114114
{
115115
description: "NoVerbs",
116116
rule: rbacv1.PolicyRule{},
117-
expectedAttributes: map[authorizer.AttributesRecord]struct{}{},
117+
expectedAttributes: map[string]authorizer.AttributesRecord{},
118118
},
119119
}
120120

@@ -130,11 +130,12 @@ func TestToAttributeSet(t *testing.T) {
130130
require.True(t, ok, "type assertion for attributes failed")
131131

132132
// make sure we're expecting the attribute
133-
_, exists := tt.expectedAttributes[a]
133+
key := attributesKey(a.GetUser(), a.GetNamespace(), a.GetVerb(), a.GetAPIGroup(), a.GetResource(), a.GetName(), a.GetPath())
134+
_, exists := tt.expectedAttributes[key]
134135
require.True(t, exists, fmt.Sprintf("found unexpected attributes %v", attributes))
135136

136137
// ensure each expected attribute only appears once
137-
delete(tt.expectedAttributes, a)
138+
delete(tt.expectedAttributes, key)
138139
}
139140

140141
// check that all expected have been found

pkg/controller/operators/operatorconditiongenerator_controller.go

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func (r *OperatorConditionGeneratorReconciler) SetupWithManager(mgr ctrl.Manager
6262
}
6363

6464
return ctrl.NewControllerManagedBy(mgr).
65+
Named("operator-condition-generator").
6566
For(&operatorsv1alpha1.ClusterServiceVersion{}, builder.WithPredicates(p)).
6667
Watches(&operatorsv2.OperatorCondition{}, handler).
6768
Complete(r)

0 commit comments

Comments
 (0)