Skip to content

Commit

Permalink
Upgrade vendored digitalocean/godo version to v1.22.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Normore committed Oct 21, 2019
1 parent 6da7fdf commit 1d39163
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 134 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor/
15 changes: 11 additions & 4 deletions cluster-autoscaler/cloudprovider/digitalocean/godo/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
language: go

go:
- 1.7
- 1.8
- 1.9
- "1.10"
- 1.7.x
- 1.8.x
- 1.9.x
- 1.10.x
- 1.11.x
- 1.12.x
- 1.13.x
- tip

matrix:
allow_failures:
- go: tip
13 changes: 13 additions & 0 deletions cluster-autoscaler/cloudprovider/digitalocean/godo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Change Log

## [v1.22.0] - 2019-09-24

- #259 Add Kubernetes GetCredentials method - @snormore

## [v1.21.1] - 2019-09-19

- #257 Upgrade to Go 1.13 - @bentranter

## [v1.21.0] - 2019-09-16

- #255 Add DropletID to Kubernetes Node instance - @snormore
- #254 Add tags to Database, DatabaseReplica - @Zyqsempai

## [v1.20.0] - 2019-09-06

- #252 Add Kubernetes autoscale config fields - @snormore
Expand Down
32 changes: 15 additions & 17 deletions cluster-autoscaler/cloudprovider/digitalocean/godo/VENDORED_VERSION
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
The godo package was vendored based on the following git SHA:
The `godo` package was vendored based on the git SHA `1f632d37f6858f0532207a5f77118c097d94be89`.

8d8fad298a2eb45d1139313816d50a9ab5e423cd
* We removed the `util/` folder because it's not needed.
* We removed the `go.mod` to avoid conflicts (https://github.com/kubernetes/autoscaler/commit/a96bd9adc3d041cb2328b88101d995546e360d15#diff-d5d7c905baa3f3ba3fd4563b8b5ff9fa).
* We vendored the dependencies by calling `go mod vendor` after checking out a new version.

* We removed the `util/` folder because it's not needed
* We vendored the dependencies by calling `go mod vendor` after checking out a new version
To upgrade to a new `godo` version do the following:

To upgrade to a new godo version do the following:

```
```sh
cd cloudprovider/digitalocean

# remove the godo folder
# Remove the godo folder
rm -rf godo/

# clone the godo folder
# Clone the godo folder
git clone https://github.com/digitalocean/godo
cd godo

# checkout to new release, replace the version. Here we're using v1.19.0
git checkout v1.19.0
# Checkout to new release, replace the version. Here we're using v1.22.0
git checkout v1.22.0

# remove the .git and util/
rm -rf .git
rm -rf util/

# vendor all dependencies
# Vendor all dependencies
go mod vendor

# edit this file to include that you're using now the latest version
# Remove the .git and util/
rm -rf .git util/ go.mod

# Re-add this VENDORED_VERSION file and edit to indicate which version is now being used.
```
26 changes: 15 additions & 11 deletions cluster-autoscaler/cloudprovider/digitalocean/godo/databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type Database struct {
MaintenanceWindow *DatabaseMaintenanceWindow `json:"maintenance_window,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
PrivateNetworkUUID string `json:"private_network_uuid,omitempty"`
Tags []string `json:"tags,omitempty"`
}

