SREP-2441: Return the body of the error when backplane-api is unable to assume role by ratnam915 · Pull Request #825 · openshift/backplane-cli
This PR has been created to address the issue of backplane-cli gets an error from backplane-api while it is assuming a role
and only the status code 500 is displayed, this PR address the issue by printing the response body along with the error.
Changes made to common.go
Unit test coverage for code changes carried out in common_test.go
As part of testing below is the change:
Error before:
ERRO[0015] failed to get cloud console for cluster 2mbm2lqoknnr4sn73utv5ar93a61dhb3: failed to assume role with isolated backplane flow: failed to fetch arn sequence: 500 Internal Server Error
Error after code change:
ERRO[0015] failed to get cloud console for cluster 2mbm2lqoknnr4sn73utv5ar93a61dhb3: failed to assume role with isolated backplane flow: failed to fetch arn sequence: error from backplane:
Status Code: 500
Message: error occurred for type assume-role-sequence, error: failed to assume orgrole: AccessDenied: User is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::123456789012:role/TestRole
(response body: {"statusCode":500,"message":"error occurred for type assume-role-sequence, error: failed to assume orgrole: AccessDenied: User is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::123456789012:role/TestRole","reason":"InternalError","details":{"error":"AWS STS AssumeRole failed","roleArn":"arn:aws:iam::123456789012:role/TestRole"}})