2021-02-08 15:42:35 +00:00
|
|
|
package terraform
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"runtime"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ProviderConfig struct {
|
|
|
|
Key string
|
|
|
|
Version string
|
|
|
|
Postfix string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ProviderConfig) GetDownloadUrl() string {
|
2021-02-18 14:59:45 +00:00
|
|
|
arch := runtime.GOARCH
|
2021-02-17 08:59:51 +00:00
|
|
|
if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" {
|
|
|
|
arch = "amd64"
|
|
|
|
}
|
2021-02-08 15:42:35 +00:00
|
|
|
return fmt.Sprintf(
|
|
|
|
"https://releases.hashicorp.com/terraform-provider-%s/%s/terraform-provider-%s_%s_%s_%s.zip",
|
|
|
|
c.Key,
|
|
|
|
c.Version,
|
|
|
|
c.Key,
|
|
|
|
c.Version,
|
|
|
|
runtime.GOOS,
|
2021-02-17 08:59:51 +00:00
|
|
|
arch,
|
2021-02-08 15:42:35 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ProviderConfig) GetBinaryName() string {
|
2021-02-15 13:24:20 +00:00
|
|
|
if c.Postfix == "" {
|
|
|
|
return fmt.Sprintf("terraform-provider-%s_v%s", c.Key, c.Version)
|
|
|
|
}
|
2021-02-08 15:42:35 +00:00
|
|
|
return fmt.Sprintf("terraform-provider-%s_v%s_%s", c.Key, c.Version, c.Postfix)
|
|
|
|
}
|