Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit99ba884

Browse files
authored
feat: addoptional property tocoder_external_auth (#185)
1 parent1797a03 commit99ba884

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

‎docs/data-sources/external_auth.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ Use this data source to require users to authenticate with an external service p
1919

2020
-`id` (String) The ID of a configured external auth provider set up in your Coder deployment.
2121

22+
###Optional
23+
24+
-`optional` (Boolean) Authenticating with the external auth provider is not required, and can be skipped by users when creating or updating workspaces
25+
2226
###Read-Only
2327

2428
-`access_token` (String) The access token returned by the external auth provider. This can be used to pre-authenticate command-line tools.

‎provider/externalauth.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,13 @@ func externalAuthDataSource() *schema.Resource {
3232
},
3333
"access_token": {
3434
Type:schema.TypeString,
35-
Computed:true,
3635
Description:"The access token returned by the external auth provider. This can be used to pre-authenticate command-line tools.",
36+
Computed:true,
37+
},
38+
"optional": {
39+
Type:schema.TypeBool,
40+
Description:"Authenticating with the external auth provider is not required, and can be skipped by users when creating or updating workspaces",
41+
Optional:true,
3742
},
3843
},
3944
}

‎provider/externalauth_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,40 @@ func TestExternalAuth(t *testing.T) {
3636

3737
attribs:=resource.Primary.Attributes
3838
require.Equal(t,"github",attribs["id"])
39+
require.Equal(t,"",attribs["optional"])
40+
41+
returnnil
42+
},
43+
}},
44+
})
45+
}
46+
47+
funcTestOptionalExternalAuth(t*testing.T) {
48+
t.Parallel()
49+
50+
resource.Test(t, resource.TestCase{
51+
Providers:map[string]*schema.Provider{
52+
"coder":provider.New(),
53+
},
54+
IsUnitTest:true,
55+
Steps: []resource.TestStep{{
56+
Config:`
57+
provider "coder" {
58+
}
59+
data "coder_external_auth" "github" {
60+
id = "github"
61+
optional = true
62+
}
63+
`,
64+
Check:func(state*terraform.State)error {
65+
require.Len(t,state.Modules,1)
66+
require.Len(t,state.Modules[0].Resources,1)
67+
resource:=state.Modules[0].Resources["data.coder_external_auth.github"]
68+
require.NotNil(t,resource)
69+
70+
attribs:=resource.Primary.Attributes
71+
require.Equal(t,"github",attribs["id"])
72+
require.Equal(t,"true",attribs["optional"])
3973

4074
returnnil
4175
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp