Skip to content

Commit 9bbc8d2

Browse files
committed
feat(provisioner): add support for workspace_owner_login_type
1 parent 1c938cd commit 9bbc8d2

File tree

5 files changed

+214
-160
lines changed

5 files changed

+214
-160
lines changed

coderd/provisionerdserver/provisionerdserver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo
614614
WorkspaceOwnerSshPublicKey: ownerSSHPublicKey,
615615
WorkspaceOwnerSshPrivateKey: ownerSSHPrivateKey,
616616
WorkspaceBuildId: workspaceBuild.ID.String(),
617+
WorkspaceOwnerLoginType: string(owner.LoginType),
617618
},
618619
LogLevel: input.LogLevel,
619620
},

provisioner/terraform/provision.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ func provisionEnv(
246246
"CODER_WORKSPACE_OWNER_GROUPS="+string(ownerGroups),
247247
"CODER_WORKSPACE_OWNER_SSH_PUBLIC_KEY="+metadata.GetWorkspaceOwnerSshPublicKey(),
248248
"CODER_WORKSPACE_OWNER_SSH_PRIVATE_KEY="+metadata.GetWorkspaceOwnerSshPrivateKey(),
249+
"CODER_WORKSPACE_OWNER_LOGIN_TYPE="+metadata.GetWorkspaceOwnerLoginType(),
249250
"CODER_WORKSPACE_ID="+metadata.GetWorkspaceId(),
250251
"CODER_WORKSPACE_OWNER_ID="+metadata.GetWorkspaceOwnerId(),
251252
"CODER_WORKSPACE_OWNER_SESSION_TOKEN="+metadata.GetWorkspaceOwnerSessionToken(),

provisioner/terraform/provision_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,45 @@ func TestProvision(t *testing.T) {
703703
}},
704704
},
705705
},
706+
{
707+
Name: "workspace-owner-login-type",
708+
Files: map[string]string{
709+
"main.tf": `terraform {
710+
required_providers {
711+
coder = {
712+
source = "coder/coder"
713+
version = "1.0.5"
714+
}
715+
}
716+
}
717+
718+
resource "null_resource" "example" {}
719+
data "coder_workspace_owner" "me" {}
720+
resource "coder_metadata" "example" {
721+
resource_id = null_resource.example.id
722+
item {
723+
key = "login_type"
724+
value = data.coder_workspace_owner.me.login_type
725+
}
726+
}
727+
`,
728+
},
729+
Request: &proto.PlanRequest{
730+
Metadata: &proto.Metadata{
731+
WorkspaceOwnerLoginType: "github",
732+
},
733+
},
734+
Response: &proto.PlanComplete{
735+
Resources: []*proto.Resource{{
736+
Name: "example",
737+
Type: "null_resource",
738+
Metadata: []*proto.Resource_Metadata{{
739+
Key: "login_type",
740+
Value: "github",
741+
}},
742+
}},
743+
},
744+
},
706745
}
707746

708747
for _, testCase := range testCases {

0 commit comments

Comments
 (0)