- Notifications
You must be signed in to change notification settings - Fork22
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
11 commits Select commitHold shift + click to select a range
ab53274
feat: add login_type to coder_workspace_owner data source
pmarekebf8e5d0
feat: remove types check
pmarekea32460b
feat: update integration test
pmareke6f96982
feat: run linter
pmarekefb69196
feat: set empty string as the default value for the login type
pmareke1e4b8fb
feat: update integration test
pmareke210847d
feat: add a warning when the CODER_WORKSPACE_OWNER_LOGIN_TYPE is not set
pmareke2f3f734
feat: create a new diags variable
pmareke63607a3
feat: add missing comma
pmareke3eb23d2
feat: add missing parenthesis
pmareke241f90a
feat: fix typo in summary field
pmarekeFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletionsdocs/data-sources/workspace_owner.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsintegration/integration_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsintegration/workspace-owner/main.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
17 changes: 16 additions & 1 deletionprovider/workspace_owner.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -15,6 +15,8 @@ func workspaceOwnerDataSource() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Use this data source to fetch information about the workspace owner.", | ||
ReadContext: func(ctx context.Context, rd *schema.ResourceData, i interface{}) diag.Diagnostics { | ||
diags := diag.Diagnostics{} | ||
if idStr := os.Getenv("CODER_WORKSPACE_OWNER_ID"); idStr != "" { | ||
rd.SetId(idStr) | ||
} else { | ||
@@ -53,7 +55,15 @@ func workspaceOwnerDataSource() *schema.Resource { | ||
_ = rd.Set("session_token", os.Getenv("CODER_WORKSPACE_OWNER_SESSION_TOKEN")) | ||
_ = rd.Set("oidc_access_token", os.Getenv("CODER_WORKSPACE_OWNER_OIDC_ACCESS_TOKEN")) | ||
if os.Getenv("CODER_WORKSPACE_OWNER_LOGIN_TYPE") == "" { | ||
diags = append(diags, diag.Diagnostic{ | ||
pmareke marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
Severity: diag.Warning, | ||
Summary: "WARNING: The CODER_WORKSPACE_OWNER_LOGIN_TYPE env variable is not set", | ||
}) | ||
} | ||
_ = rd.Set("login_type", os.Getenv("CODER_WORKSPACE_OWNER_LOGIN_TYPE")) | ||
return diags | ||
}, | ||
Schema: map[string]*schema.Schema{ | ||
"id": { | ||
@@ -107,6 +117,11 @@ func workspaceOwnerDataSource() *schema.Resource { | ||
"This is only available if the workspace owner authenticated with OpenID Connect. " + | ||
"If a valid token cannot be obtained, this value will be an empty string.", | ||
}, | ||
"login_type": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The type of login the user has.", | ||
}, | ||
}, | ||
} | ||
} |
5 changes: 5 additions & 0 deletionsprovider/workspace_owner_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.