MCPcopy Index your code
hub / github.com/coder/coder / makeAgentName

Method makeAgentName

agent/agentcontainers/api.go:1145–1158  ·  view source on GitHub ↗

makeAgentName attempts to create an agent name. It will first attempt to create an agent name based off of the workspace folder, and will eventually fallback to a friendly name. Like `safeAgentName`, the second returned value will be true if the agent name utilizes the workspace folder, and false if

(workspaceFolder string, friendlyName string)

Source from the content-addressed store, hash-verified

1143// agent name utilizes the workspace folder, and false if it falls back to the
1144// friendly name.
1145func (api *API) makeAgentName(workspaceFolder string, friendlyName string) (string, bool) {
1146 for attempt := 0; attempt <= maxAttemptsToNameAgent; attempt++ {
1147 agentName, usingWorkspaceFolder := expandedAgentName(workspaceFolder, friendlyName, attempt)
1148 if !usingWorkspaceFolder {
1149 return agentName, false
1150 }
1151
1152 if !api.devcontainerNames[agentName] {
1153 return agentName, true
1154 }
1155 }
1156
1157 return safeFriendlyName(friendlyName), false
1158}
1159
1160// RefreshContainers triggers an immediate update of the container list
1161// and waits for it to complete.

Callers 2

WithDevcontainersFunction · 0.80

Calls 2

expandedAgentNameFunction · 0.85
safeFriendlyNameFunction · 0.85

Tested by

no test coverage detected