-
Notifications
You must be signed in to change notification settings - Fork 114
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
[infra-proxy-service] reset node client key, create client & delete client API #4592
Conversation
Deploy preview for chef-automate processing. Building with commit 929d43d https://app.netlify.com/sites/chef-automate/deploys/6024a0efed69810007630c19 |
Facing some trouble in Create Client API |
@shaik80 hope you have added the chef-server entry provided in the "Steps to test". Could you please verify with providing the output of:
|
Updated the client detail API containing public key data:
|
rpc DeleteClient (infra_proxy.request.Client) returns (infra_proxy.response.Client) { | ||
option (google.api.http).delete = "/api/v0/infra/servers/{server_id}/orgs/{org_id}/clients/{name}"; | ||
option (chef.automate.api.iam.policy).resource = "infra:servers:{server_id}:orgs:{org_id}:clients"; | ||
option (chef.automate.api.iam.policy).action = "infra:infraServers:update"; |
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.
check the other proto file, in case of get/update/delete this policy has differerent way to handle.
option (chef.automate.api.iam.policy).action = "infra:infraServers:delete";
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.
@punitmundra, here we handled it differently, in all action only get & update for all third-level objects like chef server >> chef organizations >> cookbooks| roles| clients | data bags
etc.
Please check the detailed discussion in PR #3550
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.
fine
string name = 3; | ||
// Boolean indicates client type is validator or not. | ||
bool validator = 4; | ||
// Boolean indicates whether it's required to create a key or not. |
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.
make the proper alinement
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 guess alignment looks okay here, any specific ask?
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.
It looks OK in some editors and it looks wrong in some editors--that is because you are mixing spaces and tabs. Please change to all spaces.
(This applies to several files.)
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.
Yeah, Due to some misconfiguration in my local VSCode. Have fixes for some files, will keep it for future in relevant files.
Thanks!
string name = 3; | ||
// Boolean indicates client type is validator or not. | ||
bool validator = 4; |
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.
make proper formatting
// Deletes the existing key | ||
_, err = c.client.Clients.DeleteKey(req.Name, key) | ||
chefError, _ := chef.ChefError(err) | ||
if err != nil && chefError.StatusCode() != 404 { |
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.
Ignore if the key already got deleted
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 have test the code locally and it gives the output as expected.
rpc DeleteClient (infra_proxy.request.Client) returns (infra_proxy.response.Client) { | ||
option (google.api.http).delete = "/api/v0/infra/servers/{server_id}/orgs/{org_id}/clients/{name}"; | ||
option (chef.automate.api.iam.policy).resource = "infra:servers:{server_id}:orgs:{org_id}:clients"; | ||
option (chef.automate.api.iam.policy).action = "infra:infraServers:update"; |
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.
fine
string name = 3; | ||
// Boolean indicates client type is validator or not. | ||
bool validator = 4; | ||
// Boolean indicates whether it's required to create a key or not. |
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.
It looks OK in some editors and it looks wrong in some editors--that is because you are mixing spaces and tabs. Please change to all spaces.
(This applies to several files.)
}, nil | ||
} | ||
|
||
// ResetClientKey resets an infra client |
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.
// ResetClientKey resets an infra client | |
// ResetClientKey resets an infra client key |
Also, could we explain what it means to reset a client key.
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.
Still: what does it mean to "reset a client key"? Does that mean set the key to null? ...to empty string? ...to a random string? or something else.
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.
In chef infra context, resetting the client key, deletes the associated key pair and generates new key pair again, and then attached it to the client.
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.
OK. That should be in the code comment, too.
@msorens have made the tabs to spaces changes it due to vscode issue microsoft/vscode-go#2871 good to review it again. |
Signed-off-by: Vivek Singh <[email protected]>
Signed-off-by: Vivek Singh <[email protected]>
Signed-off-by: Vivek Singh <[email protected]>
Signed-off-by: Vivek Singh <[email protected]>
Signed-off-by: Vivek Singh <[email protected]>
Signed-off-by: Vivek Singh <[email protected]>
Signed-off-by: Vivek Singh <[email protected]>
Signed-off-by: Vivek Singh <[email protected]>
0e959a9
to
2d638a1
Compare
} | ||
|
||
// ResetClientKey resets the client key | ||
// Deletes the associated key pair and generates new key pair again, and then attached it to the client. |
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.
// Deletes the associated key pair and generates new key pair again, and then attached it to the client. | |
// Deletes the associated key pair and generates new key pair again, and then attaches it to the client. |
Signed-off-by: Vivek Singh <[email protected]>
🔩 Description: What code changed, and why?
⛓️ Related Resources
👍 Definition of Done
create client
,delete client
and reset client chef server APIs.👟 How to Build and Test the Change
rebuild components/infra-proxy-service
rebuild components/automate-gateway
Steps to test:
Client detail API with appended default key data:
Create Client API
Delete Client API
Reset Client Key API
✅ Checklist
📷 Screenshots, if applicable
Signed-off-by: Vivek Singh [email protected]