Skip to content

Add login_type to coder_workspace_owner data source #235 #287

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 11 commits into from
Sep 11, 2024

Conversation

pmareke
Copy link
Contributor

@pmareke pmareke commented Sep 10, 2024

This PR add the login type the the coder_workspace_owner data source (Issue #235).

I took some decisions (like the default value to none), but if you think this should be different please let me know.

Thanks!

Copy link

github-actions bot commented Sep 10, 2024

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@pmareke
Copy link
Contributor Author

pmareke commented Sep 10, 2024

I have read the CLA Document and I hereby sign the CLA

cdrcommunity added a commit to coder/cla that referenced this pull request Sep 10, 2024
@pmareke pmareke changed the title Add login_type to coder_workspace_owner data source Add login_type to coder_workspace_owner data source (solves #235) Sep 10, 2024
@pmareke pmareke changed the title Add login_type to coder_workspace_owner data source (solves #235) Add login_type to coder_workspace_owner data source #235 Sep 10, 2024
@johnstcn johnstcn requested review from johnstcn and mtojek September 10, 2024 15:44
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

That was quick! You'll also need to update the integration tests to expect the new field.

@pmareke
Copy link
Contributor Author

pmareke commented Sep 10, 2024

Done!

@matifali matifali requested a review from johnstcn September 11, 2024 11:43
if login_type := os.Getenv("CODER_WORKSPACE_OWNER_LOGIN_TYPE"); login_type != "" {
_ = rd.Set("login_type", login_type)
} else {
_ = rd.Set("login_type", "none")
Copy link
Member

Choose a reason for hiding this comment

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

@mtojek should we instead set login_type to an empty string if Coder does not set the required env?

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps at the very least, drop a diag.Warn?

Copy link
Member

Choose a reason for hiding this comment

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

should we instead set login_type to an empty string

This seems reasonable and consistent with other ENV vars. I would start with empty string, we can always revisit it in the future and replace it with none.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems reasonable and consistent with other ENV vars. I would start with empty string, we can always revisit it in the future and replace it with none.

Great, what about the warn?

Copy link
Member

Choose a reason for hiding this comment

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

Adding a diag.Warn if the CODER_WORKSPACE_OWNER_LOGIN_TYPE environment variable is not present or empty would be a good indication to the user that they have a potential mismatch of the Coder version and provider version.

Copy link
Contributor Author

@pmareke pmareke Sep 11, 2024

Choose a reason for hiding this comment

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

Sorry, but taking a look to the diag package there is not Warn method.

https://pkg.go.dev/github.com/hashicorp/terraform-plugin-sdk/v2/diag

Copy link
Member

Choose a reason for hiding this comment

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

Sorry! I should have been more specific -- you can append a diag.Diagnostic with severity diag.Warning to the second return argument of type diag.Diagnostics.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, this is the first time I have to deal with the diags, so please let me know if this solution is correct 🙏🏼 .

Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

if login_type := os.Getenv("CODER_WORKSPACE_OWNER_LOGIN_TYPE"); login_type != "" {
_ = rd.Set("login_type", login_type)
} else {
_ = rd.Set("login_type", "none")
Copy link
Member

Choose a reason for hiding this comment

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

should we instead set login_type to an empty string

This seems reasonable and consistent with other ENV vars. I would start with empty string, we can always revisit it in the future and replace it with none.

@pmareke
Copy link
Contributor Author

pmareke commented Sep 11, 2024

All fixed @johnstcn thanks for your time!

@pmareke pmareke requested review from johnstcn and mtojek September 11, 2024 12:58
Copy link
Member

@johnstcn johnstcn 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 your contribution!

Note that this won't be useful until coder/coder is updated to set CODER_WORKSPACE_OWNER_LOGIN_TYPE. This will require a separate PR.

@johnstcn johnstcn merged commit 2598aa7 into coder:main Sep 11, 2024
8 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants