mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: refactor instance identity to be a SessionTokenProvider (#19566)
Refactors Agent instance identity to be a SessionTokenProvider. Refactors the CLI to create Agent clients via a centralized function, rather than add-hoc via individual command handlers and their flags. This allows commands besides `coder agent`, but which still use the agent identity, to support instance identity authentication. Fixes #19111 by unifying all API requests to go thru the SessionTokenProvider for auth credentials.
This commit is contained in:
+4
-3
@@ -18,7 +18,8 @@ import (
|
||||
"github.com/coder/serpent"
|
||||
)
|
||||
|
||||
func (r *RootCmd) gitssh() *serpent.Command {
|
||||
func gitssh() *serpent.Command {
|
||||
agentAuth := &AgentAuth{}
|
||||
cmd := &serpent.Command{
|
||||
Use: "gitssh",
|
||||
Hidden: true,
|
||||
@@ -38,7 +39,7 @@ func (r *RootCmd) gitssh() *serpent.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
client, err := r.tryCreateAgentClient()
|
||||
client, err := agentAuth.CreateClient(ctx)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("create agent client: %w", err)
|
||||
}
|
||||
@@ -108,7 +109,7 @@ func (r *RootCmd) gitssh() *serpent.Command {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
agentAuth.AttachOptions(cmd, false)
|
||||
return cmd
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user