driftctl/test/resource/resource.go

67 lines
1.3 KiB
Go
Raw Normal View History

package resource
2021-03-25 11:13:52 +00:00
import (
"fmt"
"github.com/zclconf/go-cty/cty"
)
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"`
Type string
2021-03-25 11:13:52 +00:00
Tags map[string]string `cty:"tags"`
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:"-"`
}
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
}
type FakeResourceStringer struct {
2021-03-25 11:13:52 +00:00
Id string
Name string
CtyVal *cty.Value `diff:"-"`
}
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
}
func (d *FakeResourceStringer) String() string {
return fmt.Sprintf("Name: '%s'", d.Name)
}