Skip to content
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] Add environments & expanded_run_lists attributes in Roles API #3236

Merged
merged 7 commits into from
Mar 31, 2020

Conversation

kvivek1115
Copy link

@kvivek1115 kvivek1115 commented Mar 28, 2020

🔩 Description: What code changed, and why?

  • Add description, environments attributes in Roles list API.
  • Add default_attributes, override_attributes and expanded_run_list attributes in role detail API.
  • Implement required helpers to recursively find the runlist roles and expand those runlist as children.

⛓️ Related Resources

#1544
Mock UI Ref:
role-detail-based-on-env

👍 Definition of Done

  • GetRoles API now returns name, description, and environments.
  • GetRole detail API now also returns default_attributes, override_attributes and expanded_run_list.

👟 How to Build and Test the Change

Steps to build:

  • rebuild components/infra-proxy-service
  • rebuild components/automate-gateway

Steps to test:

  • Add required credentials e.g. test chef infra server env.

gPRC GetRoles API:

chef-automate dev grpcurl automate-gateway chef.automate.api.infra_proxy.InfraProxy.GetRole -- -d '{"server_id": "SERVER_ID", "org_id": "ORG_ID"}'

HTTP GetRoles API:

curl -sSkH "api-token: $TOK" https://a2-dev.test/api/v0/infra/servers/SERVER_ID/orgs/ORG_ID/roles

Response:

{"roles":[{"name":"starter","description":"An example Chef role","environments":["_default"]},{"name":"web_server","description":"A role to configure our front-line web servers","environments":["_default","production","testing"]}]}

gPRC GetRole API:

chef-automate dev grpcurl automate-gateway chef.automate.api.infra_proxy.InfraProxy.GetRole -- -d '{"server_id": "SERVER_ID", "org_id": "ORG_ID", "name":"ROLE_NAME"}'

HTTP GetRole API:

curl -sSkH "api-token: $TOK" https://a2-dev.test/api/v0/infra/servers/SERVER_ID/orgs/ORG_ID/roles/ROLE_NAME

Response:

{"name":"web_server","chef_type":"role","description":"A role to configure our front-line web servers","default_attributes":"{\"nginx\":{\"log_location\":\"/var/log/nginx.log\"}}","override_attributes":"{\"nginx\":{\"gzip\":\"on\"}}","json_class":"Chef::Role","run_list":["recipe[apt]","recipe[nginx]"],"expanded_run_list":[{"id":"_default","run_list":[{"type":"recipe","name":"apt","version":"","skipped":false,"children":[]},{"type":"recipe","name":"nginx","version":"","skipped":false,"children":[]}]},{"id":"production","run_list":[{"type":"recipe","name":"nginx::config_prod","version":"","skipped":false,"children":[]}]},{"id":"testing","run_list":[{"type":"recipe","name":"nginx::config_test","version":"","skipped":false,"children":[]}]}]}

✅ Checklist

📷 Screenshots, if applicable

go.sum Outdated
@@ -68,8 +68,8 @@ github.com/census-ecosystem/opencensus-go-exporter-aws v0.0.0-20180411051634-416
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chef/go-chef v0.3.1-0.20191115205148-7ac24fba7a27 h1:zb1dtm/zUcVrxyDd50XtovQFSQa26y2jJt2Dt7IzDQQ=
github.com/chef/go-chef v0.3.1-0.20191115205148-7ac24fba7a27/go.mod h1:ft8oU7s0ktse9xzZO4n8wxTz6EKx+V+fuhYxktqXvG8=
github.com/chef/go-chef v0.4.1-0.20200328065122-dfce3c0d2dc7 h1:+MU0TcZz3tfQTYEo2RwWe7AmaYkL7RB83KPcNsEXJTk=
Copy link
Author

Choose a reason for hiding this comment

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

Updated the go-chef lib to pull the latest changes and apply make revendor

@kagarmoe kagarmoe added the documentation Anything related to the Automate docs. label Mar 30, 2020
@kvivek1115 kvivek1115 force-pushed the VSingh/infra-proxy-service-roles-api-update branch from b3900f5 to c17503c Compare March 30, 2020 19:59
@kvivek1115 kvivek1115 requested a review from a team as a code owner March 30, 2020 19:59
return &response.DataBags{
DataBags: fromAPIToListDatabags(*dataBags),
}, nil
dataBags, err := client.DataBags.List()
Copy link
Author

Choose a reason for hiding this comment

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

Observed minor cleanup to skip else if if have return statements.

Vivek Singh added 7 commits April 1, 2020 00:35
 - Update the go-chef lib.
 - Add environment base runlist and expand the runlist.

Signed-off-by: Vivek Singh <[email protected]>
Signed-off-by: Vivek Singh <[email protected]>
Signed-off-by: Vivek Singh <[email protected]>
 - update the go-chef lib with latest master
 - go get -u github.com/chef/go-chef@master

Signed-off-by: Vivek Singh <[email protected]>
@kvivek1115 kvivek1115 force-pushed the VSingh/infra-proxy-service-roles-api-update branch from 85572ea to 7aa99e4 Compare March 31, 2020 19:22
@vjeffrey vjeffrey merged commit cb5d0f3 into master Mar 31, 2020
@chef-expeditor chef-expeditor bot deleted the VSingh/infra-proxy-service-roles-api-update branch March 31, 2020 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automate-infra-proxy documentation Anything related to the Automate docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants