-
Notifications
You must be signed in to change notification settings - Fork 1.8k
generator: restrict default RBAC rules #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generator: restrict default RBAC rules #200
Conversation
pkg/generator/generator_test.go
Outdated
buf := &bytes.Buffer{} | ||
projectName := "app-operator" | ||
if err := renderOperatorYaml(buf, "AppService", "app.example.com/v1alpha1", projectName, "quay.io/coreos/operator-sdk-dev:app-operator"); err != nil { | ||
apiVersion := "app.example.com/v1alpha1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are changing this test, it probably the best refactor this to use the global test constants
for app at line 23 for this test.
Also make projectName
a test constant as well.
pkg/generator/generator_test.go
Outdated
projectName := "app-operator" | ||
if err := renderOperatorYaml(buf, "AppService", "app.example.com/v1alpha1", projectName, "quay.io/coreos/operator-sdk-dev:app-operator"); err != nil { | ||
apiVersion := "app.example.com/v1alpha1" | ||
if err := renderOperatorYaml(buf, "AppService", apiVersion, projectName, "quay.io/coreos/operator-sdk-dev:app-operator"); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"AppService"
-> appKind
pkg/generator/generator_test.go
Outdated
|
||
buf = &bytes.Buffer{} | ||
if err := renderRBACYaml(buf, projectName); err != nil { | ||
if err := renderRBACYaml(buf, projectName, groupName(apiVersion)); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
groupName(apiVersion)
-> appGroupName
?
if err := renderOperatorYaml(buf, "AppService", apiVersion, projectName, "quay.io/coreos/operator-sdk-dev:app-operator"); err != nil { | ||
t.Error(err) | ||
} | ||
if operatorYamlExp != buf.String() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the test will pass if you don't change the expected result operatorYamlExp
. You might want to update that too.
nvm.
if err := renderRBACYaml(buf, projectName, groupName(apiVersion)); err != nil { | ||
t.Error(err) | ||
} | ||
if rbacYamlExp != buf.String() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might want to update the rbacYamlExp
or else this test won't pass.
@fanminshi fixed. PTAL. |
lgtm |
ref: #165
Restrict the default RBAC admin access rules.
Ideally the default rules should grant no privileges since the SDK does not know what resources an operator needs to access. Instead it would be expected that the user should update the RBAC manifest as needed by their operator.
However that means by default none of the operators(including our examples) would work out of the box.
So the current rules are an arbitrary middle ground to at least avoid giving admin access by default.
/cc @fanminshi