-
Notifications
You must be signed in to change notification settings - Fork 102
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 nomad_acl_tokens data source #128
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some minor changes; QueryOptions
will make for a more efficient call to the server and less work to do in the provider
} | ||
} | ||
|
||
d.SetId("nomad-tokens") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apologies for not noticing this before... does this ID need to include the prefix? different data "nomad_acl_tokens"
with different prefix options should (probably?) have different IDs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i manually tested this as-written and terraform didn't complain... i will ask someone from the provider team on Monday.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the ID does not matters as long as it is not ""
as this is used to indicate, it's usually set to the external ID for resources that have one but when a Terraform resource is a virtual resource (like https://github.com/hashicorp/terraform-provider-null/blob/master/null/data_source.go#L51) or is actually multiple resource it can be set to something else.
I can push a commit to change it to d.SetId(client.Address() + "/tokens/" + prefix)
which would make it more like the pattern used by the other datasources if you want.
yeah, I talked to some folks on the plugins team and they confirmed the
value doesn't matter. you can merge it as is.
…On Sun, Jul 12, 2020, 11:31 Rémi Lapeyre ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In nomad/data_source_acl_tokens.go
<#128 (comment)>
:
> + return fmt.Errorf("error while getting the list of tokens: %v", err)
+ }
+
+ result := make([]map[string]interface{}, len(tokens))
+ for i, t := range tokens {
+ result[i] = map[string]interface{}{
+ "accessor_id": t.AccessorID,
+ "name": t.Name,
+ "type": t.Type,
+ "policies": t.Policies,
+ "global": t.Global,
+ "create_time": t.CreateTime.String(),
+ }
+ }
+
+ d.SetId("nomad-tokens")
I think the ID does not matters as long as it is not "" as this is used
to indicate, it's usually set to the external ID for resources that have
one but when a Terraform resource is a virtual resource (like
https://github.com/hashicorp/terraform-provider-null/blob/master/null/data_source.go#L51)
or is actually multiple resource it can be set to something else.
I can push a commit to change it to d.SetId(client.Address() + "/tokens/"
+ prefix) which would make it more like the pattern used by the other
datasources if you want.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#128 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMY6T5VGM5GKXF4YKBHOZLR3HQM5ANCNFSM4OXK4E3A>
.
|
thanks, @remilapeyre! |
Closes #86