@@ -3,15 +3,15 @@ package v1
33import "context"
44
55type Cluster struct {
6+ // The ID assigned by the cloud provider to the cluster.
7+ ID CloudProviderResourceID
8+
69 // The name of the cluster, displayed on clients.
710 Name string
811
912 // The unique ID used to associate with this cluster.
1013 RefID string
1114
12- // The ID assigned by the cloud provider to the cluster.
13- CloudID string
14-
1515 // The cloud provider that manages the cluster.
1616 Provider string
1717
@@ -49,6 +49,10 @@ type NodeGroup struct {
4949
5050 // The unique ID used to associate with this node group.
5151 RefID string
52+
53+ // The ID assigned by the cloud provider to the node group.
54+ ID CloudProviderResourceID
55+
5256 // The minimum number of nodes in the node group.
5357 MinNodeCount int
5458
@@ -57,15 +61,21 @@ type NodeGroup struct {
5761
5862 // The instance type of the nodes in the node group.
5963 InstanceType string
64+
65+ // The disk size of the nodes in the node group.
66+ DiskSizeGiB int
6067}
6168
6269type ClusterStatus string
6370
6471const (
72+ ClusterStatusUnknown ClusterStatus = "unknown"
6573 ClusterStatusPending ClusterStatus = "pending"
6674 ClusterStatusAvailable ClusterStatus = "available"
6775)
6876
77+ type CloudProviderResourceID string
78+
6979type CreateClusterArgs struct {
7080 Name string
7181 RefID string
@@ -76,7 +86,7 @@ type CreateClusterArgs struct {
7686}
7787
7888type PutUserArgs struct {
79- ClusterRefID string
89+ ClusterID CloudProviderResourceID
8090 Username string
8191 RSAPEMBase64 string
8292}
@@ -91,8 +101,12 @@ type PutUserResponse struct {
91101 KubeconfigBase64 string
92102}
93103
104+ type GetClusterArgs struct {
105+ ID CloudProviderResourceID
106+ }
107+
94108type CreateNodeGroupArgs struct {
95- ClusterRefID string
109+ ClusterID CloudProviderResourceID
96110 Name string
97111 RefID string
98112 MinNodeCount int
@@ -101,26 +115,105 @@ type CreateNodeGroupArgs struct {
101115 DiskSizeGiB int
102116}
103117
118+ type GetNodeGroupArgs struct {
119+ ID CloudProviderResourceID
120+ }
121+
122+ type ModifyNodeGroupArgs struct {
123+ ID CloudProviderResourceID
124+ MinNodeCount int
125+ MaxNodeCount int
126+ }
127+
128+ type DeleteNodeGroupArgs struct {
129+ ID CloudProviderResourceID
130+ }
131+
104132type CreateNodeGroupResponse struct {
105- ClusterRefID string
133+ ID CloudProviderResourceID
106134 Name string
107135 RefID string
108- }
109-
110- type GetClusterArgs struct {
111- RefID string
112- CloudID string
113- Location string
136+ MinNodeCount int
137+ MaxNodeCount int
138+ InstanceType string
139+ DiskSizeGiB int
114140}
115141
116142type DeleteClusterArgs struct {
117- ClusterRefID string
143+ ID CloudProviderResourceID
118144}
119145
120146type CloudMaintainKubernetes interface {
121147 CreateCluster (ctx context.Context , args CreateClusterArgs ) (* Cluster , error )
122148 GetCluster (ctx context.Context , args GetClusterArgs ) (* Cluster , error )
123149 PutUser (ctx context.Context , args PutUserArgs ) (* PutUserResponse , error )
124150 CreateNodeGroup (ctx context.Context , args CreateNodeGroupArgs ) (* CreateNodeGroupResponse , error )
151+ GetNodeGroup (ctx context.Context , args GetNodeGroupArgs ) (* NodeGroup , error )
152+ ModifyNodeGroup (ctx context.Context , args ModifyNodeGroupArgs ) error
153+ DeleteNodeGroup (ctx context.Context , args DeleteNodeGroupArgs ) error
125154 DeleteCluster (ctx context.Context , args DeleteClusterArgs ) error
126155}
156+
157+ func ValidateCreateKubernetesCluster (ctx context.Context , client CloudMaintainKubernetes , attrs CreateClusterArgs ) error {
158+ _ , err := client .CreateCluster (ctx , attrs )
159+ if err != nil {
160+ return err
161+ }
162+ return nil
163+ }
164+
165+ func ValidateGetKubernetesCluster (ctx context.Context , client CloudMaintainKubernetes , attrs GetClusterArgs ) error {
166+ _ , err := client .GetCluster (ctx , attrs )
167+ if err != nil {
168+ return err
169+ }
170+ return nil
171+ }
172+
173+ func ValidateGetKubernetesClusterCredentials (ctx context.Context , client CloudMaintainKubernetes , attrs GetClusterArgs ) error {
174+ _ , err := client .GetCluster (ctx , attrs )
175+ if err != nil {
176+ return err
177+ }
178+ return nil
179+ }
180+
181+ func ValidateCreateKubernetesNodeGroup (ctx context.Context , client CloudMaintainKubernetes , attrs CreateNodeGroupArgs ) error {
182+ _ , err := client .CreateNodeGroup (ctx , attrs )
183+ if err != nil {
184+ return err
185+ }
186+ return nil
187+ }
188+
189+ func ValidateGetKubernetesNodeGroup (ctx context.Context , client CloudMaintainKubernetes , attrs GetNodeGroupArgs ) error {
190+ _ , err := client .GetNodeGroup (ctx , attrs )
191+ if err != nil {
192+ return err
193+ }
194+ return nil
195+ }
196+
197+ func ValidateModifyKubernetesNodeGroup (ctx context.Context , client CloudMaintainKubernetes , attrs ModifyNodeGroupArgs ) error {
198+ err := client .ModifyNodeGroup (ctx , attrs )
199+ if err != nil {
200+ return err
201+ }
202+ return nil
203+ }
204+
205+ func ValidateDeleteKubernetesNodeGroup (ctx context.Context , client CloudMaintainKubernetes , attrs DeleteNodeGroupArgs ) error {
206+ err := client .DeleteNodeGroup (ctx , attrs )
207+ if err != nil {
208+ return err
209+ }
210+ return nil
211+ }
212+
213+ func ValidateDeleteKubernetesCluster (ctx context.Context , client CloudMaintainKubernetes , attrs DeleteClusterArgs ) error {
214+ err := client .DeleteCluster (ctx , attrs )
215+ if err != nil {
216+ return err
217+ }
218+ return nil
219+ }
0 commit comments