mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
feat(provisioner): pass owner git ssh key (#13366)
This commit is contained in:
@ -467,6 +467,15 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo
|
||||
if err != nil {
|
||||
return nil, failJob(fmt.Sprintf("get owner: %s", err))
|
||||
}
|
||||
var ownerSSHPublicKey, ownerSSHPrivateKey string
|
||||
if ownerSSHKey, err := s.Database.GetGitSSHKey(ctx, owner.ID); err != nil {
|
||||
if !xerrors.Is(err, sql.ErrNoRows) {
|
||||
return nil, failJob(fmt.Sprintf("get owner ssh key: %s", err))
|
||||
}
|
||||
} else {
|
||||
ownerSSHPublicKey = ownerSSHKey.PublicKey
|
||||
ownerSSHPrivateKey = ownerSSHKey.PrivateKey
|
||||
}
|
||||
ownerGroups, err := s.Database.GetGroupsByOrganizationAndUserID(ctx, database.GetGroupsByOrganizationAndUserIDParams{
|
||||
UserID: owner.ID,
|
||||
OrganizationID: s.OrganizationID,
|
||||
@ -586,6 +595,8 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo
|
||||
TemplateName: template.Name,
|
||||
TemplateVersion: templateVersion.Name,
|
||||
WorkspaceOwnerSessionToken: sessionToken,
|
||||
WorkspaceOwnerSshPublicKey: ownerSSHPublicKey,
|
||||
WorkspaceOwnerSshPrivateKey: ownerSSHPrivateKey,
|
||||
},
|
||||
LogLevel: input.LogLevel,
|
||||
},
|
||||
|
@ -190,6 +190,9 @@ func TestAcquireJob(t *testing.T) {
|
||||
Name: "group1",
|
||||
OrganizationID: pd.OrganizationID,
|
||||
})
|
||||
sshKey := dbgen.GitSSHKey(t, db, database.GitSSHKey{
|
||||
UserID: user.ID,
|
||||
})
|
||||
err := db.InsertGroupMember(ctx, database.InsertGroupMemberParams{
|
||||
UserID: user.ID,
|
||||
GroupID: group1.ID,
|
||||
@ -360,6 +363,8 @@ func TestAcquireJob(t *testing.T) {
|
||||
TemplateName: template.Name,
|
||||
TemplateVersion: version.Name,
|
||||
WorkspaceOwnerSessionToken: sessionToken,
|
||||
WorkspaceOwnerSshPublicKey: sshKey.PublicKey,
|
||||
WorkspaceOwnerSshPrivateKey: sshKey.PrivateKey,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
Reference in New Issue
Block a user