-
Notifications
You must be signed in to change notification settings - Fork 91
/
list.go
49 lines (37 loc) · 1.21 KB
/
list.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.List = List{}
// Declarative defaults.List for unit testing.
type List struct {
// defaults.Describer interface methods
DescriptionMethod func(context.Context) string
MarkdownDescriptionMethod func(context.Context) string
// defaults.List interface methods
DefaultListMethod func(context.Context, defaults.ListRequest, *defaults.ListResponse)
}
// Description satisfies the defaults.Describer interface.
func (v List) Description(ctx context.Context) string {
if v.DescriptionMethod == nil {
return ""
}
return v.DescriptionMethod(ctx)
}
// MarkdownDescription satisfies the defaults.Describer interface.
func (v List) MarkdownDescription(ctx context.Context) string {
if v.MarkdownDescriptionMethod == nil {
return ""
}
return v.MarkdownDescriptionMethod(ctx)
}
// DefaultList satisfies the defaults.List interface.
func (v List) DefaultList(ctx context.Context, req defaults.ListRequest, resp *defaults.ListResponse) {
if v.DefaultListMethod == nil {
return
}
v.DefaultListMethod(ctx, req, resp)
}