-
Notifications
You must be signed in to change notification settings - Fork 113
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
Auth 1840/configure project limit #2029
Conversation
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.
Code looks good so far! I would add a few more tests.
After rebuilding authz
and deployment
I tried to exercise it with these commands (from #1840) but either my toml is wrong or I haven't rebuilt something.
[8][default:/src:93]# cat <<EOF > authz2.toml
[authz.v1.sys.svc]
project_limit = 300
EOF
[9][default:/src:0]# chef-automate config patch authz2.toml
ConfigError: The configuration is invalid: Config file must be a valid automate config: unknown configuration keys:
authz.v1.sys.svc
authz.v1.sys.svc.project_limit
@@ -4410,7 +4410,9 @@ func TestCreateProject(t *testing.T) { | |||
} | |||
resp, err := store.CreateProject(ctx, &oneProjectTooMany) | |||
assert.Nil(t, resp) | |||
assert.Equal(t, storage_errors.ErrMaxProjectsExceeded, err) | |||
assert.Error(t, err) |
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.
could we add a test for configuring a different value for the project limit?
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.
we can't without refactoring the whole test suite :D but i'll do it for you if you want
lol it was not bad 😂
yah i also couldnt get that patch to work, but ive never tried to do that before either so maybe im doing something wrong |
8006a7c
to
e5fa1ed
Compare
02ef144
to
0e7bbb0
Compare
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.
Looks good! Just a few minor suggestions.
@@ -136,3 +136,15 @@ function install_go_tool() { | |||
fi | |||
done | |||
} | |||
|
|||
document "revendor" <<DOC |
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.
What does this do?
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.
api/config/authz/config_request.go
Outdated
|
||
if projectLimit != nil { | ||
if limit := projectLimit.GetValue(); limit < constants_v2.MaxProjects { | ||
e := errors.Errorf("invalid project limit of %v: must be minimum of %v", limit, constants_v2.MaxProjects) |
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.
Using "minimum" to describe a maximum seems confusing. Also, consider using a shorter phrase, e.g., just:
"project limit must be at least %v"
// MaxProjectsExceededError indicates that a new project cannot be created | ||
// since the max allowed are already created. | ||
func (e *MaxProjectsExceededError) Error() string { | ||
return fmt.Sprintf("violates project limit of %v", e.projectLimit) |
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.
Not clear what context is provided along with this text. But assuming this is the entirety of what the user sees, consider including the info in the comment on L83-84, e.g.
"cannot create project: limit of %v projects already reached"
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Ryan Cragun <ryan@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Ryan Cragun <ryan@chef.io>
0b475e8
to
bd60e4f
Compare
Signed-off-by: Blake Johnson <bstier@chef.io>
bd60e4f
to
2f1fd72
Compare
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.
sweet 👍 👍
closes #2076 |
🔩 Description: What code changed, and why?
⛓️ Related Resources
👍 Definition of Done
👟 How to Build and Test the Change
rebuild components/authz-service
rebuild components/automate-deployment
rebuild components/automate-cli
authz.toml contents:
chef-automate config patch authz.toml
Attempt to make more than 7 custom projects 💁(
curl -XPOST -d '{"name":"test", "id":"foo1-project"}' -H "api-token: $TOK" $TARGET_HOST/apis/iam/v2beta/projects --insecure
)✅ Checklist
📷 Screenshots, if applicable