Skip to content

Commit

Permalink
Infra proxy API to get the organisation of chef server (#6363)
Browse files Browse the repository at this point in the history
* Get organisation of infra server from chef server API added

Signed-off-by: sonali wale <swale@msystechnologies.com>

* minor changes added

Signed-off-by: sonali wale <swale@msystechnologies.com>

* Test cases added

Signed-off-by: sonali wale <swale@msystechnologies.com>

* Changes added in test cases

Signed-off-by: sonali wale <swale@msystechnologies.com>

* Added some changes in test cases

Signed-off-by: sonali wale <swale@msystechnologies.com>

* Removed test cases to check the existing one

Signed-off-by: sonali wale <swale@msystechnologies.com>

* added test cases changes

Signed-off-by: sonali wale <swale@msystechnologies.com>

* incorporating review comments

Signed-off-by: sonali wale <swale@msystechnologies.com>

* Minor changes added in test cases

Signed-off-by: sonali wale <swale@msystechnologies.com>

* added some logs

Signed-off-by: sonali wale <swale@msystechnologies.com>

* changes added in test cases

Signed-off-by: sonali wale <swale@msystechnologies.com>

* test cases changes added

Signed-off-by: sonali wale <swale@msystechnologies.com>

* Fixes added for repo health status

Signed-off-by: sonali wale <swale@msystechnologies.com>

* Fix added for repo health failure

Signed-off-by: sonali wale <swale@msystechnologies.com>

* Changes added in bash script of add users to remove credential id from users table

Signed-off-by: sonali wale <swale@msystechnologies.com>

* Conflicts resolved

Signed-off-by: sonali wale <swale@msystechnologies.com>
  • Loading branch information
sonali523 authored and vinay033 committed Apr 18, 2022
1 parent 34d5730 commit 1279052
Show file tree
Hide file tree
Showing 23 changed files with 2,349 additions and 1,652 deletions.
16 changes: 9 additions & 7 deletions .studio/infra-proxy-service
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,15 @@ function infra_service_load_sample_users() {
done
shift $((OPTIND -1))

local timestamp=$(date +%s%N)
local server_prefix="chef-server-${timestamp}"
local server_id="${server_prefix}-id"
local timestamp
local server_prefix
local server_id
local fqdn="api.chef.io"
local ip_address=$(printf "%d.%d.%d.%d" "$((RANDOM % 256))" "$((RANDOM % 256))" "$((RANDOM % 256))" "$((RANDOM % 256))")
local ip_address
timestamp=$(date +%s%N)
server_prefix="chef-server-${timestamp}"
server_id="${server_prefix}-id"
ip_address=$(printf "%d.%d.%d.%d" "$((RANDOM % 256))" "$((RANDOM % 256))" "$((RANDOM % 256))" "$((RANDOM % 256))")
# Add server in automate
chef-automate dev grpcurl infra-proxy-service -- -d \
"$(cat << EOF
Expand All @@ -315,16 +319,14 @@ EOF
timestamp=$(date +%s%N)
local userId="${user_prefix}-${timestamp}-id"
local infraServerUsername="infra-user-${timestamp}"
local credentialId="${user_prefix}-${timestamp}-secrets"
local automateUserId="${user_prefix}-${timestamp}"
chef-automate dev psql -d chef_infra_proxy << EOF
INSERT INTO users (
id, server_id,
infra_server_username,
credential_id,
automate_user_id,
created_at,updated_at)
VALUES ('${userId}', '${server_id}', '${infraServerUsername}', '${credentialId}','${automateUserId}',now(), now())
VALUES ('${userId}', '${server_id}', '${infraServerUsername}','${automateUserId}',now(), now())
EOF
done
log_line "Sample data loaded of $records users for server with server name '$server_prefix' and server id '$server_id'"
Expand Down
2,020 changes: 1,039 additions & 981 deletions api/external/infra_proxy/infra_proxy.pb.go

Large diffs are not rendered by default.

98 changes: 98 additions & 0 deletions api/external/infra_proxy/infra_proxy.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions api/external/infra_proxy/infra_proxy.pb.policy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions api/external/infra_proxy/infra_proxy.proto
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ service InfraProxy {
option (chef.automate.api.iam.policy).resource = "infra:infraServers:{server_id}:orgs:{id}";
option (chef.automate.api.iam.policy).action = "infra:infraServers:update";
};
rpc GetInfraServerOrgs (infra_proxy.request.GetInfraServerOrgs) returns (infra_proxy.response.GetInfraServerOrgs) {
option (google.api.http).get = "/api/v0/infra/servers/{server_id}/infraserverorgs";
option (chef.automate.api.iam.policy).resource = "infra:infraServers:{server_id}:infraserverorgs";
option (chef.automate.api.iam.policy).action = "infra:infraServers:get";
};

rpc GetCookbooks (infra_proxy.request.Cookbooks) returns (infra_proxy.response.Cookbooks) {
option (google.api.http).get = "/api/v0/infra/servers/{server_id}/orgs/{org_id}/cookbooks";
Expand Down
43 changes: 43 additions & 0 deletions api/external/infra_proxy/infra_proxy.swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 77 additions & 13 deletions api/external/infra_proxy/request/orgs.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions api/external/infra_proxy/request/orgs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@ message ResetOrgAdminKey {
// Chef organization admin key.
string admin_key = 3;
}

message GetInfraServerOrgs {
// Automate Infra Server ID
string server_id = 1;
}
Loading

0 comments on commit 1279052

Please sign in to comment.