driftctl/pkg/terraform/provider_config.go

36 lines
701 B
Go
Raw Normal View History

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"
}
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,
)
}
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)
}
return fmt.Sprintf("terraform-provider-%s_v%s_%s", c.Key, c.Version, c.Postfix)
}