-
Notifications
You must be signed in to change notification settings - Fork 133
/
types_cloud_project_kube.go
115 lines (97 loc) · 4.01 KB
/
types_cloud_project_kube.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
package ovh
import (
"fmt"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/ovh/terraform-provider-ovh/ovh/helpers"
)
type CloudProjectKubeUpdatePolicyOpts struct {
UpdatePolicy string `json:"updatePolicy"`
}
// CloudProjectKubePutOpts update cluster options
type CloudProjectKubePutOpts struct {
Name *string `json:"name,omitempty"`
}
type privateNetworkConfiguration struct {
DefaultVrackGateway string `json:"defaultVrackGateway"`
PrivateNetworkRoutingAsDefault bool `json:"privateNetworkRoutingAsDefault"`
}
type CloudProjectKubeCreateOpts struct {
Name *string `json:"name,omitempty"`
PrivateNetworkId *string `json:"privateNetworkId,omitempty"`
PrivateNetworkConfiguration *privateNetworkConfiguration `json:"privateNetworkConfiguration,omitempty"`
Region string `json:"region"`
Version *string `json:"version,omitempty"`
UpdatePolicy *string `json:"updatePolicy,omitempty"`
}
func (opts *CloudProjectKubeCreateOpts) FromResource(d *schema.ResourceData) *CloudProjectKubeCreateOpts {
opts.Region = d.Get("region").(string)
opts.Version = helpers.GetNilStringPointerFromData(d, "version")
opts.Name = helpers.GetNilStringPointerFromData(d, "name")
opts.UpdatePolicy = helpers.GetNilStringPointerFromData(d, "update_policy")
opts.PrivateNetworkId = helpers.GetNilStringPointerFromData(d, "private_network_id")
opts.PrivateNetworkConfiguration = loadPrivateNetworkConfiguration(d.Get("private_network_configuration"))
return opts
}
func loadPrivateNetworkConfiguration(i interface{}) *privateNetworkConfiguration {
if i == nil {
return nil
}
pncOutput := privateNetworkConfiguration{}
pncSet := i.(*schema.Set).List()
for _, pnc := range pncSet {
mapping := pnc.(map[string]interface{})
pncOutput.DefaultVrackGateway = mapping["default_vrack_gateway"].(string)
pncOutput.PrivateNetworkRoutingAsDefault = mapping["private_network_routing_as_default"].(bool)
}
return &pncOutput
}
func (s *CloudProjectKubeCreateOpts) String() string {
return fmt.Sprintf("%s(%s): %s", *s.Name, s.Region, *s.Version)
}
type CloudProjectKubeResponse struct {
ControlPlaneIsUpToDate bool `json:"controlPlaneIsUpToDate"`
Id string `json:"id"`
IsUpToDate bool `json:"isUpToDate"`
Name string `json:"name"`
NextUpgradeVersions []string `json:"nextUpgradeVersions"`
NodesUrl string `json:"nodesUrl"`
PrivateNetworkId string `json:"privateNetworkId"`
Region string `json:"region"`
Status string `json:"status"`
UpdatePolicy string `json:"updatePolicy"`
Url string `json:"url"`
Version string `json:"version"`
}
func (v CloudProjectKubeResponse) ToMap() map[string]interface{} {
obj := make(map[string]interface{})
obj["control_plane_is_up_to_date"] = v.ControlPlaneIsUpToDate
obj["id"] = v.Id
obj["is_up_to_date"] = v.IsUpToDate
obj["name"] = v.Name
obj["next_upgrade_versions"] = v.NextUpgradeVersions
obj["nodes_url"] = v.NodesUrl
obj["private_network_id"] = v.PrivateNetworkId
obj["region"] = v.Region
obj["status"] = v.Status
obj["update_policy"] = v.UpdatePolicy
obj["url"] = v.Url
obj["version"] = v.Version[:strings.LastIndex(v.Version, ".")]
return obj
}
func (s *CloudProjectKubeResponse) String() string {
return fmt.Sprintf("%s(%s): %s", s.Name, s.Id, s.Status)
}
type CloudProjectKubeKubeConfigResponse struct {
Content string `json:"content"`
}
type CloudProjectKubeUpdateOpts struct {
Strategy string `json:"strategy"`
}
type CloudProjectKubeResetOpts struct {
PrivateNetworkId *string `json:"privateNetworkId,omitempty"`
}
type CloudProjectKubeUpdatePNCOpts struct {
DefaultVrackGateway string `json:"defaultVrackGateway"`
PrivateNetworkRoutingAsDefault bool `json:"privateNetworkRoutingAsDefault"`
}