Skip to content

feat: Add "coder_metadata" resource #34

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

Merged
merged 8 commits into from
Aug 1, 2022
Merged

Conversation

dwahler
Copy link
Contributor

@dwahler dwahler commented Jul 27, 2022

This PR adds support for the coder_metadata resource, which allows attaching arbitrary key/value metadata to other resources in a template, as described in coder/coder#2989.

Optional: true,
Default: false,
},
"is_null": {
Copy link
Member

Choose a reason for hiding this comment

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

Would we just assume an empty string is null? Maybe that's too lossy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly! I implemented it this way because the original ticket asked for null support, and I figured somebody who's used to Terraform's semantics wouldn't necessarily be expecting us to conflate null and "" the way Go does. But if we're OK with that behavior, I definitely wouldn't mind getting rid of this hack.

Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

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

  • make gen should be used to generate docs
  • I'm looking for alternatives to names to pair, but I have no ideas! Maybe @mafredri has some thoughts 👀

@dwahler
Copy link
Contributor Author

dwahler commented Jul 29, 2022

make gen should be used to generate docs

Done! I added an example as well.

I'm looking for alternatives to names to pair, but I have no ideas! Maybe @mafredri has some thoughts 👀

Hmm, a few other possibilities that come to mind:

  • item
  • entry
  • field
  • element
  • member
  • datum

pair {
key = "pod_uid"
value = kubernetes_pod.dev[0].uid
}
Copy link
Member

Choose a reason for hiding this comment

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

I was confused about why key and value were nested until @kylecarbs explained to me that HCL allows multiple pair blocks. We should demonstrate that here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! I updated the example to use multiple blocks, and also to demonstrate the sensitive attribute.

@dwahler dwahler requested a review from ammario July 29, 2022 20:10
@mafredri
Copy link
Member

mafredri commented Jul 30, 2022

I'm looking for alternatives to names to pair, but I have no ideas! Maybe @mafredri has some thoughts 👀

I do like entry (and item as a close second) proposed by @dwahler.

Some other options:

  • kv
  • keyvalue
  • group (kind of like pair, though, but perhaps easier to use/more common)

And some more "out there" options:

  • attach
  • add

I'd read these as "attach/add key value to coder metadata".

@ammario
Copy link
Member

ammario commented Jul 31, 2022

item makes most sense to me, but I also find pair fine.

Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

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

Let's rename pair to item and it LGTM! We'll do a release immediately after too :)

@dwahler dwahler dismissed ammario’s stale review August 1, 2022 19:54

Changes made as requested

@dwahler dwahler merged commit 301c3fa into main Aug 1, 2022
@dwahler dwahler deleted the dwahler/metadata-schema branch August 1, 2022 19:56
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.

4 participants