-
Notifications
You must be signed in to change notification settings - Fork 91
/
set.go
49 lines (37 loc) · 1.2 KB
/
set.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
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package testdefaults
import (
"context"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/defaults"
)
var _ defaults.Set = Set{}
// Declarative defaults.Set for unit testing.
type Set struct {
// defaults.Describer interface methods
DescriptionMethod func(context.Context) string
MarkdownDescriptionMethod func(context.Context) string
// defaults.Set interface methods
DefaultSetMethod func(context.Context, defaults.SetRequest, *defaults.SetResponse)
}
// Description satisfies the defaults.Describer interface.
func (v Set) Description(ctx context.Context) string {
if v.DescriptionMethod == nil {
return ""
}
return v.DescriptionMethod(ctx)
}
// MarkdownDescription satisfies the defaults.Describer interface.
func (v Set) MarkdownDescription(ctx context.Context) string {
if v.MarkdownDescriptionMethod == nil {
return ""
}
return v.MarkdownDescriptionMethod(ctx)
}
// DefaultSet satisfies the defaults.Set interface.
func (v Set) DefaultSet(ctx context.Context, req defaults.SetRequest, resp *defaults.SetResponse) {
if v.DefaultSetMethod == nil {
return
}
v.DefaultSetMethod(ctx, req, resp)
}