// DatabaseConnection represents a database connection
Expand Down Expand Up @@ -123,13 +124,14 @@ type DatabaseBackup struct {

// DatabaseCreateRequest represents a request to create a database cluster
type DatabaseCreateRequest struct {
Name string `json:"name,omitempty"`
EngineSlug string `json:"engine,omitempty"`
Version string `json:"version,omitempty"`
SizeSlug string `json:"size,omitempty"`
Region string `json:"region,omitempty"`
NumNodes int `json:"num_nodes,omitempty"`
PrivateNetworkUUID string `json:"private_network_uuid"`
Name string `json:"name,omitempty"`
EngineSlug string `json:"engine,omitempty"`
Version string `json:"version,omitempty"`
SizeSlug string `json:"size,omitempty"`
Region string `json:"region,omitempty"`
NumNodes int `json:"num_nodes,omitempty"`
PrivateNetworkUUID string `json:"private_network_uuid"`
Tags []string `json:"tags,omitempty"`
}

// DatabaseResizeRequest can be used to initiate a database resize operation.
Expand Down Expand Up @@ -167,6 +169,7 @@ type DatabaseReplica struct {
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
PrivateNetworkUUID string `json:"private_network_uuid,omitempty"`
Tags []string `json:"tags,omitempty"`
}

// DatabasePool represents a database connection pool
Expand Down Expand Up @@ -201,10 +204,11 @@ type DatabaseCreateDBRequest struct {

// DatabaseCreateReplicaRequest is used to create a new read-only replica
type DatabaseCreateReplicaRequest struct {
Name string `json:"name"`
Region string `json:"region"`
Size string `json:"size"`
PrivateNetworkUUID string `json:"private_network_uuid"`
Name string `json:"name"`
Region string `json:"region"`
Size string `json:"size"`
PrivateNetworkUUID string `json:"private_network_uuid"`
Tags []string `json:"tags,omitempty"`
}

type databaseUserRoot struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var db = Database{
SSL: true,
},
Users: []DatabaseUser{
{
DatabaseUser{
Name: "doadmin",
Role: "primary",
Password: "zt91mum075ofzyww",
Expand All @@ -57,6 +57,7 @@ var db = Database{
},
SizeSlug: "db-s-2vcpu-4gb",
PrivateNetworkUUID: "da4e0206-d019-41d7-b51f-deadbeefbb8f",
Tags: []string{"production", "staging"},
}

var dbJSON = `
Expand Down Expand Up @@ -104,7 +105,8 @@ var dbJSON = `
"description": null
},
"size": "db-s-2vcpu-4gb",
"private_network_uuid": "da4e0206-d019-41d7-b51f-deadbeefbb8f"
"private_network_uuid": "da4e0206-d019-41d7-b51f-deadbeefbb8f",
"tags": ["production", "staging"]
}
`

Expand Down Expand Up @@ -193,6 +195,7 @@ func TestDatabases_Create(t *testing.T) {
CreatedAt: time.Date(2019, 2, 26, 6, 12, 39, 0, time.UTC),
MaintenanceWindow: nil,
SizeSlug: "db-s-2vcpu-4gb",
Tags: []string{"production", "staging"},
}

createRequest := &DatabaseCreateRequest{
Expand All @@ -202,6 +205,7 @@ func TestDatabases_Create(t *testing.T) {
Region: "nyc3",
SizeSlug: "db-s-2vcpu-4gb",
NumNodes: 2,
Tags: []string{"production", "staging"},
}

body := `
Expand Down Expand Up @@ -236,7 +240,8 @@ func TestDatabases_Create(t *testing.T) {
"status": "creating",
"created_at": "2019-02-26T06:12:39Z",
"maintenance_window": null,
"size": "db-s-2vcpu-4gb"
"size": "db-s-2vcpu-4gb",
"tags": ["production", "staging"]
}
}`

Expand Down Expand Up @@ -361,11 +366,11 @@ func TestDatabases_ListBackups(t *testing.T) {
defer teardown()

want := []DatabaseBackup{
{
DatabaseBackup{
CreatedAt: time.Date(2019, 1, 11, 18, 42, 27, 0, time.UTC),
SizeGigabytes: 0.03357696,
},
{
DatabaseBackup{
CreatedAt: time.Date(2019, 1, 12, 18, 42, 29, 0, time.UTC),
SizeGigabytes: 0.03364864,
},
Expand Down Expand Up @@ -918,6 +923,7 @@ func TestDatabases_GetReplica(t *testing.T) {
Database: "db",
},
PrivateNetworkUUID: "deadbeef-dead-4aa5-beef-deadbeef347d",
Tags: []string{"production", "staging"},
}

body := `
Expand Down Expand Up @@ -945,7 +951,8 @@ func TestDatabases_GetReplica(t *testing.T) {
"database": "db",
"ssl": true
},
"private_network_uuid": "deadbeef-dead-4aa5-beef-deadbeef347d"
"private_network_uuid": "deadbeef-dead-4aa5-beef-deadbeef347d",
"tags": ["production", "staging"]
}
}
`
Expand Down Expand Up @@ -994,6 +1001,7 @@ func TestDatabases_ListReplicas(t *testing.T) {
Database: "db",
},
PrivateNetworkUUID: "deadbeef-dead-4aa5-beef-deadbeef347d",
Tags: []string{"production", "staging"},
},
}

Expand Down Expand Up @@ -1022,7 +1030,8 @@ func TestDatabases_ListReplicas(t *testing.T) {
"database": "db",
"ssl": true
},
"private_network_uuid": "deadbeef-dead-4aa5-beef-deadbeef347d"
"private_network_uuid": "deadbeef-dead-4aa5-beef-deadbeef347d",
"tags": ["production", "staging"]
}]
}
`
Expand Down Expand Up @@ -1070,6 +1079,7 @@ func TestDatabases_CreateReplica(t *testing.T) {
Database: "db",
},
PrivateNetworkUUID: "deadbeef-dead-4aa5-beef-deadbeef347d",
Tags: []string{"production", "staging"},
}

