This repository has been archived by the owner on Dec 30, 2024. It is now read-only.
generated from FrangipaneTeam/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbool_type.go
67 lines (53 loc) · 1.69 KB
/
bool_type.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// -------------------------------------------------------------------- //
// ! DO NOT EDIT. This file is auto-generated from template ! //
// -------------------------------------------------------------------- //
package supertypes
import (
"context"
"fmt"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/hashicorp/terraform-plugin-go/tftypes"
)
// Ensure the implementation satisfies the expected interfaces.
var _ basetypes.BoolTypable = BoolType{}
type BoolType struct {
basetypes.BoolType
}
func (t BoolType) Equal(o attr.Type) bool {
other, ok := o.(BoolType)
if !ok {
return false
}
return t.BoolType.Equal(other.BoolType)
}
func (t BoolType) String() string {
return "supertypes.BoolType"
}
func (t BoolType) ValueFromBool(_ context.Context, in basetypes.BoolValue) (basetypes.BoolValuable, diag.Diagnostics) {
value := BoolValue{
BoolValue: in,
}
return value, nil
}
func (t BoolType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
attrValue, err := t.BoolType.ValueFromTerraform(ctx, in)
if err != nil {
return nil, err
}
BoolValue, ok := attrValue.(basetypes.BoolValue)
if !ok {
return nil, fmt.Errorf("unexpected value type of %T", attrValue)
}
BoolValuable, diags := t.ValueFromBool(ctx, BoolValue)
if diags.HasError() {
return nil, fmt.Errorf("unexpected error converting BoolValue to BoolValuable: %v", diags)
}
return BoolValuable, nil
}
func (t BoolType) ValueType(ctx context.Context) attr.Value {
return BoolValue{
BoolValue: t.BoolType.ValueType(ctx).(basetypes.BoolValue),
}
}