aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/terraform/registry/regsrc/terraform_provider.go
diff options
context:
space:
mode:
authorNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
committerNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
commit107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch)
treeca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/hashicorp/terraform/registry/regsrc/terraform_provider.go
parent844b5a68d8af4791755b8f0ad293cc99f5959183 (diff)
downloadterraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip
Upgrade to 0.12
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/registry/regsrc/terraform_provider.go')
-rw-r--r--vendor/github.com/hashicorp/terraform/registry/regsrc/terraform_provider.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/registry/regsrc/terraform_provider.go b/vendor/github.com/hashicorp/terraform/registry/regsrc/terraform_provider.go
new file mode 100644
index 0000000..58dedee
--- /dev/null
+++ b/vendor/github.com/hashicorp/terraform/registry/regsrc/terraform_provider.go
@@ -0,0 +1,60 @@
1package regsrc
2
3import (
4 "fmt"
5 "runtime"
6 "strings"
7
8 "github.com/hashicorp/terraform/svchost"
9)
10
11var (
12 // DefaultProviderNamespace represents the namespace for canonical
13 // HashiCorp-controlled providers.
14 DefaultProviderNamespace = "-"
15)
16
17// TerraformProvider describes a Terraform Registry Provider source.
18type TerraformProvider struct {
19 RawHost *FriendlyHost
20 RawNamespace string
21 RawName string
22 OS string
23 Arch string
24}
25
26// NewTerraformProvider constructs a new provider source.
27func NewTerraformProvider(name, os, arch string) *TerraformProvider {
28 if os == "" {
29 os = runtime.GOOS
30 }
31 if arch == "" {
32 arch = runtime.GOARCH
33 }
34
35 // separate namespace if included
36 namespace := DefaultProviderNamespace
37 if names := strings.SplitN(name, "/", 2); len(names) == 2 {
38 namespace, name = names[0], names[1]
39 }
40 p := &TerraformProvider{
41 RawHost: PublicRegistryHost,
42 RawNamespace: namespace,
43 RawName: name,
44 OS: os,
45 Arch: arch,
46 }
47
48 return p
49}
50
51// Provider returns just the registry ID of the provider
52func (p *TerraformProvider) TerraformProvider() string {
53 return fmt.Sprintf("%s/%s", p.RawNamespace, p.RawName)
54}
55
56// SvcHost returns the svchost.Hostname for this provider. The
57// default PublicRegistryHost is returned.
58func (p *TerraformProvider) SvcHost() (svchost.Hostname, error) {
59 return svchost.ForComparison(PublicRegistryHost.Raw)
60}