body := `
Expand Down Expand Up @@ -1097,7 +1107,8 @@ func TestDatabases_CreateReplica(t *testing.T) {
"database": "db",
"ssl": true
},
"private_network_uuid": "deadbeef-dead-4aa5-beef-deadbeef347d"
"private_network_uuid": "deadbeef-dead-4aa5-beef-deadbeef347d",
"tags": ["production", "staging"]
}
}
`
Expand All @@ -1113,6 +1124,7 @@ func TestDatabases_CreateReplica(t *testing.T) {
Region: "nyc1",
Size: "db-s-2vcpu-4gb",
PrivateNetworkUUID: privateNetworkUUID,
Tags: []string{"production", "staging"},
})
require.NoError(t, err)
require.Equal(t, want, got)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ func TestFirewalls_RemoveRules(t *testing.T) {

func makeExpectedFirewalls() []Firewall {
return []Firewall{
{
Firewall{
ID: "fe6b88f2-b42b-4bf7-bbd3-5ae20208f0b0",
Name: "f-i-r-e-w-a-l-l",
InboundRules: []InboundRule{
Expand Down
3 changes: 3 additions & 0 deletions cluster-autoscaler/cloudprovider/digitalocean/godo/go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
Expand All @@ -14,6 +15,8 @@ golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA=
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
2 changes: 1 addition & 1 deletion cluster-autoscaler/cloudprovider/digitalocean/godo/godo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

const (
libraryVersion = "1.20.0"
libraryVersion = "1.22.0"
defaultBaseURL = "https://api.digitalocean.com/"
userAgent = "godo/" + libraryVersion
mediaType = "application/json"
Expand Down
36 changes: 36 additions & 0 deletions cluster-autoscaler/cloudprovider/digitalocean/godo/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
"time"
)
Expand All @@ -27,6 +28,7 @@ type KubernetesService interface {
GetUser(context.Context, string) (*KubernetesClusterUser, *Response, error)
GetUpgrades(context.Context, string) ([]*KubernetesVersion, *Response, error)
GetKubeConfig(context.Context, string) (*KubernetesClusterConfig, *Response, error)
GetCredentials(context.Context, string, *KubernetesClusterCredentialsGetRequest) (*KubernetesClusterCredentials, *Response, error)
List(context.Context, *ListOptions) ([]*KubernetesCluster, *Response, error)
Update(context.Context, string, *KubernetesClusterUpdateRequest) (*KubernetesCluster, *Response, error)
Upgrade(context.Context, string, *KubernetesClusterUpgradeRequest) (*Response, error)
Expand Down Expand Up @@ -117,6 +119,11 @@ type KubernetesNodeDeleteRequest struct {
SkipDrain bool `json:"skip_drain,omitempty"`
}

// KubernetesClusterCredentialsGetRequest is a request to get cluster credentials.
type KubernetesClusterCredentialsGetRequest struct {
ExpirySeconds *int `json:"expiry_seconds,omitempty"`
}

// KubernetesCluster represents a Kubernetes cluster.
type KubernetesCluster struct {
ID string `json:"id,omitempty"`
Expand Down Expand Up @@ -146,6 +153,16 @@ type KubernetesClusterUser struct {
Groups []string `json:"groups,omitempty"`
}

// KubernetesClusterCredentials represents Kubernetes cluster credentials.
type KubernetesClusterCredentials struct {
Server string `json:"server"`
CertificateAuthorityData []byte `json:"certificate_authority_data"`
ClientCertificateData []byte `json:"client_certificate_data"`
ClientKeyData []byte `json:"client_key_data"`
Token string `json:"token"`
ExpiresAt time.Time `json:"expires_at"`
}

// KubernetesMaintenancePolicy is a configuration to set the maintenance window
// of a cluster
type KubernetesMaintenancePolicy struct {
Expand Down Expand Up @@ -479,6 +496,25 @@ func (svc *KubernetesServiceOp) GetKubeConfig(ctx context.Context, clusterID str
return res, resp, nil
}

// GetCredentials returns a Kubernetes API server credentials for the specified cluster.
func (svc *KubernetesServiceOp) GetCredentials(ctx context.Context, clusterID string, get *KubernetesClusterCredentialsGetRequest) (*KubernetesClusterCredentials, *Response, error) {
path := fmt.Sprintf("%s/%s/credentials", kubernetesClustersPath, clusterID)
req, err := svc.client.NewRequest(ctx, http.MethodGet, path, nil)
if err != nil {
return nil, nil, err
}
q := req.URL.Query()
if get.ExpirySeconds != nil {
q.Add("expiry_seconds", strconv.Itoa(*get.ExpirySeconds))
}
credentials := new(KubernetesClusterCredentials)
resp, err := svc.client.Do(ctx, req, credentials)
if err != nil {
return nil, nil, err
}
return credentials, resp, nil
}

// Update updates a Kubernetes cluster's properties.
func (svc *KubernetesServiceOp) Update(ctx context.Context, clusterID string, update *KubernetesClusterUpdateRequest) (*KubernetesCluster, *Response, error) {
path := fmt.Sprintf("%s/%s", kubernetesClustersPath, clusterID)
Expand Down
Loading

0 comments on commit 1d39163

Please sign in to comment.