Closed rhughes1 closed 2 years ago
@rhughes1 Great idea and thank you for the request.
This feature seems very reasonable, let me do a bit of research and provide you with a few thoughts.
Cheers!
Quick prototype, see below for an example output.
One question, how important is the Team Name? This requires an additional API call since the TeamAccess endpoint only returns the Id of the team. Not a huge deal but increases latency of the command.
Feedback welcome!
$ tfx workspace team list -w tfx-test
Using config file: /Users/tstraub/.tfx.hcl
List Variables for Workspace: tfx-test
╭──────────────┬───────────────────────┬──────────────────────┬─────────────┬───────────┬────────────────┬──────────┬───────────┬────────────────╮
│ NAME │ TEAM ID │ TEAM ACCESS ID │ ACCESS TYPE │ RUN PERMS │ SENTINEL PERMS │ RUN TASK │ VARIABLES │ STATE VERSIONS │
├──────────────┼───────────────────────┼──────────────────────┼─────────────┼───────────┼────────────────┼──────────┼───────────┼────────────────┤
│ appteam-read │ team-phMhWZUz3Hkog8Qp │ tws-LfZNEXKvxfpS5W7a │ write │ apply │ read │ false │ write │ write │
│ ws-outputs │ team-f5hT25igBATWry5u │ tws-qApZtrp4KEjDjqBq │ custom │ read │ read │ false │ none │ none │
╰──────────────┴───────────────────────┴──────────────────────┴─────────────┴───────────┴────────────────┴──────────┴───────────┴────────────────╯
Or if JSON is your focus
$ tfx workspace team list -w tfx-test -j | jq .
[
{
"Access Type": "write",
"Name": "appteam-read",
"Run Perms": "apply",
"Run Task": false,
"Sentinel Perms": "read",
"State Versions": "write",
"Team Access Id": "tws-LfZNEXKvxfpS5W7a",
"Team Id": "team-phMhWZUz3Hkog8Qp",
"Variables": "write"
},
{
"Access Type": "custom",
"Name": "ws-outputs",
"Run Perms": "read",
"Run Task": false,
"Sentinel Perms": "read",
"State Versions": "none",
"Team Access Id": "tws-qApZtrp4KEjDjqBq",
"Team Id": "team-f5hT25igBATWry5u",
"Variables": "none"
}
]
Looks solid! From a human readability point of view I would say it makes sense to have the team name as part of this. I say this because if we were doing Terraform state imports in TFE/TFC, it's important to the user to know the name of the team to ensure the right data is being migrated to the right resource.
You could make an argument potentially have the workspace show
command to have just the list of teams? That's definitely a separate feature request.
That seems very reasonable to add to the show command. I will include that in this change as well.
Check out the PR #35 Workspace Show command is not ideal, but currently the best I can do and not break JSON output in it's current form.
Problem statement
As part of easily getting IDs for team(s) on workspaces, there should be a command which lists the team information. It would be important to show the following information:
Specifications
tfx version: 0.1.0 Terraform Cloud or Terraform Enterprise: Terraform Cloud Terraform Enterprise Version: if applicable N/A Terraform Code Version: 1.2.4