Skip to content

Commit

Permalink
fix(provider): coalesce arch to armv7 if on 32-bit arm (#210)
Browse files Browse the repository at this point in the history
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"
  ...
}
```
  • Loading branch information
johnstcn authored Apr 18, 2024
1 parent f3a205c commit b94b7ea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/resources/agent_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
page_title: "coder_agent_instance Resource - terraform-provider-coder"
subcategory: ""
description: |-
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.
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.
---

# coder_agent_instance (Resource)
Expand Down
4 changes: 4 additions & 0 deletions provider/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ func provisionerDataSource() *schema.Resource {
rd.SetId(uuid.NewString())
rd.Set("os", runtime.GOOS)
rd.Set("arch", runtime.GOARCH)
// Fix for #11782: if we're on 32-bit ARM, set arch to armv7.
if runtime.GOARCH == "arm" {
rd.Set("arch", "armv7")
}

return nil
},
Expand Down
7 changes: 6 additions & 1 deletion provider/provisioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ func TestProvisioner(t *testing.T) {

attribs := resource.Primary.Attributes
require.Equal(t, runtime.GOOS, attribs["os"])
require.Equal(t, runtime.GOARCH, attribs["arch"])
if runtime.GOARCH == "arm" {
require.Equal(t, "armv7", attribs["arch"])
} else {
require.Equal(t, runtime.GOARCH, attribs["arch"])
}
return nil
},
}},
})
}

0 comments on commit b94b7ea

Please sign in to comment.