Skip to content

Commit 6e60e7e

Browse files
committed
IR-270: allow registry to create image objects
1 parent 8556fd4 commit 6e60e7e

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

pkg/resource/clusterrole.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (gcr *generatorClusterRole) expected() (runtime.Object, error) {
7575
},
7676
},
7777
{
78-
Verbs: []string{"get", "update" /*, "delete" */},
78+
Verbs: []string{"get", "update", "create"},
7979
APIGroups: []string{ /* "", */ "image.openshift.io"},
8080
Resources: []string{
8181
"images",

pkg/resource/clusterrole_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package resource
2+
3+
import (
4+
"reflect"
5+
"testing"
6+
7+
rbacapi "k8s.io/api/rbac/v1"
8+
)
9+
10+
func TestImageRules(t *testing.T) {
11+
generator := newGeneratorClusterRole(nil, nil)
12+
expected := rbacapi.PolicyRule{
13+
Verbs: []string{"get", "update", "create"},
14+
APIGroups: []string{"image.openshift.io"},
15+
Resources: []string{"images"},
16+
}
17+
r, err := generator.expected()
18+
if err != nil {
19+
t.Fatalf("error getting desired cluster role: %#v", err)
20+
}
21+
role, ok := r.(*rbacapi.ClusterRole)
22+
if !ok {
23+
t.Fatal("failed to cast object to ClusterRole")
24+
}
25+
26+
for _, rule := range role.Rules {
27+
if !reflect.DeepEqual(rule.Resources, expected.Resources) {
28+
continue
29+
}
30+
if !reflect.DeepEqual(rule.Verbs, expected.Verbs) {
31+
t.Error("images rule.Verbs differ")
32+
t.Errorf("want %#v", expected.Verbs)
33+
t.Errorf("got %#v", rule.Verbs)
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)