-
Notifications
You must be signed in to change notification settings - Fork 645
/
data_source_ibm_container_dedicated_host.go
156 lines (149 loc) · 3.81 KB
/
data_source_ibm_container_dedicated_host.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// Copyright IBM Corp. 2017, 2022 All Rights Reserved.
// Licensed under the Mozilla Public License v2.0
package kubernetes
import (
"context"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func DataSourceIBMContainerDedicatedHost() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceIBMContainerDedicatedHostRead,
Schema: map[string]*schema.Schema{
"host_id": {
Type: schema.TypeString,
Required: true,
Description: "The id of the dedicated host",
},
"host_pool_id": {
Type: schema.TypeString,
Required: true,
Description: "The id of the dedicated host pool the dedicated host is associated with",
},
"flavor": {
Type: schema.TypeString,
Computed: true,
Description: "The flavor of the dedicated host",
},
"placement_enabled": {
Type: schema.TypeBool,
Computed: true,
Description: "Describes if the placement on the dedicated host is enabled",
},
"life_cycle": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"actual_state": {
Type: schema.TypeString,
Computed: true,
},
"desired_state": {
Type: schema.TypeString,
Computed: true,
},
"message": {
Type: schema.TypeString,
Computed: true,
},
"message_date": {
Type: schema.TypeString,
Computed: true,
},
"message_details": {
Type: schema.TypeString,
Computed: true,
},
"message_details_date": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"resources": {
Type: schema.TypeList,
Computed: true,
Description: "The resources of the dedicated host",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"capacity": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"memory_bytes": {
Type: schema.TypeInt,
Computed: true,
},
"vcpu": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"consumed": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"memory_bytes": {
Type: schema.TypeInt,
Computed: true,
},
"vcpu": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
"workers": {
Type: schema.TypeList,
Computed: true,
Description: "The workers of the dedicated host",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"cluster_id": {
Type: schema.TypeString,
Computed: true,
},
"flavor": {
Type: schema.TypeString,
Computed: true,
},
"worker_id": {
Type: schema.TypeString,
Computed: true,
},
"worker_pool_id": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"zone": {
Type: schema.TypeString,
Computed: true,
Description: "The zone of the dedicated host",
},
},
}
}
func dataSourceIBMContainerDedicatedHostRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
hostID := d.Get("host_id").(string)
hostPoolID := d.Get("host_pool_id").(string)
id := fmt.Sprintf("%s/%s", hostPoolID, hostID)
if err := getIBMContainerDedicatedHost(id, d, meta); err != nil {
return diag.Errorf("[ERROR] getIBMContainerDedicatedHost failed: %v", err)
}
d.SetId(id)
return nil
}