-
Notifications
You must be signed in to change notification settings - Fork 38
/
terraform_resource.go
51 lines (41 loc) · 1.46 KB
/
terraform_resource.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package manifest
import (
"strings"
)
type TerraformResource struct {
// Name holds the name of this resource. e.g. terraform-provider-google-beta
Name string `yaml:"name"`
// Version holds the version of the resource e.g. 1.19.0
Version string `yaml:"version"`
// Source holds the URI of an archive that contains the source code for this release.
Source string `yaml:"source"`
// Provider holds path to extract the provider path.
Provider string `yaml:"provider,omitempty"`
// URLTemplate holds a custom URL template to get the release of the given tool.
// Parameters available are ${name}, ${version}, ${os}, and ${arch}.
// If non is specified for providers, HashicorpUrlTemplate is used
// If non is specified for tofu, TofuURLTemplate is used
// https://github.com/cloudfoundry/cloud-service-broker/pull/975/commits/d1bf775bebf46a5685a3f05524e0977f4ac0cd99
URLTemplate string `yaml:"url_template,omitempty"`
// Default is used to mark the default Terraform version when there is more than one
Default bool `yaml:"default,omitempty"`
}
type terraformResourceType int
const (
invalidType terraformResourceType = iota
terraformVersion
terraformProvider
otherBinary
)
func (tr *TerraformResource) resourceType() terraformResourceType {
switch {
case tr.Name == "":
return invalidType
case tr.Name == binaryName:
return terraformVersion
case strings.HasPrefix(tr.Name, "terraform-provider-"):
return terraformProvider
default:
return otherBinary
}
}