Repository navigation
chore(provisioner/terraform): warn when agent dir breaks Desktop file sync - #24951
zenithwolf1000 wants to merge 1 commit into
Conversation
code-asher
left a comment
There was a problem hiding this comment.
Looks good to me.
If you want to add a test appending something like this to the others should work:
{
Name: "warn-agent-dir",
Files: map[string]string{
"main.tf": `terraform {
required_providers {
coder = {
source = "coder/coder"
version = ">= 2.12.0"
}
}
}
resource "coder_agent" "dev" {
os = "windows"
arch = "arm64"
dir = "~/test"
}
resource "null_resource" "dev" {
depends_on = [coder_agent.dev]
}
`,
},
Response: &proto.GraphComplete{
Resources: []*proto.Resource{
{
Name: "dev",
Type: "null_resource",
Agents: []*proto.Agent{{
Name: "dev",
OperatingSystem: "windows",
Architecture: "arm64",
Directory: "~/test",
Auth: &proto.Agent_Token{},
ConnectionTimeoutSeconds: 120,
DisplayApps: &proto.DisplayApps{
Vscode: true,
SshHelper: true,
PortForwardingHelper: true,
WebTerminal: true,
},
ResourcesMonitoring: &proto.ResourcesMonitoring{},
ApiKeyScope: "all",
}},
},
},
},
PlanExpectLogContains: "will break Coder Desktop file sync",
SkipCacheProviders: true,
},| "agent %q has 'dir' set to %q, which will break Coder Desktop file sync. "+ | ||
| "Set 'dir' to a value that expands to the user's home directory or leave it unset.", |
There was a problem hiding this comment.
I could see someone setting /home/coder for example and tripping this warning saying it will break, but then the next sentence says it will be fine (since it is the home dir).
idk if it is worth picking over the wording for the edge cases though lol
But we could say something like "may break file sync if it expands to a directory other than the user's home directory" or something.
|
Closing in favor of the
|
Emits a WARN-level build log when a
coder_agentresource hasdirset to a value other than$HOMEor~, because this breaks Coder Desktop file sync.Refs DEVEX-227
A companion change to the
coder_agentTerraform provider docs is at coder/terraform-provider-coder (to be submitted separately).Implementation notes
The warning is emitted in
server.Graph()afterConvertState()returns, which is the earliest point where agent attributes (includingDirectory) are available alongside the session'sProvisionLogsink. The check skips agents with an emptydir(the default) or values that expand to$HOME.