Skip to content

Add data source attribute for owner email address #31

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 3 commits into from
Jul 18, 2022

Conversation

dwahler
Copy link
Contributor

@dwahler dwahler commented Jul 18, 2022

This PR adds a new attribute to the coder_workspace data source: owner_email, which is populated from the CODER_WORKSPACE_OWNER_EMAIL environment variable.

@@ -19,7 +19,10 @@ func TestProvider(t *testing.T) {
}

func TestWorkspace(t *testing.T) {
t.Parallel()
t.Setenv("CODER_WORKSPACE_OWNER", "owner123")
t.Setenv("CODER_WORKSPACE_OWNER_NAME", "Workspace Owner Jr.")
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

That's a good idea to expose the attributes. Interesting

Comment on lines +85 to +86
ownerEmail := os.Getenv("CODER_WORKSPACE_OWNER_EMAIL")
_ = rd.Set("owner_email", ownerEmail)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

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.

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.

@dwahler dwahler changed the title Add data source attributes for owner name and email address Add data source attribute for owner email address Jul 18, 2022
@kylecarbs kylecarbs merged commit b6aa7b5 into main Jul 18, 2022
@kylecarbs kylecarbs deleted the dwahler/owner-name-and-email branch July 18, 2022 21:54
DanielleMaywood pushed a commit that referenced this pull request Sep 5, 2024
* Add data source attributes for owner name and email address

* Fix incorrectly commented-out block

* Remove "owner_name" field
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