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

Add -json and -t flag for nomad acl token create command #16055

Merged
merged 6 commits into from
Feb 7, 2023

Conversation

dttung2905
Copy link
Contributor

Hi team,

This PR aims to add -json and -t flag for nomad acl token create command. This is related to issue #15894

Example output:

  • With -json flag
❯ nomad acl token create -type="management" -global=true \
  -name="Cluster A Replication Token" \
  -token="abcxyz" -ttl=10m -json
{
    "AccessorID": "83a61305-15c2-c78a-1c59-75c44afa7a13",
    "CreateIndex": 927,
    "CreateTime": "2023-02-04T09:39:33.710007669Z",
    "ExpirationTTL": 600000000000,
    "ExpirationTime": "2023-02-04T09:49:33.710007669Z",
    "Global": true,
    "ModifyIndex": 927,
    "Name": "Cluster A Replication Token",
    "Policies": null,
    "Roles": null,
    "SecretID": "6d23da6a-677d-c7b9-02ac-f1c41ad5f5d0",
    "Type": "management"
}

  • With -t flag
❯ nomad acl token create -type="management" -global=true \
  -name="Cluster A Replication Token" \
  -token="abcxyz" -ttl=10m -t='{{ .ExpirationTTL }}'

10m0s

Signed-off-by: dttung2905 <[email protected]>
Signed-off-by: dttung2905 <[email protected]>
Copy link
Member

@jrasell jrasell left a comment

Choose a reason for hiding this comment

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

Hi @dttung2905 and thanks for raising this; it's looking great. I've made a couple of very minor suggestions inline. I also wonder if it would be possible to update the tests added slightly, in particular when testing the JSON flag to check we have valid JSON returned in the output writer. Thanks again!

.changelog/16055.txt Outdated Show resolved Hide resolved
command/acl_token_create.go Outdated Show resolved Hide resolved
website/content/docs/commands/acl/token/create.mdx Outdated Show resolved Hide resolved
@jrasell jrasell self-assigned this Feb 6, 2023
@dttung2905
Copy link
Contributor Author

Hi @jrasell. Thanks for the super quick review. I didn't check the semantic of JSON output i.e. all KV pairs because I think its abit uncessary. Hence, I have only added a check for a proper JSON formatted output. Please let me know what you think on this 🙏

Copy link
Member

@jrasell jrasell left a comment

Choose a reason for hiding this comment

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

Thanks for the updates @dttung2905 and LGTM! The unmarshal testing trick is something I have used elsewhere, so it's nice to see others see this as an approach to take. Thanks!

@jrasell jrasell merged commit b19df69 into hashicorp:main Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants