-
Notifications
You must be signed in to change notification settings - Fork 1
/
custom_data_source_common_schema.go
68 lines (63 loc) · 1.99 KB
/
custom_data_source_common_schema.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
68
/***************************************************************************
* ========================================================================
* Copyright 2022-2023 VMware, Inc. All rights reserved. VMware Confidential
* SPDX-License-Identifier: MPL-2.0
* ========================================================================
*/
package nsxt
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func getDataSourceCommonSchema(additionalSchemaItems map[string]*schema.Schema) map[string]*schema.Schema {
baseSchema := map[string]*schema.Schema{
"context": {
Type: schema.TypeList,
Description: "Datasource context information",
Required: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"scope": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"vpc", "project", "infra"}, false),
Description: "The scope in which the object exists or spans out of. It can be any one of vpc, project or infra.",
},
"domain": {
Type: schema.TypeString,
Optional: true,
Default: "default",
Description: "The domain ID of the object. Applicable for groups.",
},
},
},
},
"nsx_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "The id of the object on NSX.",
},
"display_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "The display name of the object.",
},
"description": {
Type: schema.TypeString,
Computed: true,
Description: "The description of the object.",
},
"path": {
Type: schema.TypeString,
Computed: true,
Description: "The complete policy path of the object.",
},
}
for key, value := range additionalSchemaItems {
baseSchema[key] = value
}
return baseSchema
}