/
data_source_illumio_container_cluster.go
141 lines (131 loc) · 3.62 KB
/
data_source_illumio_container_cluster.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Copyright 2021 Illumio, Inc. All Rights Reserved.
package illumiocore
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func datasourceIllumioContainerCluster() *schema.Resource {
return &schema.Resource{
ReadContext: datasourceIllumioContainerClusterRead,
SchemaVersion: 1,
Description: "Represents Illumio Container Cluster",
Schema: map[string]*schema.Schema{
"href": {
Type: schema.TypeString,
Required: true,
Description: "URI of the Cluster",
ValidateDiagFunc: isContainerClusterHref,
},
"name": {
Type: schema.TypeString,
Computed: true,
Description: "Name of the Cluster",
},
"description": {
Type: schema.TypeString,
Computed: true,
Description: "Description of the Cluster",
},
"nodes": {
Type: schema.TypeList,
Computed: true,
Description: "Nodes of the Cluster",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"pod_subnet": {
Type: schema.TypeString,
Computed: true,
Description: "Pod Subnet of the node",
},
},
},
},
"container_runtime": {
Type: schema.TypeString,
Computed: true,
Description: "The Container Runtime used in this Cluster",
},
"manager_type": {
Type: schema.TypeString,
Computed: true,
Description: "Manager for this Cluster (and version)",
},
"last_connected": {
Type: schema.TypeString,
Computed: true,
Description: "Time the Cluster last connected to",
},
"online": {
Type: schema.TypeBool,
Computed: true,
Description: "Whether the Cluster is online or not",
},
"errors": {
Type: schema.TypeList,
Computed: true,
Description: "Errors for Cluster",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"audit_event": {
Type: schema.TypeMap,
Computed: true,
Description: "Audit Event of Error",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"duplicate_ids": {
Type: schema.TypeList,
Computed: true,
Description: "Duplicate IDs of Error",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"error_type": {
Type: schema.TypeString,
Computed: true,
Description: "Error Type of Error",
},
},
},
},
"kubelink_version": {
Type: schema.TypeString,
Computed: true,
Description: "Kubelink software version string for Cluster",
},
"pce_fqdn": {
Type: schema.TypeString,
Computed: true,
Description: "PCE FQDN for this container cluster. Used in Supercluster only",
},
"caps": {
Type: schema.TypeList,
Computed: true,
Description: "User permissions for the object",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"container_cluster_id": {
Type: schema.TypeString,
Computed: true,
Description: "Convenience variable for the cluster UUID contained in the HREF",
},
},
}
}
func datasourceIllumioContainerClusterRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
var diagnostics diag.Diagnostics
pConfig, _ := m.(Config)
illumioClient := pConfig.IllumioClient
href := d.Get("href").(string)
_, data, err := illumioClient.Get(href, nil)
if err != nil {
return diag.FromErr(err)
}
resourceIllumioContainerClusterReadResult(d, data)
return diagnostics
}