mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(provisioner): add support for workspace_owner_login_type (#15499)
- Adds support for the `coder_workspace_owner.login_type` attribute. - Adds a currently disabled test for `coder_workspace_owner.login_type`
This commit is contained in:
@@ -246,6 +246,7 @@ func provisionEnv(
|
||||
"CODER_WORKSPACE_OWNER_GROUPS="+string(ownerGroups),
|
||||
"CODER_WORKSPACE_OWNER_SSH_PUBLIC_KEY="+metadata.GetWorkspaceOwnerSshPublicKey(),
|
||||
"CODER_WORKSPACE_OWNER_SSH_PRIVATE_KEY="+metadata.GetWorkspaceOwnerSshPrivateKey(),
|
||||
"CODER_WORKSPACE_OWNER_LOGIN_TYPE="+metadata.GetWorkspaceOwnerLoginType(),
|
||||
"CODER_WORKSPACE_ID="+metadata.GetWorkspaceId(),
|
||||
"CODER_WORKSPACE_OWNER_ID="+metadata.GetWorkspaceOwnerId(),
|
||||
"CODER_WORKSPACE_OWNER_SESSION_TOKEN="+metadata.GetWorkspaceOwnerSessionToken(),
|
||||
|
||||
@@ -383,6 +383,8 @@ func TestProvision(t *testing.T) {
|
||||
ExpectLogContains string
|
||||
// If Apply is true, then send an Apply request and check we get the same Resources as in Response.
|
||||
Apply bool
|
||||
// Some tests may need to be skipped until the relevant provider version is released.
|
||||
SkipReason string
|
||||
}{
|
||||
{
|
||||
Name: "missing-variable",
|
||||
@@ -703,6 +705,46 @@ func TestProvision(t *testing.T) {
|
||||
}},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "workspace-owner-login-type",
|
||||
SkipReason: "field will be added in provider version 1.1.0",
|
||||
Files: map[string]string{
|
||||
"main.tf": `terraform {
|
||||
required_providers {
|
||||
coder = {
|
||||
source = "coder/coder"
|
||||
version = "1.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "null_resource" "example" {}
|
||||
data "coder_workspace_owner" "me" {}
|
||||
resource "coder_metadata" "example" {
|
||||
resource_id = null_resource.example.id
|
||||
item {
|
||||
key = "login_type"
|
||||
value = data.coder_workspace_owner.me.login_type
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
Request: &proto.PlanRequest{
|
||||
Metadata: &proto.Metadata{
|
||||
WorkspaceOwnerLoginType: "github",
|
||||
},
|
||||
},
|
||||
Response: &proto.PlanComplete{
|
||||
Resources: []*proto.Resource{{
|
||||
Name: "example",
|
||||
Type: "null_resource",
|
||||
Metadata: []*proto.Resource_Metadata{{
|
||||
Key: "login_type",
|
||||
Value: "github",
|
||||
}},
|
||||
}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
@@ -710,6 +752,10 @@ func TestProvision(t *testing.T) {
|
||||
t.Run(testCase.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if testCase.SkipReason != "" {
|
||||
t.Skip(testCase.SkipReason)
|
||||
}
|
||||
|
||||
ctx, api := setupProvisioner(t, nil)
|
||||
sess := configure(ctx, t, api, &proto.Config{
|
||||
TemplateSourceArchive: makeTar(t, testCase.Files),
|
||||
|
||||
Reference in New Issue
Block a user