-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathfloat64.go
More file actions
91 lines (70 loc) · 2.35 KB
/
float64.go
File metadata and controls
91 lines (70 loc) · 2.35 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package attrmapper
import (
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/config"
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/util"
"github.com/hashicorp/terraform-plugin-codegen-spec/datasource"
"github.com/hashicorp/terraform-plugin-codegen-spec/provider"
"github.com/hashicorp/terraform-plugin-codegen-spec/resource"
)
type ResourceFloat64Attribute struct {
resource.Float64Attribute
Name string
}
func (a *ResourceFloat64Attribute) GetName() string {
return a.Name
}
func (a *ResourceFloat64Attribute) Merge(mergeAttribute ResourceAttribute) (ResourceAttribute, error) {
float64Attribute, ok := mergeAttribute.(*ResourceFloat64Attribute)
// TODO: return error if types don't match?
if ok && (a.Description == nil || *a.Description == "") {
a.Description = float64Attribute.Description
}
return a, nil
}
func (a *ResourceFloat64Attribute) ApplyOverride(override config.Override) (ResourceAttribute, error) {
a.Description = &override.Description
return a, nil
}
func (a *ResourceFloat64Attribute) ToSpec() resource.Attribute {
return resource.Attribute{
Name: util.TerraformIdentifier(a.Name),
Float64: &a.Float64Attribute,
}
}
type DataSourceFloat64Attribute struct {
datasource.Float64Attribute
Name string
}
func (a *DataSourceFloat64Attribute) GetName() string {
return a.Name
}
func (a *DataSourceFloat64Attribute) Merge(mergeAttribute DataSourceAttribute) (DataSourceAttribute, error) {
float64Attribute, ok := mergeAttribute.(*DataSourceFloat64Attribute)
// TODO: return error if types don't match?
if ok && (a.Description == nil || *a.Description == "") {
a.Description = float64Attribute.Description
}
return a, nil
}
func (a *DataSourceFloat64Attribute) ApplyOverride(override config.Override) (DataSourceAttribute, error) {
a.Description = &override.Description
return a, nil
}
func (a *DataSourceFloat64Attribute) ToSpec() datasource.Attribute {
return datasource.Attribute{
Name: util.TerraformIdentifier(a.Name),
Float64: &a.Float64Attribute,
}
}
type ProviderFloat64Attribute struct {
provider.Float64Attribute
Name string
}
func (a *ProviderFloat64Attribute) ToSpec() provider.Attribute {
return provider.Attribute{
Name: util.TerraformIdentifier(a.Name),
Float64: &a.Float64Attribute,
}
}