Add data source attribute for owner email address#31
Conversation
internal/provider/provider_test.go
Outdated
| func TestWorkspace(t *testing.T) { | ||
| t.Parallel() | ||
| t.Setenv("CODER_WORKSPACE_OWNER", "owner123") | ||
| t.Setenv("CODER_WORKSPACE_OWNER_NAME", "Workspace Owner Jr.") |
There was a problem hiding this comment.
I kinda messed this up in the other issue, and I think it could be better to remove this for now. Since we don't have a display name, it could be easy to confuse _name with username.
There was a problem hiding this comment.
Sure. I was thinking it would be convenient to have a separate variable, because in the future we'll probably be able to get a display name from e.g. an OIDC provider. But you're right that for now, it's potentially confusing.
There was a problem hiding this comment.
That's a good idea to expose the attributes. Interesting
| ownerEmail := os.Getenv("CODER_WORKSPACE_OWNER_EMAIL") | ||
| _ = rd.Set("owner_email", ownerEmail) |
There was a problem hiding this comment.
The other attributes handled by this function all have a non-empty default value in case the expected environment var is missing. But I can't think of a good default for the email address, and in my testing, there didn't seem to be any problem with leaving it empty.
kylecarbs
left a comment
There was a problem hiding this comment.
Pending owner_name is removed in favor of owner, this is good to merge! We should cut a new release too so it can be consumed by your other PR in coder/coder.
* Add data source attributes for owner name and email address * Fix incorrectly commented-out block * Remove "owner_name" field
This PR adds a new attribute to the
coder_workspacedata source:owner_email, which is populated from theCODER_WORKSPACE_OWNER_EMAILenvironment variable.