Skip to content

Commit

Permalink
Merge branch 'main' into rak16/DOCR-1201/add-multi-registry-beta-apis
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsomething authored Nov 1, 2024
2 parents d934b1b + 2654a9d commit 8ce8fe5
Show file tree
Hide file tree
Showing 11 changed files with 682 additions and 18 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## [v1.128.0] - 2024-10-24

- #746 - @blesswinsamuel - Add archive field to AppSpec to archive/restore apps
- #745 - @asaha2 - Add load balancer monitoring endpoints
- #744 - @asaha2 - Adjust delete dangerous
- #743 - @asaha2 - Introduce droplet autoscale godo methods
- #740 - @blesswinsamuel - Add maintenance field to AppSpec to enable/disable maintenance mode
- #739 - @markusthoemmes - Add protocol to AppSpec and pending to detect responses

## [v1.127.0] - 2024-10-18

- #737 - @loosla - [databases]: change Opensearch ism_history_max_docs type to int64 to …
Expand Down
3 changes: 3 additions & 0 deletions apps.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions apps_accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions apps_accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions droplets.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var errNoNetworks = errors.New("no networks have been defined")
// See: https://docs.digitalocean.com/reference/api/api-reference/#tag/Droplets
type DropletsService interface {
List(context.Context, *ListOptions) ([]Droplet, *Response, error)
ListWithGPUs(context.Context, *ListOptions) ([]Droplet, *Response, error)
ListByName(context.Context, string, *ListOptions) ([]Droplet, *Response, error)
ListByTag(context.Context, string, *ListOptions) ([]Droplet, *Response, error)
Get(context.Context, int) (*Droplet, *Response, error)
Expand Down Expand Up @@ -321,6 +322,17 @@ func (s *DropletsServiceOp) List(ctx context.Context, opt *ListOptions) ([]Dropl
return s.list(ctx, path)
}

// ListWithGPUs lists all Droplets with GPUs.
func (s *DropletsServiceOp) ListWithGPUs(ctx context.Context, opt *ListOptions) ([]Droplet, *Response, error) {
path := fmt.Sprintf("%s?type=gpus", dropletBasePath)
path, err := addOptions(path, opt)
if err != nil {
return nil, nil, err
}

return s.list(ctx, path)
}

// ListByName lists all Droplets filtered by name returning only exact matches.
// It is case-insensitive
func (s *DropletsServiceOp) ListByName(ctx context.Context, name string, opt *ListOptions) ([]Droplet, *Response, error) {
Expand Down
92 changes: 92 additions & 0 deletions droplets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,98 @@ func TestDroplets_ListDroplets(t *testing.T) {
}
}

func TestDroplets_ListDropletsWithGPUs(t *testing.T) {
setup()
defer teardown()

mux.HandleFunc("/v2/droplets", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
if r.URL.Query().Get("type") != "gpus" {
t.Errorf("Droplets.ListWithGPUs did not request with a type parameter")
}
fmt.Fprint(w, `{
"droplets": [
{
"id": 1,
"size": {
"gpu_info": {
"count": 1,
"vram": {
"amount": 8,
"unit": "gib"
},
"model": "nvidia_tesla_v100"
},
"disk_info": [
{
"type": "local",
"size": {
"amount": 200,
"unit": "gib"
}
},
{
"type": "scratch",
"size": {
"amount": 40960,
"unit": "gib"
}
}
]
}
}
],
"meta": {
"total": 1
}
}`)
})

droplets, resp, err := client.Droplets.ListWithGPUs(ctx, nil)
if err != nil {
t.Errorf("Droplets.List returned error: %v", err)
}

expectedDroplets := []Droplet{
{
ID: 1,
Size: &Size{
GPUInfo: &GPUInfo{
Count: 1,
VRAM: &VRAM{
Amount: 8,
Unit: "gib",
},
Model: "nvidia_tesla_v100",
},
DiskInfo: []DiskInfo{
{
Type: "local",
Size: &DiskSize{
Amount: 200,
Unit: "gib",
},
},
{
Type: "scratch",
Size: &DiskSize{
Amount: 40960,
Unit: "gib",
},
},
},
},
},
}
if !reflect.DeepEqual(droplets, expectedDroplets) {
t.Errorf("Droplets.List\nDroplets: got=%#v\nwant=%#v", droplets, expectedDroplets)
}
expectedMeta := &Meta{Total: 1}
if !reflect.DeepEqual(resp.Meta, expectedMeta) {
t.Errorf("Droplets.List\nMeta: got=%#v\nwant=%#v", resp.Meta, expectedMeta)
}
}

func TestDroplets_ListDropletsByTag(t *testing.T) {
setup()
defer teardown()
Expand Down
2 changes: 1 addition & 1 deletion godo.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

const (
libraryVersion = "1.127.0"
libraryVersion = "1.128.0"
defaultBaseURL = "https://api.digitalocean.com/"
userAgent = "godo/" + libraryVersion
mediaType = "application/json"
Expand Down
Loading

0 comments on commit 8ce8fe5

Please sign in to comment.