-
Notifications
You must be signed in to change notification settings - Fork 22
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
Changes from 1 commit
ab53274
bf8e5d0
a32460b
6f96982
fb69196
1e4b8fb
210847d
2f3f734
63607a3
3eb23d2
241f90a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,9 @@ package provider | |
import ( | ||
"context" | ||
"encoding/json" | ||
"errors" | ||
"os" | ||
"slices" | ||
"strings" | ||
|
||
"github.com/google/uuid" | ||
|
@@ -53,6 +55,17 @@ 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")) | ||
|
||
types := []string{"password", "github", "oidc", "none"} | ||
if login_type := os.Getenv("CODER_WORKSPACE_OWNER_LOGIN_TYPE"); login_type != "" { | ||
if !slices.Contains(types, login_type) { | ||
errorMessage := "invalid login type: %s, the valid types are: 'password, github, oidc, or none'" | ||
return diag.Errorf(errorMessage, errors.New(errorMessage)) | ||
} | ||
_ = rd.Set("login_type", login_type) | ||
} else { | ||
_ = rd.Set("login_type", "none") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mtojek should we instead set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps at the very least, drop a There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Great, what about the warn? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, but taking a look to the https://pkg.go.dev/github.com/hashicorp/terraform-plugin-sdk/v2/diag There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry! I should have been more specific -- you can append a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, this is the first time I have to deal with the |
||
} | ||
|
||
return nil | ||
}, | ||
Schema: map[string]*schema.Schema{ | ||
|
@@ -107,6 +120,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.", | ||
}, | ||
}, | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.