Skip to content

Commit 47c6158

Browse files
author
maaft
committed
make ci happy
1 parent 97eab8b commit 47c6158

File tree

6 files changed

+241
-164
lines changed

6 files changed

+241
-164
lines changed

cluster-autoscaler/cloudprovider/datacrunch/datacrunch-go/client.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
package datacrunchclient
218

319
import (

cluster-autoscaler/cloudprovider/datacrunch/datacrunch-go/instances.go

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
package datacrunchclient
218

319
import (
@@ -9,6 +25,161 @@ import (
925
"net/url"
1026
)
1127

28+
// APIError represents an error response from the DataCrunch API.
29+
type APIError struct {
30+
Code string `json:"code"`
31+
Message string `json:"message"`
32+
}
33+
34+
// Instance represents a DataCrunch instance.
35+
type Instance struct {
36+
ID string `json:"id"`
37+
IP string `json:"ip"`
38+
Status string `json:"status"`
39+
CreatedAt string `json:"created_at"`
40+
CPU CPU `json:"cpu"`
41+
GPU GPU `json:"gpu"`
42+
GPUMemory GPUMem `json:"gpu_memory"`
43+
Memory Memory `json:"memory"`
44+
Storage Storage `json:"storage"`
45+
Hostname string `json:"hostname"`
46+
Description string `json:"description"`
47+
Location string `json:"location"`
48+
PricePerHour float64 `json:"price_per_hour"`
49+
IsSpot bool `json:"is_spot"`
50+
InstanceType string `json:"instance_type"`
51+
Image string `json:"image"`
52+
OSName string `json:"os_name"`
53+
StartupScript string `json:"startup_script_id"`
54+
SSHKeyIDs []string `json:"ssh_key_ids"`
55+
OSVolumeID string `json:"os_volume_id"`
56+
JupyterToken string `json:"jupyter_token"`
57+
Contract string `json:"contract"`
58+
Pricing string `json:"pricing"`
59+
}
60+
61+
// CPU represents a CPU in DataCrunch.
62+
type CPU struct {
63+
Description string `json:"description"`
64+
NumberOfCores int `json:"number_of_cores"`
65+
}
66+
67+
// GPU represents a GPU in DataCrunch.
68+
type GPU struct {
69+
Description string `json:"description"`
70+
NumberOfGPUs int `json:"number_of_gpus"`
71+
}
72+
73+
// GPUMem represents a GPU memory in DataCrunch.
74+
type GPUMem struct {
75+
Description string `json:"description"`
76+
SizeInGigabytes int `json:"size_in_gigabytes"`
77+
}
78+
79+
// Memory represents a memory in DataCrunch.
80+
type Memory struct {
81+
Description string `json:"description"`
82+
SizeInGigabytes int `json:"size_in_gigabytes"`
83+
}
84+
85+
// Storage represents a storage in DataCrunch.
86+
type Storage struct {
87+
Description string `json:"description"`
88+
}
89+
90+
// InstanceList is a list of instances.
91+
type InstanceList []Instance
92+
93+
// DeployInstanceRequest is the request body for creating a new instance.
94+
type DeployInstanceRequest struct {
95+
InstanceType string `json:"instance_type"`
96+
Image string `json:"image"`
97+
SSHKeyIDs []string `json:"ssh_key_ids,omitempty"`
98+
StartupScriptID string `json:"startup_script_id,omitempty"`
99+
Hostname string `json:"hostname"`
100+
Description string `json:"description"`
101+
LocationCode string `json:"location_code,omitempty"`
102+
OSVolume *OSVolume `json:"os_volume,omitempty"`
103+
IsSpot bool `json:"is_spot"`
104+
Coupon string `json:"coupon,omitempty"`
105+
Volumes []DeployVolume `json:"volumes,omitempty"`
106+
ExistingVolumes []string `json:"existing_volumes,omitempty"`
107+
Contract string `json:"contract,omitempty"`
108+
Pricing string `json:"pricing,omitempty"`
109+
}
110+
111+
// OSVolume represents an OS volume in DataCrunch when creating a new instance.
112+
type OSVolume struct {
113+
Name string `json:"name"`
114+
Size int `json:"size"`
115+
}
116+
117+
// DeployVolume represents a deploy volume in DataCrunch when creating a new instance.
118+
type DeployVolume struct {
119+
Name string `json:"name"`
120+
Size int `json:"size"`
121+
Type string `json:"type"`
122+
}
123+
124+
// DeployInstanceResponse is the response for creating a new instance (instance ID).
125+
type DeployInstanceResponse string
126+
127+
// InstanceActionRequest is the request body for performing an action on an instance.
128+
type InstanceActionRequest struct {
129+
Action string `json:"action"`
130+
ID string `json:"id"`
131+
VolumeIDs []string `json:"volume_ids,omitempty"`
132+
}
133+
134+
// InstanceType represents an instance type.
135+
type InstanceType struct {
136+
BestFor []string `json:"best_for"`
137+
CPU CPU `json:"cpu"`
138+
DeployWarning string `json:"deploy_warning"`
139+
Description string `json:"description"`
140+
GPU GPU `json:"gpu"`
141+
GPUMemory GPUMem `json:"gpu_memory"`
142+
Memory Memory `json:"memory"`
143+
Model string `json:"model"`
144+
ID string `json:"id"`
145+
InstanceType string `json:"instance_type"`
146+
Name string `json:"name"`
147+
P2P string `json:"p2p"`
148+
PricePerHour string `json:"price_per_hour"`
149+
SpotPrice string `json:"spot_price"`
150+
DynamicPrice string `json:"dynamic_price"`
151+
MaxDynamicPrice string `json:"max_dynamic_price"`
152+
ServerlessPrice string `json:"serverless_price"`
153+
ServerlessSpotPrice string `json:"serverless_spot_price"`
154+
Storage Storage `json:"storage"`
155+
Currency string `json:"currency"`
156+
Manufacturer string `json:"manufacturer"`
157+
DisplayName string `json:"display_name"`
158+
}
159+
160+
// InstanceTypeList is a list of instance types.
161+
type InstanceTypeList []InstanceType
162+
163+
// PriceHistoryEntry represents a price history entry for an instance type.
164+
type PriceHistoryEntry struct {
165+
Date string `json:"date"`
166+
FixedPricePerHour float64 `json:"fixed_price_per_hour"`
167+
DynamicPricePerHour float64 `json:"dynamic_price_per_hour"`
168+
Currency string `json:"currency"`
169+
}
170+
171+
// PriceHistory is a map of instance types to price history entries.
172+
type PriceHistory map[string][]PriceHistoryEntry
173+
174+
// InstanceAvailability represents instance availability for a location.
175+
type InstanceAvailability struct {
176+
LocationCode string `json:"location_code"`
177+
Availabilities []string `json:"availabilities"`
178+
}
179+
180+
// InstanceAvailabilityList is a list of instance availabilities.
181+
type InstanceAvailabilityList []InstanceAvailability
182+
12183
// ListInstances returns all instances, optionally filtered by status.
13184
func (c *Client) ListInstances(status string) (InstanceList, error) {
14185
endpoint := c.baseURL + "/instances"

cluster-autoscaler/cloudprovider/datacrunch/datacrunch-go/scripts.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
package datacrunchclient
218

319
import (
@@ -7,6 +23,13 @@ import (
723
"net/http"
824
)
925

26+
// StartupScript represents a startup script in DataCrunch.
27+
type StartupScript struct {
28+
ID string `json:"id"`
29+
Name string `json:"name"`
30+
Script string `json:"script"`
31+
}
32+
1033
// UploadStartupScript uploads a startup script to DataCrunch and returns its script ID.
1134
func (c *Client) UploadStartupScript(name string, script string) (string, error) {
1235
type addScriptRequest struct {

cluster-autoscaler/cloudprovider/datacrunch/datacrunch-go/sshkeys.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
// cloudprovider/datacrunch/datacrunch-go/sshkeys.go
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
216

317
package datacrunchclient
418

0 commit comments

Comments
 (0)