2020-12-09 15:31:34 +00:00
|
|
|
package resource
|
|
|
|
|
2021-03-25 11:13:52 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/zclconf/go-cty/cty"
|
|
|
|
)
|
2020-12-09 15:31:34 +00:00
|
|
|
|
|
|
|
type FakeResource struct {
|
2021-03-25 11:13:52 +00:00
|
|
|
Id string `cty:"id"`
|
|
|
|
FooBar string `cty:"foo_bar"`
|
|
|
|
BarFoo string `cty:"bar_foo" computed:"true"`
|
|
|
|
Json string `cty:"json" jsonstring:"true"`
|
2020-12-09 15:31:34 +00:00
|
|
|
Type string
|
2021-03-25 11:13:52 +00:00
|
|
|
Tags map[string]string `cty:"tags"`
|
2020-12-09 15:31:34 +00:00
|
|
|
CustomMap map[string]struct {
|
2021-03-25 11:13:52 +00:00
|
|
|
Tag string `cty:"tag"`
|
|
|
|
} `cty:"custom_map"`
|
|
|
|
Slice []string `cty:"slice"`
|
2020-12-18 14:28:46 +00:00
|
|
|
Struct struct {
|
2021-03-25 11:13:52 +00:00
|
|
|
Baz string `cty:"baz" computed:"true"`
|
|
|
|
Bar string `cty:"bar"`
|
|
|
|
} `cty:"struct"`
|
2020-12-16 12:02:02 +00:00
|
|
|
StructSlice []struct {
|
2021-03-25 11:13:52 +00:00
|
|
|
String string `cty:"string" computed:"true"`
|
|
|
|
Array []string `cty:"array" computed:"true"`
|
|
|
|
} `cty:"struct_slice"`
|
|
|
|
CtyVal *cty.Value `diff:"-"`
|
2020-12-09 15:31:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d FakeResource) TerraformId() string {
|
|
|
|
return d.Id
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d FakeResource) TerraformType() string {
|
|
|
|
if d.Type != "" {
|
|
|
|
return d.Type
|
|
|
|
}
|
|
|
|
return "FakeResource"
|
|
|
|
}
|
|
|
|
|
2021-03-25 11:13:52 +00:00
|
|
|
func (r FakeResource) CtyValue() *cty.Value {
|
|
|
|
return r.CtyVal
|
|
|
|
}
|
|
|
|
|
2020-12-09 15:31:34 +00:00
|
|
|
type FakeResourceStringer struct {
|
2021-03-25 11:13:52 +00:00
|
|
|
Id string
|
|
|
|
Name string
|
|
|
|
CtyVal *cty.Value `diff:"-"`
|
2020-12-09 15:31:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *FakeResourceStringer) TerraformId() string {
|
|
|
|
return d.Id
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *FakeResourceStringer) TerraformType() string {
|
|
|
|
return "FakeResourceStringer"
|
|
|
|
}
|
|
|
|
|
2021-03-25 11:13:52 +00:00
|
|
|
func (r *FakeResourceStringer) CtyValue() *cty.Value {
|
|
|
|
return r.CtyVal
|
|
|
|
}
|
|
|
|
|
2020-12-09 15:31:34 +00:00
|
|
|
func (d *FakeResourceStringer) String() string {
|
|
|
|
return fmt.Sprintf("Name: '%s'", d.Name)
|
|
|
|
}
|