| 30 | } |
| 31 | |
| 32 | func WithGoogleInstanceIdentity(serviceAccount string, gcpClient *metadata.Client, opts ...InstanceIdentityOption) SessionTokenSetup { |
| 33 | cfg := applyInstanceIdentityOptions(opts) |
| 34 | return func(client *codersdk.Client) RefreshableSessionTokenProvider { |
| 35 | return &InstanceIdentitySessionTokenProvider{ |
| 36 | TokenExchanger: &GoogleSessionTokenExchanger{ |
| 37 | client: client, |
| 38 | gcpClient: gcpClient, |
| 39 | serviceAccount: serviceAccount, |
| 40 | agentName: cfg.AgentName, |
| 41 | }, |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | // exchange uses the Google Compute Engine Metadata API to fetch a signed JWT, and exchange it for a session token for a |
| 47 | // workspace agent. |