mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
fix(agent/agentcontainers): reduce need to recreate sub agents (#18402)
This commit is contained in:
committed by
GitHub
parent
7e9a9e098c
commit
7fa1ad8923
@@ -2,6 +2,7 @@ package agentcontainers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"golang.org/x/xerrors"
|
||||
@@ -23,6 +24,26 @@ type SubAgent struct {
|
||||
DisplayApps []codersdk.DisplayApp
|
||||
}
|
||||
|
||||
// CloneConfig makes a copy of SubAgent without ID and AuthToken. The
|
||||
// name is inherited from the devcontainer.
|
||||
func (s SubAgent) CloneConfig(dc codersdk.WorkspaceAgentDevcontainer) SubAgent {
|
||||
return SubAgent{
|
||||
Name: dc.Name,
|
||||
Directory: s.Directory,
|
||||
Architecture: s.Architecture,
|
||||
OperatingSystem: s.OperatingSystem,
|
||||
DisplayApps: slices.Clone(s.DisplayApps),
|
||||
}
|
||||
}
|
||||
|
||||
func (s SubAgent) EqualConfig(other SubAgent) bool {
|
||||
return s.Name == other.Name &&
|
||||
s.Directory == other.Directory &&
|
||||
s.Architecture == other.Architecture &&
|
||||
s.OperatingSystem == other.OperatingSystem &&
|
||||
slices.Equal(s.DisplayApps, other.DisplayApps)
|
||||
}
|
||||
|
||||
// SubAgentClient is an interface for managing sub agents and allows
|
||||
// changing the implementation without having to deal with the
|
||||
// agentproto package directly.
|
||||
|
||||
Reference in New Issue
Block a user