Skip to content

Commit b94b7ea

Browse files
authored
fix(provider): coalesce arch to armv7 if on 32-bit arm (#210)
This PR modifies the `coder_provisioner` datasource to return `arch` as `armv7` if `GOARCH=arm`. This fixes an issue where users on 32-bit arm platforms would be unable to create a template with ``` resource "coder_agent" "main" { arch = data.coder_provisioner.me.arch ... } ``` and would instead need to manually specify ``` resource "coder_agent" "main" { arch = "armv7" ... } ```
1 parent f3a205c commit b94b7ea

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

Diff for: docs/resources/agent_instance.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
page_title: "coder_agent_instance Resource - terraform-provider-coder"
44
subcategory: ""
55
description: |-
6-
Use this resource to associate an instance ID with an agent for zero-trust authentication. This association is done automatically for "googlecomputeinstance", "awsinstance", "azurermlinuxvirtualmachine", and "azurermwindowsvirtual_machine" resources.
6+
Use this resource to associate an instance ID with an agent for zero-trust authentication. This association is done automatically for "google_compute_instance", "aws_instance", "azurerm_linux_virtual_machine", and "azurerm_windows_virtual_machine" resources.
77
---
88

99
# coder_agent_instance (Resource)

Diff for: provider/provisioner.go

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ func provisionerDataSource() *schema.Resource {
1616
rd.SetId(uuid.NewString())
1717
rd.Set("os", runtime.GOOS)
1818
rd.Set("arch", runtime.GOARCH)
19+
// Fix for #11782: if we're on 32-bit ARM, set arch to armv7.
20+
if runtime.GOARCH == "arm" {
21+
rd.Set("arch", "armv7")
22+
}
1923

2024
return nil
2125
},

Diff for: provider/provisioner_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@ func TestProvisioner(t *testing.T) {
3131

3232
attribs := resource.Primary.Attributes
3333
require.Equal(t, runtime.GOOS, attribs["os"])
34-
require.Equal(t, runtime.GOARCH, attribs["arch"])
34+
if runtime.GOARCH == "arm" {
35+
require.Equal(t, "armv7", attribs["arch"])
36+
} else {
37+
require.Equal(t, runtime.GOARCH, attribs["arch"])
38+
}
3539
return nil
3640
},
3741
}},
3842
})
3943
}
44+

0 commit comments

Comments
 (0)