From 1b1eb6ccb2190cfd17346ddf1f093e0377987ef9 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Thu, 28 Nov 2019 19:57:37 +0000 Subject: [PATCH] Migrate provision package to inletsctl This package comes over from the operator to keep the provision- ing code separate from the operator. The operator will vendor it back after the next release. Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- Gopkg.lock | 30 ++- Gopkg.toml | 61 +++++- cmd/create.go | 8 +- cmd/inletsctl.go | 11 +- pkg/{ => names}/names.go | 2 +- pkg/{ => provision}/civo.go | 19 +- .../pkg => pkg}/provision/digitalocean.go | 0 .../pkg => pkg}/provision/packet.go | 0 .../pkg => pkg}/provision/provision.go | 0 .../pkg => pkg}/provision/scaleway.go | 0 .../github.com/digitalocean/godo/CHANGELOG.md | 28 +++ .../digitalocean/godo/CONTRIBUTING.md | 2 +- .../github.com/digitalocean/godo/databases.go | 176 +++++++++++++++--- vendor/github.com/digitalocean/godo/godo.go | 8 +- vendor/github.com/digitalocean/godo/links.go | 2 +- .../github.com/digitalocean/godo/registry.go | 119 ++++++++++++ .../github.com/inlets/inlets-operator/LICENSE | 21 --- vendor/github.com/packethost/packngo/go.mod | 2 - vendor/gopkg.in/yaml.v2/.travis.yml | 18 +- vendor/gopkg.in/yaml.v2/decode.go | 14 +- vendor/gopkg.in/yaml.v2/scannerc.go | 76 ++++---- vendor/gopkg.in/yaml.v2/yaml.go | 2 +- 22 files changed, 462 insertions(+), 137 deletions(-) rename pkg/{ => names}/names.go (99%) rename pkg/{ => provision}/civo.go (87%) rename {vendor/github.com/inlets/inlets-operator/pkg => pkg}/provision/digitalocean.go (100%) rename {vendor/github.com/inlets/inlets-operator/pkg => pkg}/provision/packet.go (100%) rename {vendor/github.com/inlets/inlets-operator/pkg => pkg}/provision/provision.go (100%) rename {vendor/github.com/inlets/inlets-operator/pkg => pkg}/provision/scaleway.go (100%) create mode 100644 vendor/github.com/digitalocean/godo/registry.go delete mode 100644 vendor/github.com/inlets/inlets-operator/LICENSE diff --git a/Gopkg.lock b/Gopkg.lock index c8948a12..247adec3 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -2,12 +2,12 @@ [[projects]] - digest = "1:918fd0f816026bb4ceb1787292fa04bf59810f3d494714fe016a7208d5485713" + digest = "1:5bd74021baf638b4e3493a6832c89ee554058154d17e14d2f5a5345013f5f703" name = "github.com/digitalocean/godo" packages = ["."] pruneopts = "UT" - revision = "1f632d37f6858f0532207a5f77118c097d94be89" - version = "v1.22.0" + revision = "2a154f748812b9414534b84f082cee6ec3b4c8ab" + version = "v1.27.0" [[projects]] digest = "1:573ca21d3669500ff845bdebee890eb7fc7f0f50c59f2132f2a0c6b03d85086a" @@ -33,14 +33,6 @@ revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" -[[projects]] - digest = "1:8325efccba09192c58158f6d9f13c9d75ae146339e109929c86661b50607260a" - name = "github.com/inlets/inlets-operator" - packages = ["pkg/provision"] - pruneopts = "UT" - revision = "c467775d40a6d1ce9de1432b95ab38329be191f1" - version = "0.4.3" - [[projects]] digest = "1:906eb1ca3c8455e447b99a45237b2b9615b665608fd07ad12cce847dd9a1ec43" name = "github.com/morikuni/aec" @@ -118,7 +110,7 @@ "context/ctxhttp", ] pruneopts = "UT" - revision = "fe3aa8a4527195a6057b3fad46619d7d090e99b5" + revision = "ef20fe5d793301b553005db740f730d87993f778" [[projects]] branch = "master" @@ -129,7 +121,7 @@ "internal", ] pruneopts = "UT" - revision = "0f29369cfe4552d0e4bcddc57cc75f4d7e672a33" + revision = "5d9234df094ce600ff541158d1491aa10d078a47" [[projects]] digest = "1:e0a1881f9e0564bebdeac98c75e59f07acdde6ed3a5396e0e613eaad31194866" @@ -148,23 +140,27 @@ version = "v1.6.5" [[projects]] - digest = "1:59f10c1537d2199d9115d946927fe31165959a95190849c82ff11e05803528b0" + digest = "1:b75b3deb2bce8bc079e16bb2aecfe01eb80098f5650f9e93e5643ca8b7b73737" name = "gopkg.in/yaml.v2" packages = ["."] pruneopts = "UT" - revision = "f221b8435cfb71e54062f6c6e99e9ade30b124d5" - version = "v2.2.4" + revision = "1f64d6156d11335c3f22d9330b0ad14fc1e789ce" + version = "v2.2.7" [solve-meta] analyzer-name = "dep" analyzer-version = 1 input-imports = [ - "github.com/inlets/inlets-operator/pkg/provision", + "github.com/digitalocean/godo", "github.com/morikuni/aec", + "github.com/packethost/packngo", "github.com/pkg/errors", + "github.com/scaleway/scaleway-sdk-go/api/instance/v1", + "github.com/scaleway/scaleway-sdk-go/scw", "github.com/sethvargo/go-password/password", "github.com/spf13/cobra", "github.com/spf13/pflag", + "golang.org/x/oauth2", ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index d56ac571..8c0689e7 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,15 +1,66 @@ -[prune] - go-tests = true - unused-packages = true +# Gopkg.toml example +# +# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html +# for detailed Gopkg.toml documentation. +# +# required = ["github.com/user/thing/cmd/thing"] +# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] +# +# [[constraint]] +# name = "github.com/user/project" +# version = "1.0.0" +# +# [[constraint]] +# name = "github.com/user/project2" +# branch = "dev" +# source = "github.com/myfork/project2" +# +# [[override]] +# name = "github.com/x/y" +# version = "2.4.0" +# +# [prune] +# non-go = false +# go-tests = true +# unused-packages = true + + +[[constraint]] + name = "github.com/digitalocean/godo" + version = "1.27.0" [[constraint]] name = "github.com/morikuni/aec" version = "1.0.0" +[[constraint]] + name = "github.com/packethost/packngo" + version = "0.2.0" + +[[constraint]] + name = "github.com/pkg/errors" + version = "0.8.1" + +[[constraint]] + name = "github.com/scaleway/scaleway-sdk-go" + version = "1.0.0-beta.4" + +[[constraint]] + name = "github.com/sethvargo/go-password" + version = "0.1.3" + [[constraint]] name = "github.com/spf13/cobra" version = "0.0.5" [[constraint]] - name = "github.com/inlets/inlets-operator" - version = "0.4.3" + name = "github.com/spf13/pflag" + version = "1.0.5" + +[[constraint]] + branch = "master" + name = "golang.org/x/oauth2" + +[prune] + go-tests = true + unused-packages = true diff --git a/cmd/create.go b/cmd/create.go index 77357b4e..54e899b5 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -9,9 +9,9 @@ import ( "strings" "time" - "github.com/inlets/inletsctl/pkg" + names "github.com/inlets/inletsctl/pkg/names" + provision "github.com/inlets/inletsctl/pkg/provision" - provision "github.com/inlets/inlets-operator/pkg/provision" "github.com/pkg/errors" password "github.com/sethvargo/go-password/password" "github.com/spf13/cobra" @@ -121,7 +121,7 @@ func runCreate(cmd *cobra.Command, _ []string) error { remoteTCP, _ := cmd.Flags().GetString("remote-tcp") - name := strings.Replace(pkg.GetRandomName(10), "_", "-", -1) + name := strings.Replace(names.GetRandomName(10), "_", "-", -1) inletsControlPort := 8080 @@ -198,7 +198,7 @@ func getProvisioner(provider, accessToken, secretKey, organisationID, region str } else if provider == "packet" { return provision.NewPacketProvisioner(accessToken) } else if provider == "civo" { - return pkg.NewCivoProvisioner(accessToken) + return provision.NewCivoProvisioner(accessToken) } else if provider == "scaleway" { return provision.NewScalewayProvisioner(accessToken, secretKey, organisationID, region) } diff --git a/cmd/inletsctl.go b/cmd/inletsctl.go index 00a5cd61..245d6bcb 100644 --- a/cmd/inletsctl.go +++ b/cmd/inletsctl.go @@ -12,10 +12,14 @@ import ( ) var ( - Version string + // Version as per git repo + Version string + + // GitCommit as per git repo GitCommit string ) +// WelcomeMessage to introduce inletsctl const WelcomeMessage = "Welcome to inletsctl! Find out more at https://github.com/inlets/inletsctl" func init() { @@ -29,7 +33,10 @@ var inletsCmd = &cobra.Command{ Long: ` inletsctl can create exit nodes for you on your preferred cloud provider so that you can run a single command and then connect with your inlets -client.`, +client. + +See also: inlets-operator for Kubernetes and inlets-pro for TCP tunnelling. +`, Run: runInlets, } diff --git a/pkg/names.go b/pkg/names/names.go similarity index 99% rename from pkg/names.go rename to pkg/names/names.go index 88a570c0..ac431d86 100644 --- a/pkg/names.go +++ b/pkg/names/names.go @@ -1,6 +1,6 @@ // Copyright (c) Docker Author(s) 2019. All rights reserved. -package pkg +package names import ( "fmt" diff --git a/pkg/civo.go b/pkg/provision/civo.go similarity index 87% rename from pkg/civo.go rename to pkg/provision/civo.go index c9047c0b..af4c8c27 100644 --- a/pkg/civo.go +++ b/pkg/provision/civo.go @@ -1,4 +1,7 @@ -package pkg +// Copyright (c) Inlets Author(s) 2019. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +package provision import ( "encoding/json" @@ -10,8 +13,6 @@ import ( "strings" "time" - - "github.com/inlets/inlets-operator/pkg/provision" ) // CivoProvisioner creates instances on civo.com @@ -27,8 +28,8 @@ func NewCivoProvisioner(accessKey string) (*CivoProvisioner, error) { }, nil } -func (p *CivoProvisioner) Status(id string) (*provision.ProvisionedHost, error) { - host := &provision.ProvisionedHost{} +func (p *CivoProvisioner) Status(id string) (*ProvisionedHost, error) { + host := &ProvisionedHost{} apiURL := fmt.Sprint("https://api.civo.com/v2/instances/", id) @@ -61,7 +62,7 @@ func (p *CivoProvisioner) Status(id string) (*provision.ProvisionedHost, error) return host, unmarshalErr } - return &provision.ProvisionedHost{ + return &ProvisionedHost{ ID: instance.ID, IP: instance.PublicIP, Status: strings.ToLower(instance.Status), @@ -103,7 +104,7 @@ func (p *CivoProvisioner) Delete(id string) error { return nil } -func (p *CivoProvisioner) Provision(host provision.BasicHost) (*provision.ProvisionedHost, error) { +func (p *CivoProvisioner) Provision(host BasicHost) (*ProvisionedHost, error) { log.Printf("Provisioning host with Civo\n") @@ -117,12 +118,12 @@ func (p *CivoProvisioner) Provision(host provision.BasicHost) (*provision.Provis return nil, err } - return &provision.ProvisionedHost{ + return &ProvisionedHost{ ID: res.ID, }, nil } -func provisionCivoInstance(host provision.BasicHost, key string) (CreatedInstance, error) { +func provisionCivoInstance(host BasicHost, key string) (CreatedInstance, error) { instance := CreatedInstance{} apiURL := "https://api.civo.com/v2/instances" diff --git a/vendor/github.com/inlets/inlets-operator/pkg/provision/digitalocean.go b/pkg/provision/digitalocean.go similarity index 100% rename from vendor/github.com/inlets/inlets-operator/pkg/provision/digitalocean.go rename to pkg/provision/digitalocean.go diff --git a/vendor/github.com/inlets/inlets-operator/pkg/provision/packet.go b/pkg/provision/packet.go similarity index 100% rename from vendor/github.com/inlets/inlets-operator/pkg/provision/packet.go rename to pkg/provision/packet.go diff --git a/vendor/github.com/inlets/inlets-operator/pkg/provision/provision.go b/pkg/provision/provision.go similarity index 100% rename from vendor/github.com/inlets/inlets-operator/pkg/provision/provision.go rename to pkg/provision/provision.go diff --git a/vendor/github.com/inlets/inlets-operator/pkg/provision/scaleway.go b/pkg/provision/scaleway.go similarity index 100% rename from vendor/github.com/inlets/inlets-operator/pkg/provision/scaleway.go rename to pkg/provision/scaleway.go diff --git a/vendor/github.com/digitalocean/godo/CHANGELOG.md b/vendor/github.com/digitalocean/godo/CHANGELOG.md index e4150697..2f20fc36 100644 --- a/vendor/github.com/digitalocean/godo/CHANGELOG.md +++ b/vendor/github.com/digitalocean/godo/CHANGELOG.md @@ -1,5 +1,33 @@ # Change Log +## [v1.27.0] - 2019-11-18 + +- #278 add mysql user auth settings for database users - @gregmankes + +## [v1.26.0] - 2019-11-13 + +- #272 dbaas: get and set mysql sql mode - @mikejholly + +## [v1.25.0] - 2019-11-13 + +- #275 registry/docker-credentials: add support for the read/write parameter - @kamaln7 +- #273 implement the registry/docker-credentials endpoint - @kamaln7 +- #271 Add registry resource - @snormore + +## [v1.24.1] - 2019-11-04 + +- #264 Update isLast to check p.Next - @aqche + +## [v1.24.0] - 2019-10-30 + +- #267 Return []DatabaseFirewallRule in addition to raw response. - @andrewsomething + +## [v1.23.1] - 2019-10-30 + +- #265 add support for getting/setting firewall rules - @gregmankes +- #262 remove ResolveReference call - @mdanzinger +- #261 Update CONTRIBUTING.md - @mdanzinger + ## [v1.22.0] - 2019-09-24 - #259 Add Kubernetes GetCredentials method - @snormore diff --git a/vendor/github.com/digitalocean/godo/CONTRIBUTING.md b/vendor/github.com/digitalocean/godo/CONTRIBUTING.md index 89b096cf..43de4fad 100644 --- a/vendor/github.com/digitalocean/godo/CONTRIBUTING.md +++ b/vendor/github.com/digitalocean/godo/CONTRIBUTING.md @@ -18,7 +18,7 @@ go get -u github.com/stretchr/testify/assert If outside `$GOPATH`, just clone the repository: ```sh -git clone github.com/digitalocean/godo +git clone https://github.com/digitalocean/godo ``` ## Running tests diff --git a/vendor/github.com/digitalocean/godo/databases.go b/vendor/github.com/digitalocean/godo/databases.go index 20c9cff5..254395eb 100644 --- a/vendor/github.com/digitalocean/godo/databases.go +++ b/vendor/github.com/digitalocean/godo/databases.go @@ -4,25 +4,68 @@ import ( "context" "fmt" "net/http" + "strings" "time" ) const ( - databaseBasePath = "/v2/databases" - databaseSinglePath = databaseBasePath + "/%s" - databaseResizePath = databaseBasePath + "/%s/resize" - databaseMigratePath = databaseBasePath + "/%s/migrate" - databaseMaintenancePath = databaseBasePath + "/%s/maintenance" - databaseBackupsPath = databaseBasePath + "/%s/backups" - databaseUsersPath = databaseBasePath + "/%s/users" - databaseUserPath = databaseBasePath + "/%s/users/%s" - databaseDBPath = databaseBasePath + "/%s/dbs/%s" - databaseDBsPath = databaseBasePath + "/%s/dbs" - databasePoolPath = databaseBasePath + "/%s/pools/%s" - databasePoolsPath = databaseBasePath + "/%s/pools" - databaseReplicaPath = databaseBasePath + "/%s/replicas/%s" - databaseReplicasPath = databaseBasePath + "/%s/replicas" - evictionPolicyPath = databaseBasePath + "/%s/eviction_policy" + databaseBasePath = "/v2/databases" + databaseSinglePath = databaseBasePath + "/%s" + databaseResizePath = databaseBasePath + "/%s/resize" + databaseMigratePath = databaseBasePath + "/%s/migrate" + databaseMaintenancePath = databaseBasePath + "/%s/maintenance" + databaseBackupsPath = databaseBasePath + "/%s/backups" + databaseUsersPath = databaseBasePath + "/%s/users" + databaseUserPath = databaseBasePath + "/%s/users/%s" + databaseDBPath = databaseBasePath + "/%s/dbs/%s" + databaseDBsPath = databaseBasePath + "/%s/dbs" + databasePoolPath = databaseBasePath + "/%s/pools/%s" + databasePoolsPath = databaseBasePath + "/%s/pools" + databaseReplicaPath = databaseBasePath + "/%s/replicas/%s" + databaseReplicasPath = databaseBasePath + "/%s/replicas" + databaseEvictionPolicyPath = databaseBasePath + "/%s/eviction_policy" + databaseSQLModePath = databaseBasePath + "/%s/sql_mode" + databaseFirewallRulesPath = databaseBasePath + "/%s/firewall" +) + +// SQL Mode constants allow for MySQL-specific SQL flavor configuration. +const ( + SQLModeAllowInvalidDates = "ALLOW_INVALID_DATES" + SQLModeANSIQuotes = "ANSI_QUOTES" + SQLModeHighNotPrecedence = "HIGH_NOT_PRECEDENCE" + SQLModeIgnoreSpace = "IGNORE_SPACE" + SQLModeNoAuthCreateUser = "NO_AUTO_CREATE_USER" + SQLModeNoAutoValueOnZero = "NO_AUTO_VALUE_ON_ZERO" + SQLModeNoBackslashEscapes = "NO_BACKSLASH_ESCAPES" + SQLModeNoDirInCreate = "NO_DIR_IN_CREATE" + SQLModeNoEngineSubstitution = "NO_ENGINE_SUBSTITUTION" + SQLModeNoFieldOptions = "NO_FIELD_OPTIONS" + SQLModeNoKeyOptions = "NO_KEY_OPTIONS" + SQLModeNoTableOptions = "NO_TABLE_OPTIONS" + SQLModeNoUnsignedSubtraction = "NO_UNSIGNED_SUBTRACTION" + SQLModeNoZeroDate = "NO_ZERO_DATE" + SQLModeNoZeroInDate = "NO_ZERO_IN_DATE" + SQLModeOnlyFullGroupBy = "ONLY_FULL_GROUP_BY" + SQLModePadCharToFullLength = "PAD_CHAR_TO_FULL_LENGTH" + SQLModePipesAsConcat = "PIPES_AS_CONCAT" + SQLModeRealAsFloat = "REAL_AS_FLOAT" + SQLModeStrictAllTables = "STRICT_ALL_TABLES" + SQLModeStrictTransTables = "STRICT_TRANS_TABLES" + SQLModeANSI = "ANSI" + SQLModeDB2 = "DB2" + SQLModeMaxDB = "MAXDB" + SQLModeMSSQL = "MSSQL" + SQLModeMYSQL323 = "MYSQL323" + SQLModeMYSQL40 = "MYSQL40" + SQLModeOracle = "ORACLE" + SQLModePostgreSQL = "POSTGRESQL" + SQLModeTraditional = "TRADITIONAL" +) + +// SQL Auth constants allow for MySQL-specific user auth plugins +const ( + SQLAuthPluginNative = "mysql_native_password" + SQLAuthPluginCachingSHA2 = "caching_sha2_password" ) // DatabasesService is an interface for interfacing with the databases endpoints @@ -55,6 +98,10 @@ type DatabasesService interface { DeleteReplica(context.Context, string, string) (*Response, error) GetEvictionPolicy(context.Context, string) (string, *Response, error) SetEvictionPolicy(context.Context, string, string) (*Response, error) + GetSQLMode(context.Context, string) (string, *Response, error) + SetSQLMode(context.Context, string, ...string) (*Response, error) + GetFirewallRules(context.Context, string) ([]DatabaseFirewallRule, *Response, error) + UpdateFirewallRules(context.Context, string, *DatabaseUpdateFirewallRulesRequest) (*Response, error) } // DatabasesServiceOp handles communication with the Databases related methods @@ -102,9 +149,15 @@ type DatabaseConnection struct { // DatabaseUser represents a user in the database type DatabaseUser struct { - Name string `json:"name,omitempty"` - Role string `json:"role,omitempty"` - Password string `json:"password,omitempty"` + Name string `json:"name,omitempty"` + Role string `json:"role,omitempty"` + Password string `json:"password,omitempty"` + MySQLSettings *DatabaseMySQLUserSettings `json:"mysql_settings,omitempty"` +} + +// DatabaseMySQLUserSettings contains MySQL-specific user settings +type DatabaseMySQLUserSettings struct { + AuthPlugin string `json:"auth_plugin"` } // DatabaseMaintenanceWindow represents the maintenance_window of a database @@ -194,7 +247,8 @@ type DatabaseCreatePoolRequest struct { // DatabaseCreateUserRequest is used to create a new database user type DatabaseCreateUserRequest struct { - Name string `json:"name"` + Name string `json:"name"` + MySQLSettings *DatabaseMySQLUserSettings `json:"mysql_settings,omitempty"` } // DatabaseCreateDBRequest is used to create a new engine-specific database within the cluster @@ -211,6 +265,20 @@ type DatabaseCreateReplicaRequest struct { Tags []string `json:"tags,omitempty"` } +// DatabaseUpdateFirewallRulesRequest is used to set the firewall rules for a database +type DatabaseUpdateFirewallRulesRequest struct { + Rules []*DatabaseFirewallRule `json:"rules"` +} + +// DatabaseFirewallRule is a rule describing an inbound source to a database +type DatabaseFirewallRule struct { + UUID string `json:"uuid"` + ClusterUUID string `json:"cluster_uuid"` + Type string `json:"type"` + Value string `json:"value"` + CreatedAt time.Time `json:"created_at"` +} + type databaseUserRoot struct { User *DatabaseUser `json:"user"` } @@ -259,6 +327,15 @@ type evictionPolicyRoot struct { EvictionPolicy string `json:"eviction_policy"` } +type sqlModeRoot struct { + SQLMode string `json:"sql_mode"` +} + +type databaseFirewallRuleRoot struct { + Rules []DatabaseFirewallRule `json:"rules"` +} + +// URN returns a URN identifier for the database func (d Database) URN() string { return ToURN("dbaas", d.ID) } @@ -642,7 +719,7 @@ func (svc *DatabasesServiceOp) DeleteReplica(ctx context.Context, databaseID, na // GetEvictionPolicy loads the eviction policy for a given Redis cluster. func (svc *DatabasesServiceOp) GetEvictionPolicy(ctx context.Context, databaseID string) (string, *Response, error) { - path := fmt.Sprintf(evictionPolicyPath, databaseID) + path := fmt.Sprintf(databaseEvictionPolicyPath, databaseID) req, err := svc.client.NewRequest(ctx, http.MethodGet, path, nil) if err != nil { return "", nil, err @@ -657,7 +734,7 @@ func (svc *DatabasesServiceOp) GetEvictionPolicy(ctx context.Context, databaseID // SetEvictionPolicy updates the eviction policy for a given Redis cluster. func (svc *DatabasesServiceOp) SetEvictionPolicy(ctx context.Context, databaseID, policy string) (*Response, error) { - path := fmt.Sprintf(evictionPolicyPath, databaseID) + path := fmt.Sprintf(databaseEvictionPolicyPath, databaseID) root := &evictionPolicyRoot{EvictionPolicy: policy} req, err := svc.client.NewRequest(ctx, http.MethodPut, path, root) if err != nil { @@ -669,3 +746,60 @@ func (svc *DatabasesServiceOp) SetEvictionPolicy(ctx context.Context, databaseID } return resp, nil } + +// GetSQLMode loads the SQL Mode settings for a given MySQL cluster. +func (svc *DatabasesServiceOp) GetSQLMode(ctx context.Context, databaseID string) (string, *Response, error) { + path := fmt.Sprintf(databaseSQLModePath, databaseID) + req, err := svc.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return "", nil, err + } + root := &sqlModeRoot{} + resp, err := svc.client.Do(ctx, req, root) + if err != nil { + return "", resp, err + } + return root.SQLMode, resp, nil +} + +// SetSQLMode updates the SQL Mode settings for a given MySQL cluster. +func (svc *DatabasesServiceOp) SetSQLMode(ctx context.Context, databaseID string, sqlModes ...string) (*Response, error) { + path := fmt.Sprintf(databaseSQLModePath, databaseID) + root := &sqlModeRoot{SQLMode: strings.Join(sqlModes, ",")} + req, err := svc.client.NewRequest(ctx, http.MethodPut, path, root) + if err != nil { + return nil, err + } + resp, err := svc.client.Do(ctx, req, nil) + if err != nil { + return resp, err + } + return resp, nil +} + +// GetFirewallRules loads the inbound sources for a given cluster. +func (svc *DatabasesServiceOp) GetFirewallRules(ctx context.Context, databaseID string) ([]DatabaseFirewallRule, *Response, error) { + path := fmt.Sprintf(databaseFirewallRulesPath, databaseID) + root := new(databaseFirewallRuleRoot) + req, err := svc.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + + resp, err := svc.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + + return root.Rules, resp, nil +} + +// UpdateFirewallRules sets the inbound sources for a given cluster. +func (svc *DatabasesServiceOp) UpdateFirewallRules(ctx context.Context, databaseID string, firewallRulesReq *DatabaseUpdateFirewallRulesRequest) (*Response, error) { + path := fmt.Sprintf(databaseFirewallRulesPath, databaseID) + req, err := svc.client.NewRequest(ctx, http.MethodPut, path, firewallRulesReq) + if err != nil { + return nil, err + } + return svc.client.Do(ctx, req, nil) +} diff --git a/vendor/github.com/digitalocean/godo/godo.go b/vendor/github.com/digitalocean/godo/godo.go index cdeb1749..c5296555 100644 --- a/vendor/github.com/digitalocean/godo/godo.go +++ b/vendor/github.com/digitalocean/godo/godo.go @@ -17,7 +17,7 @@ import ( ) const ( - libraryVersion = "1.22.0" + libraryVersion = "1.27.0" defaultBaseURL = "https://api.digitalocean.com/" userAgent = "godo/" + libraryVersion mediaType = "application/json" @@ -65,6 +65,7 @@ type Client struct { Firewalls FirewallsService Projects ProjectsService Kubernetes KubernetesService + Registry RegistryService Databases DatabasesService VPCs VPCsService @@ -181,6 +182,7 @@ func NewClient(httpClient *http.Client) *Client { c.StorageActions = &StorageActionsServiceOp{client: c} c.Tags = &TagsServiceOp{client: c} c.Kubernetes = &KubernetesServiceOp{client: c} + c.Registry = &RegistryServiceOp{client: c} c.Databases = &DatabasesServiceOp{client: c} c.VPCs = &VPCsServiceOp{client: c} @@ -227,13 +229,11 @@ func SetUserAgent(ua string) ClientOpt { // BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the // value pointed to by body is JSON encoded and included in as the request body. func (c *Client) NewRequest(ctx context.Context, method, urlStr string, body interface{}) (*http.Request, error) { - rel, err := url.Parse(urlStr) + u, err := c.BaseURL.Parse(urlStr) if err != nil { return nil, err } - u := c.BaseURL.ResolveReference(rel) - buf := new(bytes.Buffer) if body != nil { err = json.NewEncoder(buf).Encode(body) diff --git a/vendor/github.com/digitalocean/godo/links.go b/vendor/github.com/digitalocean/godo/links.go index 20984417..6f350bf9 100644 --- a/vendor/github.com/digitalocean/godo/links.go +++ b/vendor/github.com/digitalocean/godo/links.go @@ -59,7 +59,7 @@ func (l *Links) IsLastPage() bool { } func (p *Pages) isLast() bool { - return p.Last == "" + return p.Next == "" } func pageForURL(urlText string) (int, error) { diff --git a/vendor/github.com/digitalocean/godo/registry.go b/vendor/github.com/digitalocean/godo/registry.go new file mode 100644 index 00000000..73719f16 --- /dev/null +++ b/vendor/github.com/digitalocean/godo/registry.go @@ -0,0 +1,119 @@ +package godo + +import ( + "bytes" + "context" + "fmt" + "net/http" +) + +const ( + registryPath = "/v2/registry" +) + +// RegistryService is an interface for interfacing with the Registry endpoints +// of the DigitalOcean API. +// See: https://developers.digitalocean.com/documentation/v2#registry +type RegistryService interface { + Create(context.Context, *RegistryCreateRequest) (*Registry, *Response, error) + Get(context.Context) (*Registry, *Response, error) + Delete(context.Context) (*Response, error) + DockerCredentials(context.Context, *RegistryDockerCredentialsRequest) (*DockerCredentials, *Response, error) +} + +var _ RegistryService = &RegistryServiceOp{} + +// RegistryServiceOp handles communication with Registry methods of the DigitalOcean API. +type RegistryServiceOp struct { + client *Client +} + +// RegistryCreateRequest represents a request to create a registry. +type RegistryCreateRequest struct { + Name string `json:"name,omitempty"` +} + +// RegistryDockerCredentialsRequest represents a request to retrieve docker +// credentials for a registry. +type RegistryDockerCredentialsRequest struct { + ReadWrite bool `json:"read_write"` +} + +// Registry represents a registry. +type Registry struct { + Name string `json:"name,omitempty"` +} + +type registryRoot struct { + Registry *Registry `json:"registry,omitempty"` +} + +// Get retrieves the details of a Registry. +func (svc *RegistryServiceOp) Get(ctx context.Context) (*Registry, *Response, error) { + req, err := svc.client.NewRequest(ctx, http.MethodGet, registryPath, nil) + if err != nil { + return nil, nil, err + } + root := new(registryRoot) + resp, err := svc.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + return root.Registry, resp, nil +} + +// Create creates a registry. +func (svc *RegistryServiceOp) Create(ctx context.Context, create *RegistryCreateRequest) (*Registry, *Response, error) { + req, err := svc.client.NewRequest(ctx, http.MethodPost, registryPath, create) + if err != nil { + return nil, nil, err + } + root := new(registryRoot) + resp, err := svc.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + return root.Registry, resp, nil +} + +// Delete deletes a registry. There is no way to recover a registry once it has +// been destroyed. +func (svc *RegistryServiceOp) Delete(ctx context.Context) (*Response, error) { + req, err := svc.client.NewRequest(ctx, http.MethodDelete, registryPath, nil) + if err != nil { + return nil, err + } + resp, err := svc.client.Do(ctx, req, nil) + if err != nil { + return resp, err + } + return resp, nil +} + +// DockerCredentials is the content of a Docker config file +// that is used by the docker CLI +// See: https://docs.docker.com/engine/reference/commandline/cli/#configjson-properties +type DockerCredentials struct { + DockerConfigJSON []byte +} + +// DockerCredentials retrieves a Docker config file containing the registry's credentials. +func (svc *RegistryServiceOp) DockerCredentials(ctx context.Context, request *RegistryDockerCredentialsRequest) (*DockerCredentials, *Response, error) { + path := fmt.Sprintf("%s/%s?read_write=%t", registryPath, "docker-credentials", request.ReadWrite) + + req, err := svc.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + + var buf bytes.Buffer + resp, err := svc.client.Do(ctx, req, &buf) + if err != nil { + return nil, resp, err + } + + dc := &DockerCredentials{ + DockerConfigJSON: buf.Bytes(), + } + return dc, resp, nil +} diff --git a/vendor/github.com/inlets/inlets-operator/LICENSE b/vendor/github.com/inlets/inlets-operator/LICENSE deleted file mode 100644 index 96456b40..00000000 --- a/vendor/github.com/inlets/inlets-operator/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019 Alex Ellis - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/vendor/github.com/packethost/packngo/go.mod b/vendor/github.com/packethost/packngo/go.mod index 0c6af6fa..10ef6856 100644 --- a/vendor/github.com/packethost/packngo/go.mod +++ b/vendor/github.com/packethost/packngo/go.mod @@ -5,5 +5,3 @@ require ( golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67 golang.org/x/sys v0.0.0-20190209173611-3b5209105503 // indirect ) - -go 1.13 diff --git a/vendor/gopkg.in/yaml.v2/.travis.yml b/vendor/gopkg.in/yaml.v2/.travis.yml index 9f556934..055480b9 100644 --- a/vendor/gopkg.in/yaml.v2/.travis.yml +++ b/vendor/gopkg.in/yaml.v2/.travis.yml @@ -1,12 +1,16 @@ language: go go: - - 1.4 - - 1.5 - - 1.6 - - 1.7 - - 1.8 - - 1.9 - - tip + - "1.4.x" + - "1.5.x" + - "1.6.x" + - "1.7.x" + - "1.8.x" + - "1.9.x" + - "1.10.x" + - "1.11.x" + - "1.12.x" + - "1.13.x" + - "tip" go_import_path: gopkg.in/yaml.v2 diff --git a/vendor/gopkg.in/yaml.v2/decode.go b/vendor/gopkg.in/yaml.v2/decode.go index 53108765..129bc2a9 100644 --- a/vendor/gopkg.in/yaml.v2/decode.go +++ b/vendor/gopkg.in/yaml.v2/decode.go @@ -319,10 +319,14 @@ func (d *decoder) prepare(n *node, out reflect.Value) (newout reflect.Value, unm } const ( - // 400,000 decode operations is ~500kb of dense object declarations, or ~5kb of dense object declarations with 10000% alias expansion + // 400,000 decode operations is ~500kb of dense object declarations, or + // ~5kb of dense object declarations with 10000% alias expansion alias_ratio_range_low = 400000 - // 4,000,000 decode operations is ~5MB of dense object declarations, or ~4.5MB of dense object declarations with 10% alias expansion + + // 4,000,000 decode operations is ~5MB of dense object declarations, or + // ~4.5MB of dense object declarations with 10% alias expansion alias_ratio_range_high = 4000000 + // alias_ratio_range is the range over which we scale allowed alias ratios alias_ratio_range = float64(alias_ratio_range_high - alias_ratio_range_low) ) @@ -784,8 +788,7 @@ func (d *decoder) merge(n *node, out reflect.Value) { case mappingNode: d.unmarshal(n, out) case aliasNode: - an, ok := d.doc.anchors[n.value] - if ok && an.kind != mappingNode { + if n.alias != nil && n.alias.kind != mappingNode { failWantMap() } d.unmarshal(n, out) @@ -794,8 +797,7 @@ func (d *decoder) merge(n *node, out reflect.Value) { for i := len(n.children) - 1; i >= 0; i-- { ni := n.children[i] if ni.kind == aliasNode { - an, ok := d.doc.anchors[ni.value] - if ok && an.kind != mappingNode { + if ni.alias != nil && ni.alias.kind != mappingNode { failWantMap() } } else if ni.kind != mappingNode { diff --git a/vendor/gopkg.in/yaml.v2/scannerc.go b/vendor/gopkg.in/yaml.v2/scannerc.go index 570b8ecd..b33bdbae 100644 --- a/vendor/gopkg.in/yaml.v2/scannerc.go +++ b/vendor/gopkg.in/yaml.v2/scannerc.go @@ -634,13 +634,14 @@ func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool { need_more_tokens = true } else { // Check if any potential simple key may occupy the head position. - if !yaml_parser_stale_simple_keys(parser) { - return false - } - - for i := range parser.simple_keys { + for i := len(parser.simple_keys) - 1; i >= 0; i-- { simple_key := &parser.simple_keys[i] - if simple_key.possible && simple_key.token_number == parser.tokens_parsed { + if simple_key.token_number < parser.tokens_parsed { + break + } + if valid, ok := yaml_simple_key_is_valid(parser, simple_key); !ok { + return false + } else if valid && simple_key.token_number == parser.tokens_parsed { need_more_tokens = true break } @@ -678,11 +679,6 @@ func yaml_parser_fetch_next_token(parser *yaml_parser_t) bool { return false } - // Remove obsolete potential simple keys. - if !yaml_parser_stale_simple_keys(parser) { - return false - } - // Check the indentation level against the current column. if !yaml_parser_unroll_indent(parser, parser.mark.column) { return false @@ -837,29 +833,30 @@ func yaml_parser_fetch_next_token(parser *yaml_parser_t) bool { "found character that cannot start any token") } -// Check the list of potential simple keys and remove the positions that -// cannot contain simple keys anymore. -func yaml_parser_stale_simple_keys(parser *yaml_parser_t) bool { - // Check for a potential simple key for each flow level. - for i := range parser.simple_keys { - simple_key := &parser.simple_keys[i] - - // The specification requires that a simple key - // - // - is limited to a single line, - // - is shorter than 1024 characters. - if simple_key.possible && (simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index) { - - // Check if the potential simple key to be removed is required. - if simple_key.required { - return yaml_parser_set_scanner_error(parser, - "while scanning a simple key", simple_key.mark, - "could not find expected ':'") - } - simple_key.possible = false +func yaml_simple_key_is_valid(parser *yaml_parser_t, simple_key *yaml_simple_key_t) (valid, ok bool) { + if !simple_key.possible { + return false, true + } + + // The 1.2 specification says: + // + // "If the ? indicator is omitted, parsing needs to see past the + // implicit key to recognize it as such. To limit the amount of + // lookahead required, the “:” indicator must appear at most 1024 + // Unicode characters beyond the start of the key. In addition, the key + // is restricted to a single line." + // + if simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index { + // Check if the potential simple key to be removed is required. + if simple_key.required { + return false, yaml_parser_set_scanner_error(parser, + "while scanning a simple key", simple_key.mark, + "could not find expected ':'") } + simple_key.possible = false + return false, true } - return true + return true, true } // Check if a simple key may start at the current position and add it if @@ -879,8 +876,8 @@ func yaml_parser_save_simple_key(parser *yaml_parser_t) bool { possible: true, required: required, token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), + mark: parser.mark, } - simple_key.mark = parser.mark if !yaml_parser_remove_simple_key(parser) { return false @@ -912,7 +909,12 @@ const max_flow_level = 10000 // Increase the flow level and resize the simple key list if needed. func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool { // Reset the simple key on the next level. - parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) + parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{ + possible: false, + required: false, + token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), + mark: parser.mark, + }) // Increase the flow level. parser.flow_level++ @@ -1286,7 +1288,11 @@ func yaml_parser_fetch_value(parser *yaml_parser_t) bool { simple_key := &parser.simple_keys[len(parser.simple_keys)-1] // Have we found a simple key? - if simple_key.possible { + if valid, ok := yaml_simple_key_is_valid(parser, simple_key); !ok { + return false + + } else if valid { + // Create the KEY token and insert it into the queue. token := yaml_token_t{ typ: yaml_KEY_TOKEN, diff --git a/vendor/gopkg.in/yaml.v2/yaml.go b/vendor/gopkg.in/yaml.v2/yaml.go index de85aa4c..89650e29 100644 --- a/vendor/gopkg.in/yaml.v2/yaml.go +++ b/vendor/gopkg.in/yaml.v2/yaml.go @@ -89,7 +89,7 @@ func UnmarshalStrict(in []byte, out interface{}) (err error) { return unmarshal(in, out, true) } -// A Decorder reads and decodes YAML values from an input stream. +// A Decoder reads and decodes YAML values from an input stream. type Decoder struct { strict bool parser *parser