Skip to content

Conversation

hasbro17
Copy link
Contributor

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

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"
Copy link
Contributor

@fanminshi fanminshi Apr 27, 2018

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.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"AppService" -> appKind


buf = &bytes.Buffer{}
if err := renderRBACYaml(buf, projectName); err != nil {
if err := renderRBACYaml(buf, projectName, groupName(apiVersion)); err != nil {
Copy link
Contributor

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() {
Copy link
Contributor

@fanminshi fanminshi Apr 27, 2018

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() {
Copy link
Contributor

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.

@hasbro17
Copy link
Contributor Author

@fanminshi fixed. PTAL.

@fanminshi
Copy link
Contributor

lgtm

@hasbro17 hasbro17 merged commit 1efc94a into operator-framework:master Apr 27, 2018
@hasbro17 hasbro17 deleted the haseeb/restrict-rbac-rules branch April 27, 2018 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants