diff --git a/vendor/cloud.google.com/go/LICENSE b/vendor/cloud.google.com/go/LICENSE index d64569567..a4c5efd82 100644 --- a/vendor/cloud.google.com/go/LICENSE +++ b/vendor/cloud.google.com/go/LICENSE @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright 2014 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/vendor/github.com/aws/aws-sdk-go/NOTICE.txt b/vendor/github.com/aws/aws-sdk-go/NOTICE.txt index 899129ecc..5f14d1162 100644 --- a/vendor/github.com/aws/aws-sdk-go/NOTICE.txt +++ b/vendor/github.com/aws/aws-sdk-go/NOTICE.txt @@ -1,3 +1,3 @@ AWS SDK for Go -Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. +Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. Copyright 2014-2015 Stripe, Inc. diff --git a/vendor/github.com/digitalocean/godo/LICENSE.txt b/vendor/github.com/digitalocean/godo/LICENSE.txt index 47f978eac..43c5d2eee 100644 --- a/vendor/github.com/digitalocean/godo/LICENSE.txt +++ b/vendor/github.com/digitalocean/godo/LICENSE.txt @@ -52,3 +52,4 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/vendor/github.com/gophercloud/gophercloud/LICENSE b/vendor/github.com/gophercloud/gophercloud/LICENSE index 5e86b007c..fbbbc9e4c 100644 --- a/vendor/github.com/gophercloud/gophercloud/LICENSE +++ b/vendor/github.com/gophercloud/gophercloud/LICENSE @@ -9,8 +9,10 @@ License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. +specific language governing permissions and limitations under the License. +------ + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ diff --git a/vendor/github.com/hashicorp/go-discover/README.md b/vendor/github.com/hashicorp/go-discover/README.md index 7e61ba977..ae87400fe 100644 --- a/vendor/github.com/hashicorp/go-discover/README.md +++ b/vendor/github.com/hashicorp/go-discover/README.md @@ -33,9 +33,15 @@ function. * vSphere [Config options](https://github.com/hashicorp/go-discover/blob/master/provider/vsphere/vsphere_discover.go#L148-L155) * Packet [Config options](https://github.com/hashicorp/go-discover/blob/master/provider/packet/packet_discover.go#L25-L35) +The following providers are implemented in the go-discover/provider subdirectory +but aren't automatically registered. If you want to support these providers, +register them manually: + + * Kubernetes [Config options](https://github.com/hashicorp/go-discover/blob/master/provider/k8s/k8s_discover.go#L32-L51) + HashiCorp maintains acceptance tests that regularly allocate and run tests with real resources to verify the behavior of several of these providers. Those -currently are: Amazon AWS, Microsoft Azure, Google Cloud, DigitalOcean, Triton, Scaleway and AliBaba Cloud. +currently are: Amazon AWS, Microsoft Azure, Google Cloud, DigitalOcean, Triton, Scaleway, AliBaba Cloud, vSphere, and Packet.net. ### Config Example @@ -70,8 +76,11 @@ provider=triton account=testaccount url=https://us-sw-1.api.joyentcloud.com key_ # vSphere provider=vsphere category_name=consul-role tag_name=consul-server host=... user=... password=... insecure_ssl=[true|false] -# Packet +# Packet provider=packet auth_token=token project=uuid url=... address_type=... + +# Kubernetes +provider=k8s label_selector="app = consul-server" ``` ## Command Line Tool Usage @@ -118,6 +127,25 @@ cfg := "provider=aws region=eu-west-1 ..." addrs, err := d.Addrs(cfg, l) ``` +You can also add support for providers that aren't registered by default: + +```go +// Imports at top of file +import "github.com/hashicorp/go-discover/provider/k8s" + +// support discovery for all supported providers +d := discover.Discover{} + +// support discovery for AWS and GCE only +d := discover.Discover{ + Providers : map[string]discover.Provider{ + "k8s": &k8s.Provider{}, + } +} + +// ... +``` + For complete API documentation, see [GoDoc](https://godoc.org/github.com/hashicorp/go-discover). The configuration for the supported providers is documented in the diff --git a/vendor/github.com/hashicorp/go-discover/go.mod b/vendor/github.com/hashicorp/go-discover/go.mod new file mode 100644 index 000000000..3cb6abe26 --- /dev/null +++ b/vendor/github.com/hashicorp/go-discover/go.mod @@ -0,0 +1,72 @@ +module github.com/hashicorp/go-discover + +require ( + cloud.google.com/go v0.26.0 // indirect + github.com/Azure/azure-sdk-for-go v16.0.0+incompatible + github.com/Azure/go-autorest v10.7.0+incompatible + github.com/Sirupsen/logrus v1.0.6 // indirect + github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af // indirect + github.com/aws/aws-sdk-go v1.15.24 + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/denverdino/aliyungo v0.0.0-20170926055100-d3308649c661 + github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect + github.com/digitalocean/godo v1.1.1 + github.com/fsnotify/fsnotify v1.4.7 // indirect + github.com/ghodss/yaml v1.0.0 // indirect + github.com/gogo/protobuf v1.1.1 // indirect + github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect + github.com/golang/protobuf v1.2.0 // indirect + github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect + github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 // indirect + github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect + github.com/googleapis/gnostic v0.2.0 // indirect + github.com/gophercloud/gophercloud v0.0.0-20180828235145-f29afc2cceca + github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c // indirect + github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect + github.com/hashicorp/go-multierror v1.0.0 + github.com/hpcloud/tail v1.0.0 // indirect + github.com/imdario/mergo v0.3.6 // indirect + github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da // indirect + github.com/joyent/triton-go v0.0.0-20180628001255-830d2b111e62 + github.com/json-iterator/go v1.1.5 // indirect + github.com/jtolds/gls v4.2.1+incompatible // indirect + github.com/mitchellh/go-homedir v1.0.0 + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2 + github.com/onsi/ginkgo v1.6.0 // indirect + github.com/onsi/gomega v1.4.1 // indirect + github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c + github.com/peterbourgon/diskv v2.0.1+incompatible // indirect + github.com/pkg/errors v0.8.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03 // indirect + github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect + github.com/sirupsen/logrus v1.0.6 // indirect + github.com/smartystreets/assertions v0.0.0-20180820201707-7c9eb446e3cf // indirect + github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a // indirect + github.com/softlayer/softlayer-go v0.0.0-20180806151055-260589d94c7d + github.com/spf13/pflag v1.0.2 // indirect + github.com/stretchr/testify v1.2.2 // indirect + github.com/tent/http-link-go v0.0.0-20130702225549-ac974c61c2f9 // indirect + github.com/vmware/govmomi v0.18.0 + github.com/vmware/vic v1.4.1 + golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac // indirect + golang.org/x/net v0.0.0-20180826012351-8a410e7b638d // indirect + golang.org/x/oauth2 v0.0.0-20170807180024-9a379c6b3e95 + golang.org/x/sync v0.0.0-20170927054112-8e0aa688b654 // indirect + golang.org/x/sys v0.0.0-20180828065106-d99a578cf41b // indirect + golang.org/x/text v0.3.0 // indirect + golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 // indirect + google.golang.org/api v0.0.0-20180829000535-087779f1d2c9 + google.golang.org/appengine v1.1.0 // indirect + gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect + gopkg.in/fsnotify.v1 v1.4.7 // indirect + gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect + gopkg.in/yaml.v2 v2.2.1 // indirect + k8s.io/api v0.0.0-20180806132203-61b11ee65332 + k8s.io/apimachinery v0.0.0-20180821005732-488889b0007f + k8s.io/client-go v8.0.0+incompatible +) diff --git a/vendor/github.com/hashicorp/go-discover/go.sum b/vendor/github.com/hashicorp/go-discover/go.sum new file mode 100644 index 000000000..e379ec629 --- /dev/null +++ b/vendor/github.com/hashicorp/go-discover/go.sum @@ -0,0 +1,144 @@ +cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ= +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/Azure/azure-sdk-for-go v16.0.0+incompatible h1:gr1qKY/Ll72VjFTZmaBwRK1yQHAxCnV25ekOKroc9ws= +github.com/Azure/azure-sdk-for-go v16.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/go-autorest v10.7.0+incompatible h1:dB+dKSLGdJLEhU/FoZTSNSPMZuE5H4M5p5zgSct7qwM= +github.com/Azure/go-autorest v10.7.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= +github.com/Sirupsen/logrus v1.0.6 h1:HCAGQRk48dRVPA5Y+Yh0qdCSTzPOyU1tBJ7Q9YzotII= +github.com/Sirupsen/logrus v1.0.6/go.mod h1:rmk17hk6i8ZSAJkSDa7nOxamrG+SP4P0mm+DAvExv4U= +github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af h1:DBNMBMuMiWYu0b+8KMJuWmfCkcxl09JwdlqwDZZ6U14= +github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw= +github.com/aws/aws-sdk-go v1.15.24 h1:xLAdTA/ore6xdPAljzZRed7IGqQgC+nY+ERS5vaj4Ro= +github.com/aws/aws-sdk-go v1.15.24/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/denverdino/aliyungo v0.0.0-20170926055100-d3308649c661 h1:lrWnAyy/F72MbxIxFUzKmcMCdt9Oi8RzpAxzTNQHD7o= +github.com/denverdino/aliyungo v0.0.0-20170926055100-d3308649c661/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= +github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/digitalocean/godo v1.1.1 h1:v0A7yF3xmKLjjdJGIeBbINfMufcrrRhqZsxuVQMoT+U= +github.com/digitalocean/godo v1.1.1/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-ini/ini v1.25.4 h1:Mujh4R/dH6YL8bxuISne3xX2+qcQ9p0IxKAP6ExWoUo= +github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= +github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +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/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCydnIczKteheJEzHRToSGK3Bnlw= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 h1:zLTLjkaOFEFIOxY5BWLFLwh+cL8vOBW4XJ2aqLE/Tf0= +github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/googleapis/gnostic v0.2.0 h1:l6N3VoaVzTncYYW+9yOz2LJJammFZGBO13sqgEhpy9g= +github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/gophercloud/gophercloud v0.0.0-20180828235145-f29afc2cceca h1:wobTb8SE189AuxzEKClyYxiI4nUGWlpVtl13eLiFlOE= +github.com/gophercloud/gophercloud v0.0.0-20180828235145-f29afc2cceca/go.mod h1:3WdhXV3rUYy9p6AUW8d94kr+HS62Y4VL9mBnFxsD8q4= +github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c h1:16eHWuMGvCjSfgRJKqIzapE78onvvTbdi1rMkU00lZw= +github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= +github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= +github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da h1:FjHUJJ7oBW4G/9j1KzlHaXL09LyMVM9rupS39lncbXk= +github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4= +github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8 h1:12VvqtR6Aowv3l/EQUlocDHW2Cp4G9WJVH7uyH8QFJE= +github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/joyent/triton-go v0.0.0-20180628001255-830d2b111e62 h1:JHCT6xuyPUrbbgAPE/3dqlvUKzRHMNuTBKKUb6OeR/k= +github.com/joyent/triton-go v0.0.0-20180628001255-830d2b111e62/go.mod h1:U+RSyWxWd04xTqnuOQxnai7XGS2PrPY2cfGoDKtMHjA= +github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE= +github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE= +github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2 h1:BQ1HW7hr4IVovMwWg0E0PYcyW8CzqDcVmaew9cujU4s= +github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk= +github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.1 h1:PZSj/UFNaVp3KxrzHOcS7oyuWA7LoOY/77yCTEFu21U= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c h1:vwpFWvAO8DeIZfFeqASzZfsxuWPno9ncAebBEP0N3uE= +github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c/go.mod h1:otzZQXgoO96RTzDB/Hycg0qZcXZsWJGJRSXbmEIJ+4M= +github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= +github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= +github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03 h1:Wdi9nwnhFNAlseAOekn6B5G/+GMtks9UKbvRU/CMM/o= +github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03/go.mod h1:gRAiPF5C5Nd0eyyRdqIu9qTiFSoZzpTq727b5B8fkkU= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/sirupsen/logrus v1.0.6 h1:hcP1GmhGigz/O7h1WVUM5KklBp1JoNS9FggWKdj/j3s= +github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= +github.com/smartystreets/assertions v0.0.0-20180820201707-7c9eb446e3cf h1:6V1qxN6Usn4jy8unvggSJz/NC790tefw8Zdy6OZS5co= +github.com/smartystreets/assertions v0.0.0-20180820201707-7c9eb446e3cf/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a h1:JSvGDIbmil4Ui/dDdFBExb7/cmkNjyX5F97oglmvCDo= +github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= +github.com/softlayer/softlayer-go v0.0.0-20180806151055-260589d94c7d h1:bVQRCxQvfjNUeRqaY/uT0tFuvuFY0ulgnczuR684Xic= +github.com/softlayer/softlayer-go v0.0.0-20180806151055-260589d94c7d/go.mod h1:Cw4GTlQccdRGSEf6KiMju767x0NEHE0YIVPJSaXjlsw= +github.com/spf13/pflag v1.0.2 h1:Fy0orTDgHdbnzHcsOgfCN4LtHf0ec3wwtiwJqwvf3Gc= +github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/tent/http-link-go v0.0.0-20130702225549-ac974c61c2f9 h1:/Bsw4C+DEdqPjt8vAqaC9LAqpAQnaCQQqmolqq3S1T4= +github.com/tent/http-link-go v0.0.0-20130702225549-ac974c61c2f9/go.mod h1:RHkNRtSLfOK7qBTHaeSX1D6BNpI3qw7NTxsmNr4RvN8= +github.com/vmware/govmomi v0.18.0 h1:f7QxSmP7meCtoAmiKZogvVbLInT+CZx6Px6K5rYsJZo= +github.com/vmware/govmomi v0.18.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= +github.com/vmware/vic v1.4.1 h1:M8hwS40QBjVTWU46qSM+tCAUSMHTTyduCmtj9OPR49A= +github.com/vmware/vic v1.4.1/go.mod h1:AiTDrZuV13NkqRzseA5ZmF2QqLpTydaaGN75xgV6Ork= +golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac h1:7d7lG9fHOLdL6jZPtnV4LpI41SbohIJ1Atq7U991dMg= +golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d h1:g9qWBGx4puODJTMVyoPrpoxPFgVGd+z1DZwjfRu4d0I= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/oauth2 v0.0.0-20170807180024-9a379c6b3e95 h1:RS+wSrhdVci7CsPwJaMN8exaP3UTuQU0qB34R/E/JD0= +golang.org/x/oauth2 v0.0.0-20170807180024-9a379c6b3e95/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20170927054112-8e0aa688b654 h1:ogYMTsPtkSw1JROKERM/ualwPUvE2UOP2KfhwFO6aVE= +golang.org/x/sync v0.0.0-20170927054112-8e0aa688b654/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180828065106-d99a578cf41b h1:cmOZLU2i7CLArKNViO+ZCQ47wqYFyKEIpbGWp+b6Uoc= +golang.org/x/sys v0.0.0-20180828065106-d99a578cf41b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +google.golang.org/api v0.0.0-20180829000535-087779f1d2c9 h1:z1TeLUmxf9ws9KLICfmX+KGXTs+rjm+aGWzfsv7MZ9w= +google.golang.org/api v0.0.0-20180829000535-087779f1d2c9/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= +google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRSs= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo= +gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 h1:OAj3g0cR6Dx/R07QgQe8wkA9RNjB2u4i700xBkIT4e0= +gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/api v0.0.0-20180806132203-61b11ee65332 h1:+ED/2NBbOoeWB9QrGTHxZI7UnE7rnHPKKumOl0WXphs= +k8s.io/api v0.0.0-20180806132203-61b11ee65332/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= +k8s.io/apimachinery v0.0.0-20180821005732-488889b0007f h1:V0PkbgaYp5JqCmzLyRmssDtzim0NShXM8gYi4fcX230= +k8s.io/apimachinery v0.0.0-20180821005732-488889b0007f/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= +k8s.io/client-go v8.0.0+incompatible h1:7Zl+OVXn0bobcsi4NEZGdoQDTE9ij1zPMfM21+yqQsM= +k8s.io/client-go v8.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= diff --git a/vendor/github.com/hashicorp/go-discover/provider/os/os_discover.go b/vendor/github.com/hashicorp/go-discover/provider/os/os_discover.go index 6db860ff5..278003579 100644 --- a/vendor/github.com/hashicorp/go-discover/provider/os/os_discover.go +++ b/vendor/github.com/hashicorp/go-discover/provider/os/os_discover.go @@ -128,16 +128,16 @@ func newClient(args map[string]string, l *log.Logger) (*gophercloud.ServiceClien } projectID := argsOrEnv(args, "project_id", "OS_PROJECT_ID") insecure := argsOrEnv(args, "insecure", "OS_INSECURE") + domain_id := argsOrEnv(args, "domain_id", "OS_DOMAIN_ID") + domain_name := argsOrEnv(args, "domain_name", "OS_DOMAIN_NAME") if url == "" { return nil, fmt.Errorf("discover-os: Auth url must be provided") } ao := gophercloud.AuthOptions{ - // "domain_id": OS_DOMAIN_ID - DomainID: "", - // "domain_name": OS_DOMAIN_NAME - DomainName: "", + DomainID: domain_id, + DomainName: domain_name, IdentityEndpoint: url, Username: username, Password: password, diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/scaleway_discover.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/scaleway_discover.go index 11bd2dab8..043cb2fe9 100644 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/scaleway_discover.go +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/scaleway_discover.go @@ -6,7 +6,7 @@ import ( "io/ioutil" "log" - "github.com/nicolai86/scaleway-sdk/api" + api "github.com/nicolai86/scaleway-sdk" ) type Provider struct{} @@ -58,7 +58,7 @@ func (p *Provider) Addrs(args map[string]string, l *log.Logger) ([]string, error // Filter servers by tag var addrs []string if servers != nil { - for _, server := range *servers { + for _, server := range servers { if stringInSlice(tagName, server.Tags) { l.Printf("[DEBUG] discover-scaleway: Found server (%s) - %s with private IP: %s", server.Name, server.Hostname, server.PrivateIP) diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/LICENSE.md b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/LICENSE.md index 7503a16ca..12e056f64 100644 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/LICENSE.md +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/LICENSE.md @@ -1,8 +1,6 @@ The MIT License =============== -Copyright (c) **2014-2016 Scaleway ([@scaleway](https://twitter.com/scaleway))** - 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 diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/README.md b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/README.md new file mode 100644 index 000000000..b0c8dc1fe --- /dev/null +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/README.md @@ -0,0 +1,9 @@ +# Scaleway SDK + +A fork of the scaleway cli repository which only aims at being an API SDK - nothing more. + +## Tests + +```bash +$ go test ./... +``` \ No newline at end of file diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/api.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api.go similarity index 70% rename from vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/api.go rename to vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api.go index 82ddd25ad..fad62e78c 100644 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/api.go +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api.go @@ -1,10 +1,10 @@ -// Copyright (C) 2015 Scaleway. All rights reserved. +// Copyright (C) 2015 . All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE.md file. -// Interact with Scaleway API +// Interact with API -// Package api contains client and functions to interact with Scaleway API +// Package api contains client and functions to interact with API package api import ( @@ -23,17 +23,15 @@ import ( "golang.org/x/sync/errgroup" ) -// https://cp-par1.scaleway.com/products/servers -// https://cp-ams1.scaleway.com/products/servers +// https://cp-par1..com/products/servers +// https://cp-ams1..com/products/servers // Default values var ( - AccountAPI = "https://account.scaleway.com/" - MetadataAPI = "http://169.254.42.42/" - MarketplaceAPI = "https://api-marketplace.scaleway.com" - ComputeAPIPar1 = "https://cp-par1.scaleway.com/" - ComputeAPIAms1 = "https://cp-ams1.scaleway.com/" - AvailabilityAPIPar1 = "https://availability.scaleway.com/" - AvailabilityAPIAms1 = "https://availability-ams1.scaleway.com/" + AccountAPI = "https://account.scaleway.com/" + MetadataAPI = "http://169.254.42.42/" + MarketplaceAPI = "https://api-marketplace.scaleway.com" + ComputeAPIPar1 = "https://cp-par1.scaleway.com/" + ComputeAPIAms1 = "https://cp-ams1.scaleway.com/" URLPublicDNS = ".pub.cloud.scaleway.com" URLPrivateDNS = ".priv.cloud.scaleway.com" @@ -60,28 +58,21 @@ type HTTPClient interface { Do(*http.Request) (*http.Response, error) } -// ScalewayAPI is the interface used to communicate with the Scaleway API -type ScalewayAPI struct { - // Organization is the identifier of the Scaleway organization - Organization string +// API is the interface used to communicate with the API +type API struct { + Organization string // Organization is the identifier of the organization + Token string // Token is the authentication token for the organization + Client HTTPClient // Client is used for all HTTP interactions - // Token is the authentication token for the Scaleway organization - Token string - - // Password is the authentication password - password string - - userAgent string - - client HTTPClient - computeAPI string - availabilityAPI string + password string // Password is the authentication password + userAgent string + computeAPI string Region string } -// ScalewayAPIError represents a Scaleway API Error -type ScalewayAPIError struct { +// APIError represents a API Error +type APIError struct { // Message is a human-friendly error message APIMessage string `json:"message,omitempty"` @@ -99,7 +90,7 @@ type ScalewayAPIError struct { } // Error returns a string representing the error -func (e ScalewayAPIError) Error() string { +func (e APIError) Error() string { var b bytes.Buffer fmt.Fprintf(&b, "StatusCode: %v, ", e.StatusCode) @@ -111,17 +102,17 @@ func (e ScalewayAPIError) Error() string { return b.String() } -// New creates a ready-to-use Scaleway SDK client -func New(organization, token, region string, options ...func(*ScalewayAPI)) (*ScalewayAPI, error) { - s := &ScalewayAPI{ +// New creates a ready-to-use SDK client +func New(organization, token, region string, options ...func(*API)) (*API, error) { + s := &API{ // exposed Organization: organization, Token: token, + Client: &http.Client{}, // internal - client: &http.Client{}, password: "", - userAgent: "scaleway-sdk", + userAgent: "-sdk", } for _, option := range options { option(s) @@ -129,10 +120,8 @@ func New(organization, token, region string, options ...func(*ScalewayAPI)) (*Sc switch region { case "par1", "": s.computeAPI = ComputeAPIPar1 - s.availabilityAPI = AvailabilityAPIPar1 case "ams1": s.computeAPI = ComputeAPIAms1 - s.availabilityAPI = AvailabilityAPIAms1 default: return nil, fmt.Errorf("%s isn't a valid region", region) } @@ -140,13 +129,10 @@ func New(organization, token, region string, options ...func(*ScalewayAPI)) (*Sc if url := os.Getenv("SCW_COMPUTE_API"); url != "" { s.computeAPI = url } - if url := os.Getenv("SCW_AVAILABILITY_API"); url != "" { - s.availabilityAPI = url - } return s, nil } -func (s *ScalewayAPI) response(method, uri string, content io.Reader) (resp *http.Response, err error) { +func (s *API) response(method, uri string, content io.Reader) (resp *http.Response, err error) { var ( req *http.Request ) @@ -159,12 +145,12 @@ func (s *ScalewayAPI) response(method, uri string, content io.Reader) (resp *htt req.Header.Set("X-Auth-Token", s.Token) req.Header.Set("Content-Type", "application/json") req.Header.Set("User-Agent", s.userAgent) - resp, err = s.client.Do(req) + resp, err = s.Client.Do(req) return } // GetResponsePaginate fetchs all resources and returns an http.Response object for the requested resource -func (s *ScalewayAPI) GetResponsePaginate(apiURL, resource string, values url.Values) (*http.Response, error) { +func (s *API) GetResponsePaginate(apiURL, resource string, values url.Values) (*http.Response, error) { resp, err := s.response("HEAD", fmt.Sprintf("%s/%s?%s", strings.TrimRight(apiURL, "/"), resource, values.Encode()), nil) if err != nil { return nil, err @@ -252,7 +238,7 @@ func (s *ScalewayAPI) GetResponsePaginate(apiURL, resource string, values url.Va } // PostResponse returns an http.Response object for the updated resource -func (s *ScalewayAPI) PostResponse(apiURL, resource string, data interface{}) (*http.Response, error) { +func (s *API) PostResponse(apiURL, resource string, data interface{}) (*http.Response, error) { payload := new(bytes.Buffer) if err := json.NewEncoder(payload).Encode(data); err != nil { return nil, err @@ -261,7 +247,7 @@ func (s *ScalewayAPI) PostResponse(apiURL, resource string, data interface{}) (* } // PatchResponse returns an http.Response object for the updated resource -func (s *ScalewayAPI) PatchResponse(apiURL, resource string, data interface{}) (*http.Response, error) { +func (s *API) PatchResponse(apiURL, resource string, data interface{}) (*http.Response, error) { payload := new(bytes.Buffer) if err := json.NewEncoder(payload).Encode(data); err != nil { return nil, err @@ -270,7 +256,7 @@ func (s *ScalewayAPI) PatchResponse(apiURL, resource string, data interface{}) ( } // PutResponse returns an http.Response object for the updated resource -func (s *ScalewayAPI) PutResponse(apiURL, resource string, data interface{}) (*http.Response, error) { +func (s *API) PutResponse(apiURL, resource string, data interface{}) (*http.Response, error) { payload := new(bytes.Buffer) if err := json.NewEncoder(payload).Encode(data); err != nil { return nil, err @@ -279,12 +265,12 @@ func (s *ScalewayAPI) PutResponse(apiURL, resource string, data interface{}) (*h } // DeleteResponse returns an http.Response object for the deleted resource -func (s *ScalewayAPI) DeleteResponse(apiURL, resource string) (*http.Response, error) { +func (s *API) DeleteResponse(apiURL, resource string) (*http.Response, error) { return s.response("DELETE", fmt.Sprintf("%s/%s", strings.TrimRight(apiURL, "/"), resource), nil) } // handleHTTPError checks the statusCode and displays the error -func (s *ScalewayAPI) handleHTTPError(goodStatusCode []int, resp *http.Response) ([]byte, error) { +func (s *API) handleHTTPError(goodStatusCode []int, resp *http.Response) ([]byte, error) { body, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, err @@ -293,25 +279,24 @@ func (s *ScalewayAPI) handleHTTPError(goodStatusCode []int, resp *http.Response) if resp.StatusCode >= http.StatusInternalServerError { return nil, errors.New(string(body)) } - good := false + for _, code := range goodStatusCode { if code == resp.StatusCode { - good = true + return body, nil } } - if !good { - var scwError ScalewayAPIError + var scwError APIError + scwError.StatusCode = resp.StatusCode + if len(body) > 0 { if err := json.Unmarshal(body, &scwError); err != nil { return nil, err } - scwError.StatusCode = resp.StatusCode - return nil, scwError } - return body, nil + return nil, scwError } // SetPassword register the password -func (s *ScalewayAPI) SetPassword(password string) { +func (s *API) SetPassword(password string) { s.password = password } diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/availability.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/availability.go deleted file mode 100644 index fe5e23ac1..000000000 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/availability.go +++ /dev/null @@ -1,37 +0,0 @@ -package api - -import ( - "encoding/json" - "fmt" - "io/ioutil" -) - -type ServerAvailabilities map[string]interface{} - -func (a ServerAvailabilities) CommercialTypes() []string { - types := []string{} - for k, v := range a { - if _, ok := v.(bool); !ok { - continue - } - types = append(types, k) - } - return types -} - -func (s *ScalewayAPI) GetServerAvailabilities() (ServerAvailabilities, error) { - resp, err := s.response("GET", fmt.Sprintf("%s/availability.json", s.availabilityAPI), nil) - if err != nil { - return nil, err - } - defer resp.Body.Close() - bs, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, err - } - content := ServerAvailabilities{} - if err := json.Unmarshal(bs, &content); err != nil { - return nil, err - } - return content, nil -} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/container.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/container.go deleted file mode 100644 index d1173b20f..000000000 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/container.go +++ /dev/null @@ -1,72 +0,0 @@ -package api - -import ( - "encoding/json" - "fmt" - "net/http" - "net/url" -) - -// ScalewayContainerData represents a Scaleway container data (S3) -type ScalewayContainerData struct { - LastModified string `json:"last_modified"` - Name string `json:"name"` - Size string `json:"size"` -} - -// ScalewayGetContainerDatas represents a list of Scaleway containers data (S3) -type ScalewayGetContainerDatas struct { - Container []ScalewayContainerData `json:"container"` -} - -// ScalewayContainer represents a Scaleway container (S3) -type ScalewayContainer struct { - ScalewayOrganizationDefinition `json:"organization"` - Name string `json:"name"` - Size string `json:"size"` -} - -// ScalewayGetContainers represents a list of Scaleway containers (S3) -type ScalewayGetContainers struct { - Containers []ScalewayContainer `json:"containers"` -} - -// GetContainers returns a ScalewayGetContainers -func (s *ScalewayAPI) GetContainers() (*ScalewayGetContainers, error) { - resp, err := s.GetResponsePaginate(s.computeAPI, "containers", url.Values{}) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - body, err := s.handleHTTPError([]int{http.StatusOK}, resp) - if err != nil { - return nil, err - } - var containers ScalewayGetContainers - - if err = json.Unmarshal(body, &containers); err != nil { - return nil, err - } - return &containers, nil -} - -// GetContainerDatas returns a ScalewayGetContainerDatas -func (s *ScalewayAPI) GetContainerDatas(container string) (*ScalewayGetContainerDatas, error) { - resp, err := s.GetResponsePaginate(s.computeAPI, fmt.Sprintf("containers/%s", container), url.Values{}) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - body, err := s.handleHTTPError([]int{http.StatusOK}, resp) - if err != nil { - return nil, err - } - var datas ScalewayGetContainerDatas - - if err = json.Unmarshal(body, &datas); err != nil { - return nil, err - } - return &datas, nil -} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/organization.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/organization.go deleted file mode 100644 index 29e4b436f..000000000 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/organization.go +++ /dev/null @@ -1,39 +0,0 @@ -package api - -import ( - "encoding/json" - "net/http" - "net/url" -) - -// ScalewayOrganizationDefinition represents a Scaleway Organization -type ScalewayOrganizationDefinition struct { - ID string `json:"id"` - Name string `json:"name"` - Users []ScalewayUserDefinition `json:"users"` -} - -// ScalewayOrganizationsDefinition represents a Scaleway Organizations -type ScalewayOrganizationsDefinition struct { - Organizations []ScalewayOrganizationDefinition `json:"organizations"` -} - -// GetOrganization returns Organization -func (s *ScalewayAPI) GetOrganization() (*ScalewayOrganizationsDefinition, error) { - resp, err := s.GetResponsePaginate(AccountAPI, "organizations", url.Values{}) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - body, err := s.handleHTTPError([]int{http.StatusOK}, resp) - if err != nil { - return nil, err - } - var data ScalewayOrganizationsDefinition - - if err = json.Unmarshal(body, &data); err != nil { - return nil, err - } - return &data, nil -} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/permissions.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/permissions.go deleted file mode 100644 index c3cdaaa47..000000000 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/permissions.go +++ /dev/null @@ -1,39 +0,0 @@ -package api - -import ( - "encoding/json" - "fmt" - "net/http" - "net/url" -) - -// ScalewayPermissions represents the response of GET /permissions -type ScalewayPermissions map[string]ScalewayPermCategory - -// ScalewayPermCategory represents ScalewayPermissions's fields -type ScalewayPermCategory map[string][]string - -// ScalewayPermissionDefinition represents the permissions -type ScalewayPermissionDefinition struct { - Permissions ScalewayPermissions `json:"permissions"` -} - -// GetPermissions returns the permissions -func (s *ScalewayAPI) GetPermissions() (*ScalewayPermissionDefinition, error) { - resp, err := s.GetResponsePaginate(AccountAPI, fmt.Sprintf("tokens/%s/permissions", s.Token), url.Values{}) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - body, err := s.handleHTTPError([]int{http.StatusOK}, resp) - if err != nil { - return nil, err - } - var permissions ScalewayPermissionDefinition - - if err = json.Unmarshal(body, &permissions); err != nil { - return nil, err - } - return &permissions, nil -} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/security_group.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/security_group.go deleted file mode 100644 index 26b5cef4e..000000000 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/security_group.go +++ /dev/null @@ -1,129 +0,0 @@ -package api - -import ( - "encoding/json" - "fmt" - "net/http" - "net/url" -) - -// ScalewaySecurityGroups definition -type ScalewaySecurityGroups struct { - Description string `json:"description"` - ID string `json:"id"` - Organization string `json:"organization"` - Name string `json:"name"` - Servers []ScalewaySecurityGroup `json:"servers"` - EnableDefaultSecurity bool `json:"enable_default_security"` - OrganizationDefault bool `json:"organization_default"` -} - -// ScalewayGetSecurityGroups represents the response of a GET /security_groups/ -type ScalewayGetSecurityGroups struct { - SecurityGroups []ScalewaySecurityGroups `json:"security_groups"` -} - -// ScalewayGetSecurityGroup represents the response of a GET /security_groups/{groupID} -type ScalewayGetSecurityGroup struct { - SecurityGroups ScalewaySecurityGroups `json:"security_group"` -} - -// ScalewaySecurityGroup represents a Scaleway security group -type ScalewaySecurityGroup struct { - // Identifier is a unique identifier for the security group - Identifier string `json:"id,omitempty"` - - // Name is the user-defined name of the security group - Name string `json:"name,omitempty"` -} - -// ScalewayNewSecurityGroup definition POST request /security_groups -type ScalewayNewSecurityGroup struct { - Organization string `json:"organization"` - Name string `json:"name"` - Description string `json:"description"` -} - -// ScalewayUpdateSecurityGroup definition PUT request /security_groups -type ScalewayUpdateSecurityGroup struct { - Organization string `json:"organization"` - Name string `json:"name"` - Description string `json:"description"` - OrganizationDefault bool `json:"organization_default"` -} - -// DeleteSecurityGroup deletes a SecurityGroup -func (s *ScalewayAPI) DeleteSecurityGroup(securityGroupID string) error { - resp, err := s.DeleteResponse(s.computeAPI, fmt.Sprintf("security_groups/%s", securityGroupID)) - if err != nil { - return err - } - defer resp.Body.Close() - - _, err = s.handleHTTPError([]int{http.StatusNoContent}, resp) - return err -} - -// PutSecurityGroup updates a SecurityGroup -func (s *ScalewayAPI) PutSecurityGroup(group ScalewayUpdateSecurityGroup, securityGroupID string) error { - resp, err := s.PutResponse(s.computeAPI, fmt.Sprintf("security_groups/%s", securityGroupID), group) - if err != nil { - return err - } - defer resp.Body.Close() - - _, err = s.handleHTTPError([]int{http.StatusOK}, resp) - return err -} - -// GetASecurityGroup returns a ScalewaySecurityGroup -func (s *ScalewayAPI) GetASecurityGroup(groupsID string) (*ScalewayGetSecurityGroup, error) { - resp, err := s.GetResponsePaginate(s.computeAPI, fmt.Sprintf("security_groups/%s", groupsID), url.Values{}) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - body, err := s.handleHTTPError([]int{http.StatusOK}, resp) - if err != nil { - return nil, err - } - var securityGroups ScalewayGetSecurityGroup - - if err = json.Unmarshal(body, &securityGroups); err != nil { - return nil, err - } - return &securityGroups, nil -} - -// PostSecurityGroup posts a group on a server -func (s *ScalewayAPI) PostSecurityGroup(group ScalewayNewSecurityGroup) error { - resp, err := s.PostResponse(s.computeAPI, "security_groups", group) - if err != nil { - return err - } - defer resp.Body.Close() - - _, err = s.handleHTTPError([]int{http.StatusCreated}, resp) - return err -} - -// GetSecurityGroups returns a ScalewaySecurityGroups -func (s *ScalewayAPI) GetSecurityGroups() (*ScalewayGetSecurityGroups, error) { - resp, err := s.GetResponsePaginate(s.computeAPI, "security_groups", url.Values{}) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - body, err := s.handleHTTPError([]int{http.StatusOK}, resp) - if err != nil { - return nil, err - } - var securityGroups ScalewayGetSecurityGroups - - if err = json.Unmarshal(body, &securityGroups); err != nil { - return nil, err - } - return &securityGroups, nil -} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/security_group_rule.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/security_group_rule.go deleted file mode 100644 index 0735c8d38..000000000 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/security_group_rule.go +++ /dev/null @@ -1,116 +0,0 @@ -package api - -import ( - "encoding/json" - "fmt" - "net/http" - "net/url" -) - -// ScalewaySecurityGroupRule definition -type ScalewaySecurityGroupRule struct { - Direction string `json:"direction"` - Protocol string `json:"protocol"` - IPRange string `json:"ip_range"` - DestPortFrom int `json:"dest_port_from,omitempty"` - Action string `json:"action"` - Position int `json:"position"` - DestPortTo string `json:"dest_port_to"` - Editable bool `json:"editable"` - ID string `json:"id"` -} - -// ScalewayGetSecurityGroupRules represents the response of a GET /security_group/{groupID}/rules -type ScalewayGetSecurityGroupRules struct { - Rules []ScalewaySecurityGroupRule `json:"rules"` -} - -// ScalewayGetSecurityGroupRule represents the response of a GET /security_group/{groupID}/rules/{ruleID} -type ScalewayGetSecurityGroupRule struct { - Rules ScalewaySecurityGroupRule `json:"rule"` -} - -// ScalewayNewSecurityGroupRule definition POST/PUT request /security_group/{groupID} -type ScalewayNewSecurityGroupRule struct { - Action string `json:"action"` - Direction string `json:"direction"` - IPRange string `json:"ip_range"` - Protocol string `json:"protocol"` - DestPortFrom int `json:"dest_port_from,omitempty"` -} - -// GetSecurityGroupRules returns a ScalewaySecurityGroupRules -func (s *ScalewayAPI) GetSecurityGroupRules(groupID string) (*ScalewayGetSecurityGroupRules, error) { - resp, err := s.GetResponsePaginate(s.computeAPI, fmt.Sprintf("security_groups/%s/rules", groupID), url.Values{}) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - body, err := s.handleHTTPError([]int{http.StatusOK}, resp) - if err != nil { - return nil, err - } - var securityGroupRules ScalewayGetSecurityGroupRules - - if err = json.Unmarshal(body, &securityGroupRules); err != nil { - return nil, err - } - return &securityGroupRules, nil -} - -// GetASecurityGroupRule returns a ScalewaySecurityGroupRule -func (s *ScalewayAPI) GetASecurityGroupRule(groupID string, rulesID string) (*ScalewayGetSecurityGroupRule, error) { - resp, err := s.GetResponsePaginate(s.computeAPI, fmt.Sprintf("security_groups/%s/rules/%s", groupID, rulesID), url.Values{}) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - body, err := s.handleHTTPError([]int{http.StatusOK}, resp) - if err != nil { - return nil, err - } - var securityGroupRules ScalewayGetSecurityGroupRule - - if err = json.Unmarshal(body, &securityGroupRules); err != nil { - return nil, err - } - return &securityGroupRules, nil -} - -// PostSecurityGroupRule posts a rule on a server -func (s *ScalewayAPI) PostSecurityGroupRule(SecurityGroupID string, rules ScalewayNewSecurityGroupRule) error { - resp, err := s.PostResponse(s.computeAPI, fmt.Sprintf("security_groups/%s/rules", SecurityGroupID), rules) - if err != nil { - return err - } - defer resp.Body.Close() - - _, err = s.handleHTTPError([]int{http.StatusCreated}, resp) - return err -} - -// PutSecurityGroupRule updates a SecurityGroupRule -func (s *ScalewayAPI) PutSecurityGroupRule(rules ScalewayNewSecurityGroupRule, securityGroupID, RuleID string) error { - resp, err := s.PutResponse(s.computeAPI, fmt.Sprintf("security_groups/%s/rules/%s", securityGroupID, RuleID), rules) - if err != nil { - return err - } - defer resp.Body.Close() - - _, err = s.handleHTTPError([]int{http.StatusOK}, resp) - return err -} - -// DeleteSecurityGroupRule deletes a SecurityGroupRule -func (s *ScalewayAPI) DeleteSecurityGroupRule(SecurityGroupID, RuleID string) error { - resp, err := s.DeleteResponse(s.computeAPI, fmt.Sprintf("security_groups/%s/rules/%s", SecurityGroupID, RuleID)) - if err != nil { - return err - } - defer resp.Body.Close() - - _, err = s.handleHTTPError([]int{http.StatusNoContent}, resp) - return err -} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/tasks.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/tasks.go deleted file mode 100644 index 3cadbad94..000000000 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/tasks.go +++ /dev/null @@ -1,59 +0,0 @@ -package api - -import ( - "encoding/json" - "net/http" - "net/url" -) - -// ScalewayTask represents a Scaleway Task -type ScalewayTask struct { - // Identifier is a unique identifier for the task - Identifier string `json:"id,omitempty"` - - // StartDate is the start date of the task - StartDate string `json:"started_at,omitempty"` - - // TerminationDate is the termination date of the task - TerminationDate string `json:"terminated_at,omitempty"` - - HrefFrom string `json:"href_from,omitempty"` - - Description string `json:"description,omitempty"` - - Status string `json:"status,omitempty"` - - Progress int `json:"progress,omitempty"` -} - -// ScalewayOneTask represents the response of a GET /tasks/UUID API call -type ScalewayOneTask struct { - Task ScalewayTask `json:"task,omitempty"` -} - -// ScalewayTasks represents a group of Scaleway tasks -type ScalewayTasks struct { - // Tasks holds scaleway tasks of the response - Tasks []ScalewayTask `json:"tasks,omitempty"` -} - -// GetTasks get the list of tasks from the ScalewayAPI -func (s *ScalewayAPI) GetTasks() (*[]ScalewayTask, error) { - query := url.Values{} - resp, err := s.GetResponsePaginate(s.computeAPI, "tasks", query) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - body, err := s.handleHTTPError([]int{http.StatusOK}, resp) - if err != nil { - return nil, err - } - var tasks ScalewayTasks - - if err = json.Unmarshal(body, &tasks); err != nil { - return nil, err - } - return &tasks.Tasks, nil -} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/user.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/user.go deleted file mode 100644 index 3a4371f6b..000000000 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/user.go +++ /dev/null @@ -1,121 +0,0 @@ -package api - -import ( - "encoding/json" - "fmt" - "net/http" - "net/url" -) - -// ScalewayTokenDefinition represents a Scaleway Token -type ScalewayTokenDefinition struct { - UserID string `json:"user_id"` - Description string `json:"description,omitempty"` - Roles ScalewayRoleDefinition `json:"roles"` - Expires string `json:"expires"` - InheritsUsersPerms bool `json:"inherits_user_perms"` - ID string `json:"id"` -} - -// ScalewayTokensDefinition represents a Scaleway Tokens -type ScalewayTokensDefinition struct { - Token ScalewayTokenDefinition `json:"token"` -} - -// ScalewayGetTokens represents a list of Scaleway Tokens -type ScalewayGetTokens struct { - Tokens []ScalewayTokenDefinition `json:"tokens"` -} - -// ScalewayRoleDefinition represents a Scaleway Token UserId Role -type ScalewayRoleDefinition struct { - Organization ScalewayOrganizationDefinition `json:"organization,omitempty"` - Role string `json:"role,omitempty"` -} - -// ScalewayUserDefinition represents a Scaleway User -type ScalewayUserDefinition struct { - Email string `json:"email"` - Firstname string `json:"firstname"` - Fullname string `json:"fullname"` - ID string `json:"id"` - Lastname string `json:"lastname"` - Organizations []ScalewayOrganizationDefinition `json:"organizations"` - Roles []ScalewayRoleDefinition `json:"roles"` - SSHPublicKeys []ScalewayKeyDefinition `json:"ssh_public_keys"` -} - -// ScalewayKeyDefinition represents a key -type ScalewayKeyDefinition struct { - Key string `json:"key"` - Fingerprint string `json:"fingerprint,omitempty"` -} - -// ScalewayUsersDefinition represents the response of a GET /user -type ScalewayUsersDefinition struct { - User ScalewayUserDefinition `json:"user"` -} - -// ScalewayUserPatchSSHKeyDefinition represents a User Patch -type ScalewayUserPatchSSHKeyDefinition struct { - SSHPublicKeys []ScalewayKeyDefinition `json:"ssh_public_keys"` -} - -// PatchUserSSHKey updates a user -func (s *ScalewayAPI) PatchUserSSHKey(UserID string, definition ScalewayUserPatchSSHKeyDefinition) error { - resp, err := s.PatchResponse(AccountAPI, fmt.Sprintf("users/%s", UserID), definition) - if err != nil { - return err - } - - defer resp.Body.Close() - - if _, err := s.handleHTTPError([]int{http.StatusOK}, resp); err != nil { - return err - } - return nil -} - -// GetUserID returns the userID -func (s *ScalewayAPI) GetUserID() (string, error) { - resp, err := s.GetResponsePaginate(AccountAPI, fmt.Sprintf("tokens/%s", s.Token), url.Values{}) - if err != nil { - return "", err - } - defer resp.Body.Close() - - body, err := s.handleHTTPError([]int{http.StatusOK}, resp) - if err != nil { - return "", err - } - var token ScalewayTokensDefinition - - if err = json.Unmarshal(body, &token); err != nil { - return "", err - } - return token.Token.UserID, nil -} - -// GetUser returns the user -func (s *ScalewayAPI) GetUser() (*ScalewayUserDefinition, error) { - userID, err := s.GetUserID() - if err != nil { - return nil, err - } - resp, err := s.GetResponsePaginate(AccountAPI, fmt.Sprintf("users/%s", userID), url.Values{}) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - body, err := s.handleHTTPError([]int{http.StatusOK}, resp) - if err != nil { - return nil, err - } - var user ScalewayUsersDefinition - - if err = json.Unmarshal(body, &user); err != nil { - return nil, err - } - return &user.User, nil -} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/availability.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/availability.go new file mode 100644 index 000000000..58977127d --- /dev/null +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/availability.go @@ -0,0 +1,50 @@ +package api + +import ( + "encoding/json" + "fmt" + "io/ioutil" +) + +type InstanceTypeAvailability string + +var ( + InstanceTypeAvailable InstanceTypeAvailability = "available" + InstanceTypeScarce InstanceTypeAvailability = "scarce" + InstanceTypeShortage InstanceTypeAvailability = "shortage" +) + +type ServerAvailability struct { + Availability InstanceTypeAvailability `json:"availability"` +} + +type ServerAvailabilities map[string]ServerAvailability + +func (a ServerAvailabilities) CommercialTypes() []string { + types := []string{} + for k, _ := range a { + types = append(types, k) + } + return types +} + +type availabilityResponse struct { + Servers ServerAvailabilities +} + +func (s *API) GetServerAvailabilities() (ServerAvailabilities, error) { + resp, err := s.response("GET", fmt.Sprintf("%s/products/servers/availability", s.computeAPI), nil) + if err != nil { + return nil, err + } + defer resp.Body.Close() + bs, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, err + } + content := availabilityResponse{} + if err := json.Unmarshal(bs, &content); err != nil { + return nil, err + } + return content.Servers, nil +} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/bootscript.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/bootscript.go similarity index 63% rename from vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/bootscript.go rename to vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/bootscript.go index 67849c694..b10ced6e3 100644 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/bootscript.go +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/bootscript.go @@ -6,8 +6,8 @@ import ( "net/url" ) -// ScalewayBootscript represents a Scaleway Bootscript -type ScalewayBootscript struct { +// Bootscript represents a Bootscript +type Bootscript struct { Bootcmdargs string `json:"bootcmdargs,omitempty"` Dtb string `json:"dtb,omitempty"` Initrd string `json:"initrd,omitempty"` @@ -31,19 +31,16 @@ type ScalewayBootscript struct { Default bool `json:"default,omitempty"` } -// ScalewayOneBootscript represents the response of a GET /bootscripts/UUID API call -type ScalewayOneBootscript struct { - Bootscript ScalewayBootscript `json:"bootscript,omitempty"` +type getBootscriptResponse struct { + Bootscript Bootscript `json:"bootscript,omitempty"` } -// ScalewayBootscripts represents a group of Scaleway bootscripts -type ScalewayBootscripts struct { - // Bootscripts holds Scaleway bootscripts of the response - Bootscripts []ScalewayBootscript `json:"bootscripts,omitempty"` +type getBootscriptsResponse struct { + Bootscripts []Bootscript `json:"bootscripts,omitempty"` } -// GetBootscripts gets the list of bootscripts from the ScalewayAPI -func (s *ScalewayAPI) GetBootscripts() (*[]ScalewayBootscript, error) { +// GetBootscripts gets the list of bootscripts from the API +func (s *API) GetBootscripts() ([]Bootscript, error) { query := url.Values{} resp, err := s.GetResponsePaginate(s.computeAPI, "bootscripts", query) @@ -56,16 +53,16 @@ func (s *ScalewayAPI) GetBootscripts() (*[]ScalewayBootscript, error) { if err != nil { return nil, err } - var bootscripts ScalewayBootscripts + var bootscripts getBootscriptsResponse if err = json.Unmarshal(body, &bootscripts); err != nil { return nil, err } - return &bootscripts.Bootscripts, nil + return bootscripts.Bootscripts, nil } -// GetBootscript gets a bootscript from the ScalewayAPI -func (s *ScalewayAPI) GetBootscript(bootscriptID string) (*ScalewayBootscript, error) { +// GetBootscript gets a bootscript from the API +func (s *API) GetBootscript(bootscriptID string) (*Bootscript, error) { resp, err := s.GetResponsePaginate(s.computeAPI, "bootscripts/"+bootscriptID, url.Values{}) if err != nil { return nil, err @@ -76,7 +73,7 @@ func (s *ScalewayAPI) GetBootscript(bootscriptID string) (*ScalewayBootscript, e if err != nil { return nil, err } - var oneBootscript ScalewayOneBootscript + var oneBootscript getBootscriptResponse if err = json.Unmarshal(body, &oneBootscript); err != nil { return nil, err diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/container.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/container.go new file mode 100644 index 000000000..e7a5abc49 --- /dev/null +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/container.go @@ -0,0 +1,70 @@ +package api + +import ( + "encoding/json" + "fmt" + "net/http" + "net/url" +) + +// ContainerData represents a container data (S3) +type ContainerData struct { + LastModified string `json:"last_modified"` + Name string `json:"name"` + Size string `json:"size"` +} + +type getContainerDatas struct { + Container []*ContainerData `json:"container"` +} + +// Container represents a container (S3) +type Container struct { + Organization `json:"organization"` + Name string `json:"name"` + Size string `json:"size"` +} + +type getContainers struct { + Containers []*Container `json:"containers"` +} + +// GetContainers returns a GetContainers +func (s *API) GetContainers() ([]*Container, error) { + resp, err := s.GetResponsePaginate(s.computeAPI, "containers", url.Values{}) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var containers getContainers + + if err = json.Unmarshal(body, &containers); err != nil { + return nil, err + } + return containers.Containers, nil +} + +// GetContainerDatas returns a GetContainerDatas +func (s *API) GetContainerDatas(container string) ([]*ContainerData, error) { + resp, err := s.GetResponsePaginate(s.computeAPI, fmt.Sprintf("containers/%s", container), url.Values{}) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var datas getContainerDatas + + if err = json.Unmarshal(body, &datas); err != nil { + return nil, err + } + return datas.Container, nil +} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/dashboard.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/dashboard.go similarity index 70% rename from vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/dashboard.go rename to vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/dashboard.go index 6835ab4b4..a66cea6fa 100644 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/dashboard.go +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/dashboard.go @@ -6,13 +6,13 @@ import ( "net/url" ) -// ScalewayDashboardResp represents a dashboard received from the API -type ScalewayDashboardResp struct { - Dashboard ScalewayDashboard +// DashboardResp represents a dashboard received from the API +type DashboardResp struct { + Dashboard Dashboard } -// ScalewayDashboard represents a dashboard -type ScalewayDashboard struct { +// Dashboard represents a dashboard +type Dashboard struct { VolumesCount int `json:"volumes_count"` RunningServersCount int `json:"running_servers_count"` ImagesCount int `json:"images_count"` @@ -22,7 +22,7 @@ type ScalewayDashboard struct { } // GetDashboard returns the dashboard -func (s *ScalewayAPI) GetDashboard() (*ScalewayDashboard, error) { +func (s *API) GetDashboard() (*Dashboard, error) { resp, err := s.GetResponsePaginate(s.computeAPI, "dashboard", url.Values{}) if err != nil { return nil, err @@ -33,7 +33,7 @@ func (s *ScalewayAPI) GetDashboard() (*ScalewayDashboard, error) { if err != nil { return nil, err } - var dashboard ScalewayDashboardResp + var dashboard DashboardResp if err = json.Unmarshal(body, &dashboard); err != nil { return nil, err diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/image.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/image.go similarity index 78% rename from vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/image.go rename to vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/image.go index 0a2fba181..e8e644e32 100644 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/image.go +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/image.go @@ -7,8 +7,8 @@ import ( "net/url" ) -// ScalewayImageDefinition represents a Scaleway image definition -type ScalewayImageDefinition struct { +// ImageDefinition represents a image definition +type ImageDefinition struct { SnapshotIDentifier string `json:"root_volume"` Name string `json:"name,omitempty"` Organization string `json:"organization"` @@ -16,8 +16,8 @@ type ScalewayImageDefinition struct { DefaultBootscript *string `json:"default_bootscript,omitempty"` } -// ScalewayImage represents a Scaleway Image -type ScalewayImage struct { +// Image represents a Image +type Image struct { // Identifier is a unique identifier for the image Identifier string `json:"id,omitempty"` @@ -31,13 +31,13 @@ type ScalewayImage struct { ModificationDate string `json:"modification_date,omitempty"` // RootVolume is the root volume bound to the image - RootVolume ScalewayVolume `json:"root_volume,omitempty"` + RootVolume Volume `json:"root_volume,omitempty"` // Public is true for public images and false for user images Public bool `json:"public,omitempty"` // Bootscript is the bootscript bound to the image - DefaultBootscript *ScalewayBootscript `json:"default_bootscript,omitempty"` + DefaultBootscript *Bootscript `json:"default_bootscript,omitempty"` // Organization is the owner of the image Organization string `json:"organization,omitempty"` @@ -48,23 +48,23 @@ type ScalewayImage struct { // FIXME: extra_volumes } -// ScalewayImageIdentifier represents a Scaleway Image Identifier -type ScalewayImageIdentifier struct { +// ImageIdentifier represents a Image Identifier +type ImageIdentifier struct { Identifier string Arch string Region string Owner string } -// ScalewayOneImage represents the response of a GET /images/UUID API call -type ScalewayOneImage struct { - Image ScalewayImage `json:"image,omitempty"` +// OneImage represents the response of a GET /images/UUID API call +type OneImage struct { + Image Image `json:"image,omitempty"` } -// ScalewayImages represents a group of Scaleway images -type ScalewayImages struct { - // Images holds scaleway images of the response - Images []ScalewayImage `json:"images,omitempty"` +// Images represents a group of images +type Images struct { + // Images holds images of the response + Images []Image `json:"images,omitempty"` } // MarketImages represents MarketPlace images @@ -130,9 +130,9 @@ type MarketImage struct { MarketVersions } -// PostImage creates a new image -func (s *ScalewayAPI) PostImage(volumeID string, name string, bootscript string, arch string) (string, error) { - definition := ScalewayImageDefinition{ +// CreateImage creates a new image +func (s *API) CreateImage(volumeID string, name string, bootscript string, arch string) (*Image, error) { + definition := ImageDefinition{ SnapshotIDentifier: volumeID, Name: name, Organization: s.Organization, @@ -144,24 +144,24 @@ func (s *ScalewayAPI) PostImage(volumeID string, name string, bootscript string, resp, err := s.PostResponse(s.computeAPI, "images", definition) if err != nil { - return "", err + return nil, err } defer resp.Body.Close() body, err := s.handleHTTPError([]int{http.StatusCreated}, resp) if err != nil { - return "", err + return nil, err } - var image ScalewayOneImage + var image OneImage if err = json.Unmarshal(body, &image); err != nil { - return "", err + return nil, err } - return image.Image.Identifier, nil + return &image.Image, nil } -// GetImages gets the list of images from the ScalewayAPI -func (s *ScalewayAPI) GetImages() (*[]MarketImage, error) { +// GetImages gets the list of images from the API +func (s *API) GetImages() (*[]MarketImage, error) { images, err := s.GetMarketPlaceImages("") if err != nil { return nil, err @@ -187,7 +187,7 @@ func (s *ScalewayAPI) GetImages() (*[]MarketImage, error) { if err != nil { return nil, err } - var OrgaImages ScalewayImages + var OrgaImages Images if err = json.Unmarshal(body, &OrgaImages); err != nil { return nil, err @@ -225,8 +225,8 @@ func (s *ScalewayAPI) GetImages() (*[]MarketImage, error) { return &images.Images, nil } -// GetImage gets an image from the ScalewayAPI -func (s *ScalewayAPI) GetImage(imageID string) (*ScalewayImage, error) { +// GetImage gets an image from the API +func (s *API) GetImage(imageID string) (*Image, error) { resp, err := s.GetResponsePaginate(s.computeAPI, "images/"+imageID, url.Values{}) if err != nil { return nil, err @@ -237,7 +237,7 @@ func (s *ScalewayAPI) GetImage(imageID string) (*ScalewayImage, error) { if err != nil { return nil, err } - var oneImage ScalewayOneImage + var oneImage OneImage if err = json.Unmarshal(body, &oneImage); err != nil { return nil, err @@ -247,7 +247,7 @@ func (s *ScalewayAPI) GetImage(imageID string) (*ScalewayImage, error) { } // DeleteImage deletes a image -func (s *ScalewayAPI) DeleteImage(imageID string) error { +func (s *API) DeleteImage(imageID string) error { resp, err := s.DeleteResponse(s.computeAPI, fmt.Sprintf("images/%s", imageID)) if err != nil { return err @@ -261,7 +261,7 @@ func (s *ScalewayAPI) DeleteImage(imageID string) error { } // GetMarketPlaceImages returns images from marketplace -func (s *ScalewayAPI) GetMarketPlaceImages(uuidImage string) (*MarketImages, error) { +func (s *API) GetMarketPlaceImages(uuidImage string) (*MarketImages, error) { resp, err := s.GetResponsePaginate(MarketplaceAPI, fmt.Sprintf("images/%s", uuidImage), url.Values{}) if err != nil { return nil, err @@ -292,7 +292,7 @@ func (s *ScalewayAPI) GetMarketPlaceImages(uuidImage string) (*MarketImages, err } // GetMarketPlaceImageVersions returns image version -func (s *ScalewayAPI) GetMarketPlaceImageVersions(uuidImage, uuidVersion string) (*MarketVersions, error) { +func (s *API) GetMarketPlaceImageVersions(uuidImage, uuidVersion string) (*MarketVersions, error) { resp, err := s.GetResponsePaginate(MarketplaceAPI, fmt.Sprintf("images/%v/versions/%s", uuidImage, uuidVersion), url.Values{}) if err != nil { return nil, err @@ -322,7 +322,7 @@ func (s *ScalewayAPI) GetMarketPlaceImageVersions(uuidImage, uuidVersion string) } // GetMarketPlaceImageCurrentVersion return the image current version -func (s *ScalewayAPI) GetMarketPlaceImageCurrentVersion(uuidImage string) (*MarketVersion, error) { +func (s *API) GetMarketPlaceImageCurrentVersion(uuidImage string) (*MarketVersion, error) { resp, err := s.GetResponsePaginate(MarketplaceAPI, fmt.Sprintf("images/%v/versions/current", uuidImage), url.Values{}) if err != nil { return nil, err @@ -342,7 +342,7 @@ func (s *ScalewayAPI) GetMarketPlaceImageCurrentVersion(uuidImage string) (*Mark } // GetMarketPlaceLocalImages returns images from local region -func (s *ScalewayAPI) GetMarketPlaceLocalImages(uuidImage, uuidVersion, uuidLocalImage string) (*MarketLocalImages, error) { +func (s *API) GetMarketPlaceLocalImages(uuidImage, uuidVersion, uuidLocalImage string) (*MarketLocalImages, error) { resp, err := s.GetResponsePaginate(MarketplaceAPI, fmt.Sprintf("images/%v/versions/%s/local_images/%s", uuidImage, uuidVersion, uuidLocalImage), url.Values{}) if err != nil { return nil, err @@ -369,8 +369,8 @@ func (s *ScalewayAPI) GetMarketPlaceLocalImages(uuidImage, uuidVersion, uuidLoca return &ret, nil } -// PostMarketPlaceImage adds new image -func (s *ScalewayAPI) PostMarketPlaceImage(images MarketImage) error { +// CreateMarketPlaceImage adds new image +func (s *API) CreateMarketPlaceImage(images MarketImage) error { resp, err := s.PostResponse(MarketplaceAPI, "images/", images) if err != nil { return err @@ -380,8 +380,8 @@ func (s *ScalewayAPI) PostMarketPlaceImage(images MarketImage) error { return err } -// PostMarketPlaceImageVersion adds new image version -func (s *ScalewayAPI) PostMarketPlaceImageVersion(uuidImage string, version MarketVersion) error { +// CreateMarketPlaceImageVersion adds new image version +func (s *API) CreateMarketPlaceImageVersion(uuidImage string, version MarketVersion) error { resp, err := s.PostResponse(MarketplaceAPI, fmt.Sprintf("images/%v/versions", uuidImage), version) if err != nil { return err @@ -391,8 +391,8 @@ func (s *ScalewayAPI) PostMarketPlaceImageVersion(uuidImage string, version Mark return err } -// PostMarketPlaceLocalImage adds new local image -func (s *ScalewayAPI) PostMarketPlaceLocalImage(uuidImage, uuidVersion, uuidLocalImage string, local MarketLocalImage) error { +// CreateMarketPlaceLocalImage adds new local image +func (s *API) CreateMarketPlaceLocalImage(uuidImage, uuidVersion, uuidLocalImage string, local MarketLocalImage) error { resp, err := s.PostResponse(MarketplaceAPI, fmt.Sprintf("images/%v/versions/%s/local_images/%v", uuidImage, uuidVersion, uuidLocalImage), local) if err != nil { return err @@ -402,8 +402,8 @@ func (s *ScalewayAPI) PostMarketPlaceLocalImage(uuidImage, uuidVersion, uuidLoca return err } -// PutMarketPlaceImage updates image -func (s *ScalewayAPI) PutMarketPlaceImage(uudiImage string, images MarketImage) error { +// UpdateMarketPlaceImage updates image +func (s *API) UpdateMarketPlaceImage(uudiImage string, images MarketImage) error { resp, err := s.PutResponse(MarketplaceAPI, fmt.Sprintf("images/%v", uudiImage), images) if err != nil { return err @@ -413,8 +413,8 @@ func (s *ScalewayAPI) PutMarketPlaceImage(uudiImage string, images MarketImage) return err } -// PutMarketPlaceImageVersion updates image version -func (s *ScalewayAPI) PutMarketPlaceImageVersion(uuidImage, uuidVersion string, version MarketVersion) error { +// UpdateMarketPlaceImageVersion updates image version +func (s *API) UpdateMarketPlaceImageVersion(uuidImage, uuidVersion string, version MarketVersion) error { resp, err := s.PutResponse(MarketplaceAPI, fmt.Sprintf("images/%v/versions/%v", uuidImage, uuidVersion), version) if err != nil { return err @@ -424,8 +424,8 @@ func (s *ScalewayAPI) PutMarketPlaceImageVersion(uuidImage, uuidVersion string, return err } -// PutMarketPlaceLocalImage updates local image -func (s *ScalewayAPI) PutMarketPlaceLocalImage(uuidImage, uuidVersion, uuidLocalImage string, local MarketLocalImage) error { +// UpdateMarketPlaceLocalImage updates local image +func (s *API) UpdateMarketPlaceLocalImage(uuidImage, uuidVersion, uuidLocalImage string, local MarketLocalImage) error { resp, err := s.PostResponse(MarketplaceAPI, fmt.Sprintf("images/%v/versions/%s/local_images/%v", uuidImage, uuidVersion, uuidLocalImage), local) if err != nil { return err @@ -436,7 +436,7 @@ func (s *ScalewayAPI) PutMarketPlaceLocalImage(uuidImage, uuidVersion, uuidLocal } // DeleteMarketPlaceImage deletes image -func (s *ScalewayAPI) DeleteMarketPlaceImage(uudImage string) error { +func (s *API) DeleteMarketPlaceImage(uudImage string) error { resp, err := s.DeleteResponse(MarketplaceAPI, fmt.Sprintf("images/%v", uudImage)) if err != nil { return err @@ -447,7 +447,7 @@ func (s *ScalewayAPI) DeleteMarketPlaceImage(uudImage string) error { } // DeleteMarketPlaceImageVersion delete image version -func (s *ScalewayAPI) DeleteMarketPlaceImageVersion(uuidImage, uuidVersion string) error { +func (s *API) DeleteMarketPlaceImageVersion(uuidImage, uuidVersion string) error { resp, err := s.DeleteResponse(MarketplaceAPI, fmt.Sprintf("images/%v/versions/%v", uuidImage, uuidVersion)) if err != nil { return err @@ -458,7 +458,7 @@ func (s *ScalewayAPI) DeleteMarketPlaceImageVersion(uuidImage, uuidVersion strin } // DeleteMarketPlaceLocalImage deletes local image -func (s *ScalewayAPI) DeleteMarketPlaceLocalImage(uuidImage, uuidVersion, uuidLocalImage string) error { +func (s *API) DeleteMarketPlaceLocalImage(uuidImage, uuidVersion, uuidLocalImage string) error { resp, err := s.DeleteResponse(MarketplaceAPI, fmt.Sprintf("images/%v/versions/%s/local_images/%v", uuidImage, uuidVersion, uuidLocalImage)) if err != nil { return err diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/ip.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/ip.go similarity index 59% rename from vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/ip.go rename to vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/ip.go index cd746453c..04d1dd020 100644 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/ip.go +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/ip.go @@ -7,15 +7,15 @@ import ( "net/url" ) -// ScalewayIPV6Definition represents a Scaleway ipv6 -type ScalewayIPV6Definition struct { +// IPV6 represents a ipv6 +type IPV6 struct { Netmask string `json:"netmask"` Gateway string `json:"gateway"` Address string `json:"address"` } -// ScalewayIPDefinition represents the IP's fields -type ScalewayIPDefinition struct { +// IPV4 represents the IPs fields +type IPV4 struct { Organization string `json:"organization"` Reverse *string `json:"reverse"` ID string `json:"id"` @@ -26,8 +26,8 @@ type ScalewayIPDefinition struct { Address string `json:"address"` } -// ScalewayIPAddress represents a Scaleway IP address -type ScalewayIPAddress struct { +// IPAddress represents a IP address +type IPAddress struct { // Identifier is a unique identifier for the IP address Identifier string `json:"id,omitempty"` @@ -38,18 +38,18 @@ type ScalewayIPAddress struct { Dynamic *bool `json:"dynamic,omitempty"` } -// ScalewayGetIPS represents the response of a GET /ips/ -type ScalewayGetIPS struct { - IPS []ScalewayIPDefinition `json:"ips"` +// GetIPS represents the response of a GET /ips/ +type GetIPS struct { + IPS []IPV4 `json:"ips"` } -// ScalewayGetIP represents the response of a GET /ips/{id_ip} -type ScalewayGetIP struct { - IP ScalewayIPDefinition `json:"ip"` +// GetIP represents the response of a GET /ips/{id_ip} +type GetIP struct { + IP IPV4 `json:"ip"` } -// GetIP returns a ScalewayGetIP -func (s *ScalewayAPI) GetIP(ipID string) (*ScalewayGetIP, error) { +// GetIP returns a GetIP +func (s *API) GetIP(ipID string) (*IPV4, error) { resp, err := s.GetResponsePaginate(s.computeAPI, fmt.Sprintf("ips/%s", ipID), url.Values{}) if err != nil { return nil, err @@ -60,16 +60,59 @@ func (s *ScalewayAPI) GetIP(ipID string) (*ScalewayGetIP, error) { if err != nil { return nil, err } - var ip ScalewayGetIP + var ip GetIP if err = json.Unmarshal(body, &ip); err != nil { return nil, err } - return &ip, nil + return &ip.IP, nil } -// GetIPS returns a ScalewayGetIPS -func (s *ScalewayAPI) GetIPS() (*ScalewayGetIPS, error) { +type UpdateIPRequest struct { + ID string + Reverse string +} + +func (s *API) UpdateIP(req UpdateIPRequest) (*IPV4, error) { + var update struct { + Address string `json:"address"` + ID string `json:"id"` + Reverse *string `json:"reverse"` + Organization string `json:"organization"` + Server *string `json:"server"` + } + + ip, err := s.GetIP(req.ID) + if err != nil { + return nil, err + } + update.Address = ip.Address + update.ID = ip.ID + update.Organization = ip.Organization + update.Server = nil + if ip.Server != nil { + update.Server = &ip.Server.Identifier + } + update.Reverse = nil + if req.Reverse != "" { + update.Reverse = &req.Reverse + } + resp, err := s.PutResponse(s.computeAPI, fmt.Sprintf("ips/%s", req.ID), update) + if err != nil { + return nil, err + } + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + var data GetIP + + if err = json.Unmarshal(body, &data); err != nil { + return nil, err + } + return &data.IP, nil +} + +// GetIPS returns a GetIPS +func (s *API) GetIPS() ([]IPV4, error) { resp, err := s.GetResponsePaginate(s.computeAPI, "ips", url.Values{}) if err != nil { return nil, err @@ -80,16 +123,16 @@ func (s *ScalewayAPI) GetIPS() (*ScalewayGetIPS, error) { if err != nil { return nil, err } - var ips ScalewayGetIPS + var ips GetIPS if err = json.Unmarshal(body, &ips); err != nil { return nil, err } - return &ips, nil + return ips.IPS, nil } -// NewIP returns a new IP -func (s *ScalewayAPI) NewIP() (*ScalewayGetIP, error) { +// CreateIP returns a new IP +func (s *API) CreateIP() (*IPV4, error) { var orga struct { Organization string `json:"organization"` } @@ -104,16 +147,16 @@ func (s *ScalewayAPI) NewIP() (*ScalewayGetIP, error) { if err != nil { return nil, err } - var ip ScalewayGetIP + var ip GetIP if err = json.Unmarshal(body, &ip); err != nil { return nil, err } - return &ip, nil + return &ip.IP, nil } // AttachIP attachs an IP to a server -func (s *ScalewayAPI) AttachIP(ipID, serverID string) error { +func (s *API) AttachIP(ipID, serverID string) error { var update struct { Address string `json:"address"` ID string `json:"id"` @@ -126,9 +169,9 @@ func (s *ScalewayAPI) AttachIP(ipID, serverID string) error { if err != nil { return err } - update.Address = ip.IP.Address - update.ID = ip.IP.ID - update.Organization = ip.IP.Organization + update.Address = ip.Address + update.ID = ip.ID + update.Organization = ip.Organization update.Server = serverID resp, err := s.PutResponse(s.computeAPI, fmt.Sprintf("ips/%s", ipID), update) if err != nil { @@ -139,13 +182,13 @@ func (s *ScalewayAPI) AttachIP(ipID, serverID string) error { } // DetachIP detaches an IP from a server -func (s *ScalewayAPI) DetachIP(ipID string) error { +func (s *API) DetachIP(ipID string) error { ip, err := s.GetIP(ipID) if err != nil { return err } - ip.IP.Server = nil - resp, err := s.PutResponse(s.computeAPI, fmt.Sprintf("ips/%s", ipID), ip.IP) + ip.Server = nil + resp, err := s.PutResponse(s.computeAPI, fmt.Sprintf("ips/%s", ipID), ip) if err != nil { return err } @@ -155,7 +198,7 @@ func (s *ScalewayAPI) DetachIP(ipID string) error { } // DeleteIP deletes an IP -func (s *ScalewayAPI) DeleteIP(ipID string) error { +func (s *API) DeleteIP(ipID string) error { resp, err := s.DeleteResponse(s.computeAPI, fmt.Sprintf("ips/%s", ipID)) if err != nil { return err diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/organization.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/organization.go new file mode 100644 index 000000000..7110edb59 --- /dev/null +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/organization.go @@ -0,0 +1,39 @@ +package api + +import ( + "encoding/json" + "net/http" + "net/url" +) + +// Organization represents a Organization +type Organization struct { + ID string `json:"id"` + Name string `json:"name"` + Users []User `json:"users"` +} + +// organizationsDefinition represents a Organizations +type organizationsDefinition struct { + Organizations []Organization `json:"organizations"` +} + +// GetOrganization returns Organization +func (s *API) GetOrganization() ([]Organization, error) { + resp, err := s.GetResponsePaginate(AccountAPI, "organizations", url.Values{}) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var data organizationsDefinition + + if err = json.Unmarshal(body, &data); err != nil { + return nil, err + } + return data.Organizations, nil +} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/permissions.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/permissions.go new file mode 100644 index 000000000..5e493ef69 --- /dev/null +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/permissions.go @@ -0,0 +1,39 @@ +package api + +import ( + "encoding/json" + "fmt" + "net/http" + "net/url" +) + +// Permissions represents the response of GET /permissions +type Permissions map[string]PermCategory + +// PermCategory represents Permissions's fields +type PermCategory map[string][]string + +// permissions represents the permissions +type permissionsResponse struct { + Permissions Permissions `json:"permissions"` +} + +// GetPermissions returns the permissions +func (s *API) GetPermissions() (Permissions, error) { + resp, err := s.GetResponsePaginate(AccountAPI, fmt.Sprintf("tokens/%s/permissions", s.Token), url.Values{}) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var permissions permissionsResponse + + if err = json.Unmarshal(body, &permissions); err != nil { + return nil, err + } + return permissions.Permissions, nil +} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/quota.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/quota.go similarity index 51% rename from vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/quota.go rename to vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/quota.go index a83023670..0ee7cff00 100644 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/quota.go +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/quota.go @@ -7,16 +7,16 @@ import ( "net/url" ) -// ScalewayQuota represents a map of quota (name, value) -type ScalewayQuota map[string]int +// Quota represents a map of quota (name, value) +type Quotas map[string]int -// ScalewayGetQuotas represents the response of GET /organizations/{orga_id}/quotas -type ScalewayGetQuotas struct { - Quotas ScalewayQuota `json:"quotas"` +// GetQuotas represents the response of GET /organizations/{orga_id}/quotas +type GetQuotas struct { + Quotas Quotas `json:"quotas"` } -// GetQuotas returns a ScalewayGetQuotas -func (s *ScalewayAPI) GetQuotas() (*ScalewayGetQuotas, error) { +// GetQuotas returns a GetQuotas +func (s *API) GetQuotas() (Quotas, error) { resp, err := s.GetResponsePaginate(AccountAPI, fmt.Sprintf("organizations/%s/quotas", s.Organization), url.Values{}) if err != nil { return nil, err @@ -27,10 +27,10 @@ func (s *ScalewayAPI) GetQuotas() (*ScalewayGetQuotas, error) { if err != nil { return nil, err } - var quotas ScalewayGetQuotas + var quotas GetQuotas if err = json.Unmarshal(body, "as); err != nil { return nil, err } - return "as, nil + return quotas.Quotas, nil } diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/security_group.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/security_group.go new file mode 100644 index 000000000..d0bdb6dc0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/security_group.go @@ -0,0 +1,146 @@ +package api + +import ( + "encoding/json" + "fmt" + "net/http" + "net/url" +) + +// SecurityGroup definition +type SecurityGroup struct { + Description string `json:"description"` + ID string `json:"id"` + Organization string `json:"organization"` + Name string `json:"name"` + Servers []ServerRef `json:"servers"` + EnableDefaultSecurity bool `json:"enable_default_security"` + OrganizationDefault bool `json:"organization_default"` +} + +type SecurityGroupRef struct { + Identifier string `json:"id,omitempty"` + Name string `json:"name,omitempty"` +} + +type ServerRef struct { + Identifier string `json:"id,omitempty"` + Name string `json:"name,omitempty"` +} + +// getSecurityGroups represents the response of a GET /security_groups/ +type getSecurityGroups struct { + SecurityGroups []SecurityGroup `json:"security_groups"` +} + +// getSecurityGroup represents the response of a GET /security_groups/{groupID} +type getSecurityGroup struct { + SecurityGroup SecurityGroup `json:"security_group"` +} + +// NewSecurityGroup definition POST request /security_groups +type NewSecurityGroup struct { + Organization string `json:"organization"` + Name string `json:"name"` + Description string `json:"description"` + EnableDefaultSecurity bool `json:"enable_default_security"` +} + +// UpdateSecurityGroup definition PUT request /security_groups +type UpdateSecurityGroup struct { + Organization string `json:"organization"` + Name string `json:"name"` + Description string `json:"description"` + OrganizationDefault bool `json:"organization_default"` +} + +// DeleteSecurityGroup deletes a SecurityGroup +func (s *API) DeleteSecurityGroup(securityGroupID string) error { + resp, err := s.DeleteResponse(s.computeAPI, fmt.Sprintf("security_groups/%s", securityGroupID)) + if err != nil { + return err + } + defer resp.Body.Close() + + _, err = s.handleHTTPError([]int{http.StatusNoContent}, resp) + return err +} + +// UpdateSecurityGroup updates a SecurityGroup +func (s *API) UpdateSecurityGroup(group UpdateSecurityGroup, securityGroupID string) (*SecurityGroup, error) { + resp, err := s.PutResponse(s.computeAPI, fmt.Sprintf("security_groups/%s", securityGroupID), group) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var data getSecurityGroup + if err = json.Unmarshal(body, &data); err != nil { + return nil, err + } + return &data.SecurityGroup, err +} + +// GetSecurityGroup returns a SecurityGroup +func (s *API) GetSecurityGroup(groupsID string) (*SecurityGroup, error) { + resp, err := s.GetResponsePaginate(s.computeAPI, fmt.Sprintf("security_groups/%s", groupsID), url.Values{}) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var securityGroups getSecurityGroup + + if err = json.Unmarshal(body, &securityGroups); err != nil { + return nil, err + } + return &securityGroups.SecurityGroup, nil +} + +// CreateSecurityGroup posts a group on a server +func (s *API) CreateSecurityGroup(group NewSecurityGroup) (*SecurityGroup, error) { + resp, err := s.PostResponse(s.computeAPI, "security_groups", group) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusCreated}, resp) + if err != nil { + return nil, err + } + var securityGroups getSecurityGroup + + if err = json.Unmarshal(body, &securityGroups); err != nil { + return nil, err + } + return &securityGroups.SecurityGroup, nil +} + +// GetSecurityGroups returns a SecurityGroups +func (s *API) GetSecurityGroups() ([]SecurityGroup, error) { + resp, err := s.GetResponsePaginate(s.computeAPI, "security_groups", url.Values{}) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var securityGroups getSecurityGroups + + if err = json.Unmarshal(body, &securityGroups); err != nil { + return nil, err + } + return securityGroups.SecurityGroups, nil +} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/security_group_rule.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/security_group_rule.go new file mode 100644 index 000000000..492e3cefe --- /dev/null +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/security_group_rule.go @@ -0,0 +1,140 @@ +package api + +import ( + "encoding/json" + "fmt" + "net/http" + "net/url" +) + +// SecurityGroupRule definition +type SecurityGroupRule struct { + Direction string `json:"direction"` + Protocol string `json:"protocol"` + IPRange string `json:"ip_range"` + DestPortFrom int `json:"dest_port_from,omitempty"` + Action string `json:"action"` + Position int `json:"position"` + DestPortTo string `json:"dest_port_to"` + Editable bool `json:"editable"` + ID string `json:"id"` +} + +// getSecurityGroupRules represents the response of a GET /_group/{groupID}/rules +type getSecurityGroupRules struct { + Rules []SecurityGroupRule `json:"rules"` +} + +// getSecurityGroupRule represents the response of a GET /_group/{groupID}/rules/{ruleID} +type getSecurityGroupRule struct { + Rules SecurityGroupRule `json:"rule"` +} + +// NewSecurityGroupRule definition POST/PUT request /_group/{groupID} +type NewSecurityGroupRule struct { + Action string `json:"action"` + Direction string `json:"direction"` + IPRange string `json:"ip_range"` + Protocol string `json:"protocol"` + DestPortFrom int `json:"dest_port_from,omitempty"` +} + +// UpdateSecurityGroupRule definition POST/PUT request /_group/{groupID} +type UpdateSecurityGroupRule struct { + Action string `json:"action"` + Direction string `json:"direction"` + IPRange string `json:"ip_range"` + Protocol string `json:"protocol"` + Position int `json:"position"` + DestPortFrom int `json:"dest_port_from,omitempty"` +} + +// GetSecurityGroupRules returns a GroupRules +func (s *API) GetSecurityGroupRules(groupID string) ([]SecurityGroupRule, error) { + resp, err := s.GetResponsePaginate(s.computeAPI, fmt.Sprintf("security_groups/%s/rules", groupID), url.Values{}) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var data getSecurityGroupRules + + if err = json.Unmarshal(body, &data); err != nil { + return nil, err + } + return data.Rules, nil +} + +// GetASecurityGroupRule returns a SecurityGroupRule +func (s *API) GetSecurityGroupRule(groupID string, rulesID string) (*SecurityGroupRule, error) { + resp, err := s.GetResponsePaginate(s.computeAPI, fmt.Sprintf("security_groups/%s/rules/%s", groupID, rulesID), url.Values{}) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var data getSecurityGroupRule + + if err = json.Unmarshal(body, &data); err != nil { + return nil, err + } + return &data.Rules, nil +} + +type postGroupRuleResponse struct { + SecurityGroupRule SecurityGroupRule `json:"rule"` +} + +// CreateSecurityGroupRule posts a rule on a server +func (s *API) CreateSecurityGroupRule(GroupID string, rules NewSecurityGroupRule) (*SecurityGroupRule, error) { + resp, err := s.PostResponse(s.computeAPI, fmt.Sprintf("security_groups/%s/rules", GroupID), rules) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + data, err := s.handleHTTPError([]int{http.StatusCreated}, resp) + if err != nil { + return nil, err + } + var res postGroupRuleResponse + err = json.Unmarshal(data, &res) + return &res.SecurityGroupRule, err +} + +// UpdateSecurityGroupRule updates a SecurityGroupRule +func (s *API) UpdateSecurityGroupRule(rules UpdateSecurityGroupRule, GroupID, RuleID string) (*SecurityGroupRule, error) { + resp, err := s.PutResponse(s.computeAPI, fmt.Sprintf("security_groups/%s/rules/%s", GroupID, RuleID), rules) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var res postGroupRuleResponse + err = json.Unmarshal(body, &res) + return &res.SecurityGroupRule, err +} + +// DeleteSecurityGroupRule deletes a SecurityGroupRule +func (s *API) DeleteSecurityGroupRule(GroupID, RuleID string) error { + resp, err := s.DeleteResponse(s.computeAPI, fmt.Sprintf("security_groups/%s/rules/%s", GroupID, RuleID)) + if err != nil { + return err + } + defer resp.Body.Close() + + _, err = s.handleHTTPError([]int{http.StatusNoContent}, resp) + return err +} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/server.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/server.go similarity index 55% rename from vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/server.go rename to vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/server.go index 53fa6b452..6e76dfa85 100644 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/server.go +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/server.go @@ -6,12 +6,10 @@ import ( "net/http" "net/url" "time" - - "golang.org/x/sync/errgroup" ) -// ScalewayServer represents a Scaleway server -type ScalewayServer struct { +// Server represents a server +type Server struct { // Arch is the architecture target of the server Arch string `json:"arch,omitempty"` @@ -28,13 +26,13 @@ type ScalewayServer struct { ModificationDate string `json:"modification_date,omitempty"` // Image is the image used by the server - Image ScalewayImage `json:"image,omitempty"` + Image Image `json:"image,omitempty"` // DynamicIPRequired is a flag that defines a server with a dynamic ip address attached DynamicIPRequired *bool `json:"dynamic_ip_required,omitempty"` // PublicIP is the public IP address bound to the server - PublicAddress ScalewayIPAddress `json:"public_ip,omitempty"` + PublicAddress IPAddress `json:"public_ip,omitempty"` // State is the current status of the server State string `json:"state,omitempty"` @@ -46,7 +44,10 @@ type ScalewayServer struct { PrivateIP string `json:"private_ip,omitempty"` // Bootscript is the unique identifier of the selected bootscript - Bootscript *ScalewayBootscript `json:"bootscript,omitempty"` + Bootscript *Bootscript `json:"bootscript,omitempty"` + + // BootType defines the type of boot. Can be local or bootscript + BootType string `json:"boot_type,omitempty"` // Hostname represents the ServerName in a format compatible with unix's hostname Hostname string `json:"hostname,omitempty"` @@ -55,10 +56,10 @@ type ScalewayServer struct { Tags []string `json:"tags,omitempty"` // Volumes are the attached volumes - Volumes map[string]ScalewayVolume `json:"volumes,omitempty"` + Volumes map[string]Volume `json:"volumes,omitempty"` // SecurityGroup is the selected security group object - SecurityGroup ScalewaySecurityGroup `json:"security_group,omitempty"` + SecurityGroup SecurityGroupRef `json:"security_group,omitempty"` // Organization is the owner of the server Organization string `json:"organization,omitempty"` @@ -77,7 +78,7 @@ type ScalewayServer struct { ZoneID string `json:"zone_id,omitempty"` } `json:"location,omitempty"` - IPV6 *ScalewayIPV6Definition `json:"ipv6,omitempty"` + IPV6 *IPV6 `json:"ipv6,omitempty"` EnableIPV6 bool `json:"enable_ipv6,omitempty"` @@ -86,30 +87,30 @@ type ScalewayServer struct { DNSPrivate string `json:"dns_private,omitempty"` } -// ScalewayServerPatchDefinition represents a Scaleway server with nullable fields (for PATCH) -type ScalewayServerPatchDefinition struct { - Arch *string `json:"arch,omitempty"` - Name *string `json:"name,omitempty"` - CreationDate *string `json:"creation_date,omitempty"` - ModificationDate *string `json:"modification_date,omitempty"` - Image *ScalewayImage `json:"image,omitempty"` - DynamicIPRequired *bool `json:"dynamic_ip_required,omitempty"` - PublicAddress *ScalewayIPAddress `json:"public_ip,omitempty"` - State *string `json:"state,omitempty"` - StateDetail *string `json:"state_detail,omitempty"` - PrivateIP *string `json:"private_ip,omitempty"` - Bootscript *string `json:"bootscript,omitempty"` - Hostname *string `json:"hostname,omitempty"` - Volumes *map[string]ScalewayVolume `json:"volumes,omitempty"` - SecurityGroup *ScalewaySecurityGroup `json:"security_group,omitempty"` - Organization *string `json:"organization,omitempty"` - Tags *[]string `json:"tags,omitempty"` - IPV6 *ScalewayIPV6Definition `json:"ipv6,omitempty"` - EnableIPV6 *bool `json:"enable_ipv6,omitempty"` +// ServerPatchDefinition represents a server with nullable fields (for PATCH) +type ServerPatchDefinition struct { + Arch *string `json:"arch,omitempty"` + Name *string `json:"name,omitempty"` + CreationDate *string `json:"creation_date,omitempty"` + ModificationDate *string `json:"modification_date,omitempty"` + Image *Image `json:"image,omitempty"` + DynamicIPRequired *bool `json:"dynamic_ip_required,omitempty"` + PublicAddress *IPAddress `json:"public_ip,omitempty"` + State *string `json:"state,omitempty"` + StateDetail *string `json:"state_detail,omitempty"` + PrivateIP *string `json:"private_ip,omitempty"` + Bootscript *string `json:"bootscript,omitempty"` + Hostname *string `json:"hostname,omitempty"` + Volumes *map[string]Volume `json:"volumes,omitempty"` + SecurityGroup *SecurityGroupRef `json:"security_group,omitempty"` + Organization *string `json:"organization,omitempty"` + Tags *[]string `json:"tags,omitempty"` + IPV6 *IPV6 `json:"ipv6,omitempty"` + EnableIPV6 *bool `json:"enable_ipv6,omitempty"` } -// ScalewayServerDefinition represents a Scaleway server with image definition -type ScalewayServerDefinition struct { +// ServerDefinition represents a server with image definition +type ServerDefinition struct { // Name is the user-defined name of the server Name string `json:"name"` @@ -134,6 +135,9 @@ type ScalewayServerDefinition struct { // CommercialType is the commercial type of the server (i.e: C1, C2[SML], VC1S) CommercialType string `json:"commercial_type"` + // BootType defines the type of boot. Can be local or bootscript + BootType string `json:"boot_type,omitempty"` + PublicIP string `json:"public_ip,omitempty"` EnableIPV6 bool `json:"enable_ipv6,omitempty"` @@ -141,25 +145,25 @@ type ScalewayServerDefinition struct { SecurityGroup string `json:"security_group,omitempty"` } -// ScalewayServers represents a group of Scaleway servers -type ScalewayServers struct { - // Servers holds scaleway servers of the response - Servers []ScalewayServer `json:"servers,omitempty"` +// Servers represents a group of servers +type Servers struct { + // Servers holds servers of the response + Servers []Server `json:"servers,omitempty"` } -// ScalewayServerAction represents an action to perform on a Scaleway server -type ScalewayServerAction struct { +// ServerAction represents an action to perform on a server +type ServerAction struct { // Action is the name of the action to trigger Action string `json:"action,omitempty"` } -// ScalewayOneServer represents the response of a GET /servers/UUID API call -type ScalewayOneServer struct { - Server ScalewayServer `json:"server,omitempty"` +// OneServer represents the response of a GET /servers/UUID API call +type OneServer struct { + Server Server `json:"server,omitempty"` } // PatchServer updates a server -func (s *ScalewayAPI) PatchServer(serverID string, definition ScalewayServerPatchDefinition) error { +func (s *API) PatchServer(serverID string, definition ServerPatchDefinition) error { resp, err := s.PatchResponse(s.computeAPI, fmt.Sprintf("servers/%s", serverID), definition) if err != nil { return err @@ -172,67 +176,50 @@ func (s *ScalewayAPI) PatchServer(serverID string, definition ScalewayServerPatc return nil } -// GetServers gets the list of servers from the ScalewayAPI -func (s *ScalewayAPI) GetServers(all bool, limit int) (*[]ScalewayServer, error) { +// GetServers gets the list of servers from the API +func (s *API) GetServers(all bool, limit int) ([]Server, error) { query := url.Values{} if !all { query.Set("state", "running") } + // TODO per_page=20&page=2&state=running if limit > 0 { // FIXME: wait for the API to be ready // query.Set("per_page", strconv.Itoa(limit)) panic("Not implemented yet") } - var ( - g errgroup.Group - apis = []string{ - ComputeAPIPar1, - ComputeAPIAms1, - } - ) - - serverChan := make(chan ScalewayServers, 2) - for _, api := range apis { - g.Go(s.fetchServers(api, query, serverChan)) - } - - if err := g.Wait(); err != nil { + servers, err := s.fetchServers(query) + if err != nil { return nil, err } - close(serverChan) - var servers ScalewayServers - - for server := range serverChan { - servers.Servers = append(servers.Servers, server.Servers...) - } for i, server := range servers.Servers { servers.Servers[i].DNSPublic = server.Identifier + URLPublicDNS servers.Servers[i].DNSPrivate = server.Identifier + URLPrivateDNS } - return &servers.Servers, nil + return servers.Servers, nil } -// ScalewaySortServers represents a wrapper to sort by CreationDate the servers -type ScalewaySortServers []ScalewayServer +// SortServers represents a wrapper to sort by CreationDate the servers +type SortServers []Server -func (s ScalewaySortServers) Len() int { +func (s SortServers) Len() int { return len(s) } -func (s ScalewaySortServers) Swap(i, j int) { +func (s SortServers) Swap(i, j int) { s[i], s[j] = s[j], s[i] } -func (s ScalewaySortServers) Less(i, j int) bool { +func (s SortServers) Less(i, j int) bool { date1, _ := time.Parse("2006-01-02T15:04:05.000000+00:00", s[i].CreationDate) date2, _ := time.Parse("2006-01-02T15:04:05.000000+00:00", s[j].CreationDate) return date2.Before(date1) } -// GetServer gets a server from the ScalewayAPI -func (s *ScalewayAPI) GetServer(serverID string) (*ScalewayServer, error) { +// GetServer gets a server from the API +func (s *API) GetServer(serverID string) (*Server, error) { if serverID == "" { return nil, fmt.Errorf("cannot get server without serverID") } @@ -247,7 +234,7 @@ func (s *ScalewayAPI) GetServer(serverID string) (*ScalewayServer, error) { return nil, err } - var oneServer ScalewayOneServer + var oneServer OneServer if err = json.Unmarshal(body, &oneServer); err != nil { return nil, err @@ -259,44 +246,49 @@ func (s *ScalewayAPI) GetServer(serverID string) (*ScalewayServer, error) { } // PostServerAction posts an action on a server -func (s *ScalewayAPI) PostServerAction(serverID, action string) error { - data := ScalewayServerAction{ +func (s *API) PostServerAction(serverID, action string) (*Task, error) { + data := ServerAction{ Action: action, } resp, err := s.PostResponse(s.computeAPI, fmt.Sprintf("servers/%s/action", serverID), data) if err != nil { - return err + return nil, err } defer resp.Body.Close() - _, err = s.handleHTTPError([]int{http.StatusAccepted}, resp) - return err + body, err := s.handleHTTPError([]int{http.StatusAccepted}, resp) + if err != nil { + return nil, err + } + + var t oneTask + if err = json.Unmarshal(body, &t); err != nil { + return nil, err + } + return &t.Task, err } -func (s *ScalewayAPI) fetchServers(api string, query url.Values, out chan<- ScalewayServers) func() error { - return func() error { - resp, err := s.GetResponsePaginate(api, "servers", query) - if err != nil { - return err - } - defer resp.Body.Close() - - body, err := s.handleHTTPError([]int{http.StatusOK}, resp) - if err != nil { - return err - } - var servers ScalewayServers - - if err = json.Unmarshal(body, &servers); err != nil { - return err - } - out <- servers - return nil +func (s *API) fetchServers(query url.Values) (*Servers, error) { + resp, err := s.GetResponsePaginate(s.computeAPI, "servers", query) + if err != nil { + return nil, err } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var servers Servers + + if err = json.Unmarshal(body, &servers); err != nil { + return nil, err + } + return &servers, nil } // DeleteServer deletes a server -func (s *ScalewayAPI) DeleteServer(serverID string) error { +func (s *API) DeleteServer(serverID string) error { resp, err := s.DeleteResponse(s.computeAPI, fmt.Sprintf("servers/%s", serverID)) if err != nil { return err @@ -309,24 +301,24 @@ func (s *ScalewayAPI) DeleteServer(serverID string) error { return nil } -// PostServer creates a new server -func (s *ScalewayAPI) PostServer(definition ScalewayServerDefinition) (string, error) { +// CreateServer creates a new server +func (s *API) CreateServer(definition ServerDefinition) (*Server, error) { definition.Organization = s.Organization resp, err := s.PostResponse(s.computeAPI, "servers", definition) if err != nil { - return "", err + return nil, err } defer resp.Body.Close() body, err := s.handleHTTPError([]int{http.StatusCreated}, resp) if err != nil { - return "", err + return nil, err } - var server ScalewayOneServer + var data OneServer - if err = json.Unmarshal(body, &server); err != nil { - return "", err + if err = json.Unmarshal(body, &data); err != nil { + return nil, err } - return server.Server.Identifier, nil + return &data.Server, nil } diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/snapshot.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/snapshot.go similarity index 64% rename from vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/snapshot.go rename to vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/snapshot.go index 6148b7d3b..99571eb52 100644 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/snapshot.go +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/snapshot.go @@ -7,15 +7,15 @@ import ( "net/url" ) -// ScalewaySnapshotDefinition represents a Scaleway snapshot definition -type ScalewaySnapshotDefinition struct { +// SnapshotDefinition represents a snapshot definition +type SnapshotDefinition struct { VolumeIDentifier string `json:"volume_id"` Name string `json:"name,omitempty"` Organization string `json:"organization"` } -// ScalewaySnapshot represents a Scaleway Snapshot -type ScalewaySnapshot struct { +// Snapshot represents a Snapshot +type Snapshot struct { // Identifier is a unique identifier for the snapshot Identifier string `json:"id,omitempty"` @@ -41,47 +41,47 @@ type ScalewaySnapshot struct { VolumeType string `json:"volume_type"` // BaseVolume is the volume from which the snapshot inherits - BaseVolume ScalewayVolume `json:"base_volume,omitempty"` + BaseVolume Volume `json:"base_volume,omitempty"` } -// ScalewayOneSnapshot represents the response of a GET /snapshots/UUID API call -type ScalewayOneSnapshot struct { - Snapshot ScalewaySnapshot `json:"snapshot,omitempty"` +// oneSnapshot represents the response of a GET /snapshots/UUID API call +type oneSnapshot struct { + Snapshot Snapshot `json:"snapshot,omitempty"` } -// ScalewaySnapshots represents a group of Scaleway snapshots -type ScalewaySnapshots struct { - // Snapshots holds scaleway snapshots of the response - Snapshots []ScalewaySnapshot `json:"snapshots,omitempty"` +// Snapshots represents a group of snapshots +type Snapshots struct { + // Snapshots holds snapshots of the response + Snapshots []Snapshot `json:"snapshots,omitempty"` } -// PostSnapshot creates a new snapshot -func (s *ScalewayAPI) PostSnapshot(volumeID string, name string) (string, error) { - definition := ScalewaySnapshotDefinition{ +// CreateSnapshot creates a new snapshot +func (s *API) CreateSnapshot(volumeID string, name string) (*Snapshot, error) { + definition := SnapshotDefinition{ VolumeIDentifier: volumeID, Name: name, Organization: s.Organization, } resp, err := s.PostResponse(s.computeAPI, "snapshots", definition) if err != nil { - return "", err + return nil, err } defer resp.Body.Close() body, err := s.handleHTTPError([]int{http.StatusCreated}, resp) if err != nil { - return "", err + return nil, err } - var snapshot ScalewayOneSnapshot + var snapshot oneSnapshot if err = json.Unmarshal(body, &snapshot); err != nil { - return "", err + return nil, err } - return snapshot.Snapshot.Identifier, nil + return &snapshot.Snapshot, nil } // DeleteSnapshot deletes a snapshot -func (s *ScalewayAPI) DeleteSnapshot(snapshotID string) error { +func (s *API) DeleteSnapshot(snapshotID string) error { resp, err := s.DeleteResponse(s.computeAPI, fmt.Sprintf("snapshots/%s", snapshotID)) if err != nil { return err @@ -94,8 +94,8 @@ func (s *ScalewayAPI) DeleteSnapshot(snapshotID string) error { return nil } -// GetSnapshots gets the list of snapshots from the ScalewayAPI -func (s *ScalewayAPI) GetSnapshots() (*[]ScalewaySnapshot, error) { +// GetSnapshots gets the list of snapshots from the API +func (s *API) GetSnapshots() ([]Snapshot, error) { query := url.Values{} resp, err := s.GetResponsePaginate(s.computeAPI, "snapshots", query) @@ -108,16 +108,16 @@ func (s *ScalewayAPI) GetSnapshots() (*[]ScalewaySnapshot, error) { if err != nil { return nil, err } - var snapshots ScalewaySnapshots + var snapshots Snapshots if err = json.Unmarshal(body, &snapshots); err != nil { return nil, err } - return &snapshots.Snapshots, nil + return snapshots.Snapshots, nil } -// GetSnapshot gets a snapshot from the ScalewayAPI -func (s *ScalewayAPI) GetSnapshot(snapshotID string) (*ScalewaySnapshot, error) { +// GetSnapshot gets a snapshot from the API +func (s *API) GetSnapshot(snapshotID string) (*Snapshot, error) { resp, err := s.GetResponsePaginate(s.computeAPI, "snapshots/"+snapshotID, url.Values{}) if err != nil { return nil, err @@ -128,7 +128,7 @@ func (s *ScalewayAPI) GetSnapshot(snapshotID string) (*ScalewaySnapshot, error) if err != nil { return nil, err } - var oneSnapshot ScalewayOneSnapshot + var oneSnapshot oneSnapshot if err = json.Unmarshal(body, &oneSnapshot); err != nil { return nil, err diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/tasks.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/tasks.go new file mode 100644 index 000000000..70b502a07 --- /dev/null +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/tasks.go @@ -0,0 +1,82 @@ +package api + +import ( + "encoding/json" + "fmt" + "net/http" + "net/url" +) + +// Task represents a Task +type Task struct { + // Identifier is a unique identifier for the task + Identifier string `json:"id,omitempty"` + + // StartDate is the start date of the task + StartDate string `json:"started_at,omitempty"` + + // TerminationDate is the termination date of the task + TerminationDate string `json:"terminated_at,omitempty"` + + HrefFrom string `json:"href_from,omitempty"` + + Description string `json:"description,omitempty"` + + Status string `json:"status,omitempty"` + + Progress int `json:"progress,omitempty"` +} + +// oneTask represents the response of a GET /tasks/UUID API call +type oneTask struct { + Task Task `json:"task,omitempty"` +} + +// Tasks represents a group of tasks +type Tasks struct { + // Tasks holds tasks of the response + Tasks []Task `json:"tasks,omitempty"` +} + +// GetTasks get the list of tasks from the API +func (s *API) GetTasks() ([]Task, error) { + query := url.Values{} + // TODO per_page=20&page=2 + resp, err := s.GetResponsePaginate(s.computeAPI, "tasks", query) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var tasks Tasks + + if err = json.Unmarshal(body, &tasks); err != nil { + return nil, err + } + return tasks.Tasks, nil +} + +// GetTask fetches a specific task +func (s *API) GetTask(id string) (*Task, error) { + query := url.Values{} + resp, err := s.GetResponsePaginate(s.computeAPI, fmt.Sprintf("tasks/%s", id), query) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + + var t oneTask + if err = json.Unmarshal(body, &t); err != nil { + return nil, err + } + return &t.Task, nil +} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/tokens.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/tokens.go new file mode 100644 index 000000000..b3dff56bb --- /dev/null +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/tokens.go @@ -0,0 +1,135 @@ +package api + +import ( + "encoding/json" + "fmt" + "net/http" + "net/url" +) + +// Token represents a Token +type Token struct { + UserID string `json:"user_id"` + Description string `json:"description,omitempty"` + Roles Role `json:"roles"` + Expires string `json:"expires"` + InheritsUsersPerms bool `json:"inherits_user_perms"` + ID string `json:"id"` +} + +// Role represents a Token UserId Role +type Role struct { + Organization Organization `json:"organization,omitempty"` + Role string `json:"role,omitempty"` +} + +type getTokenResponse struct { + Token Token `json:"token"` +} + +type getTokensResponse struct { + Tokens []Token `json:"tokens"` +} + +func (s *API) GetTokens() ([]Token, error) { + query := url.Values{} + // TODO per_page=20&page=2 + resp, err := s.GetResponsePaginate(s.computeAPI, "tokens", query) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var token getTokensResponse + + if err = json.Unmarshal(body, &token); err != nil { + return nil, err + } + return token.Tokens, nil +} + +type CreateTokenRequest struct { + Email string `json:"email"` + Password string `json:"password,omitempty"` + Expires bool `json:"expires"` +} + +func (s *API) CreateToken(req *CreateTokenRequest) (*Token, error) { + resp, err := s.PostResponse(AccountAPI, "tokens", req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusCreated}, resp) + if err != nil { + return nil, err + } + var data getTokenResponse + + if err = json.Unmarshal(body, &data); err != nil { + return nil, err + } + return &data.Token, nil +} + +type UpdateTokenRequest struct { + Description string `json:"description,omitempty"` + Expires bool `json:"expires"` + ID string `json:"-"` +} + +func (s *API) UpdateToken(req *UpdateTokenRequest) (*Token, error) { + resp, err := s.PatchResponse(AccountAPI, fmt.Sprintf("tokens/%s", req.ID), req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var data getTokenResponse + + if err = json.Unmarshal(body, &data); err != nil { + return nil, err + } + return &data.Token, nil +} + +func (s *API) GetToken(id string) (*Token, error) { + query := url.Values{} + resp, err := s.GetResponsePaginate(AccountAPI, fmt.Sprintf("tokens/%s", id), query) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var data getTokenResponse + + if err = json.Unmarshal(body, &data); err != nil { + return nil, err + } + return &data.Token, nil +} + +func (s *API) DeleteToken(id string) error { + resp, err := s.DeleteResponse(AccountAPI, fmt.Sprintf("tokens/%s", id)) + if err != nil { + return err + } + + if _, err = s.handleHTTPError([]int{http.StatusNoContent}, resp); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/user.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/user.go new file mode 100644 index 000000000..5c07cdbcd --- /dev/null +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/user.go @@ -0,0 +1,101 @@ +package api + +import ( + "encoding/json" + "fmt" + "net/http" + "net/url" +) + +// User represents a User +type User struct { + Email string `json:"email"` + Firstname string `json:"firstname"` + Fullname string `json:"fullname"` + ID string `json:"id"` + Lastname string `json:"lastname"` + Organizations []Organization `json:"organizations"` + Roles []Role `json:"roles"` + SSHPublicKeys []KeyDefinition `json:"ssh_public_keys"` +} + +// KeyDefinition represents a key +type KeyDefinition struct { + Key string `json:"key"` + Fingerprint string `json:"fingerprint,omitempty"` +} + +// UsersDefinition represents the response of a GET /user +type UsersDefinition struct { + User User `json:"user"` +} + +// UserPatchSSHKeyDefinition represents a User Patch +type UserPatchSSHKeyDefinition struct { + SSHPublicKeys []KeyDefinition `json:"ssh_public_keys"` +} + +// PatchUserSSHKey updates a user +func (s *API) PatchUserSSHKey(UserID string, definition UserPatchSSHKeyDefinition) (*User, error) { + resp, err := s.PatchResponse(AccountAPI, fmt.Sprintf("users/%s", UserID), definition) + if err != nil { + return nil, err + } + + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var user UsersDefinition + + if err = json.Unmarshal(body, &user); err != nil { + return nil, err + } + return &user.User, nil +} + +// GetUserID returns the userID +func (s *API) GetUserID() (string, error) { + resp, err := s.GetResponsePaginate(AccountAPI, fmt.Sprintf("tokens/%s", s.Token), url.Values{}) + if err != nil { + return "", err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return "", err + } + var token getTokenResponse + + if err = json.Unmarshal(body, &token); err != nil { + return "", err + } + return token.Token.UserID, nil +} + +// GetUser returns the user +func (s *API) GetUser() (*User, error) { + userID, err := s.GetUserID() + if err != nil { + return nil, err + } + resp, err := s.GetResponsePaginate(AccountAPI, fmt.Sprintf("users/%s", userID), url.Values{}) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var user UsersDefinition + + if err = json.Unmarshal(body, &user); err != nil { + return nil, err + } + return &user.User, nil +} diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/user_data.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/user_data.go similarity index 79% rename from vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/user_data.go rename to vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/user_data.go index c404959ba..61608b8db 100644 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/user_data.go +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/user_data.go @@ -10,16 +10,16 @@ import ( "strings" ) -// ScalewayUserdatas represents the response of a GET /user_data -type ScalewayUserdatas struct { +// Userdatas represents the response of a GET /user_data +type Userdatas struct { UserData []string `json:"user_data"` } -// ScalewayUserdata represents []byte -type ScalewayUserdata []byte +// Userdata represents []byte +type Userdata []byte // GetUserdatas gets list of userdata for a server -func (s *ScalewayAPI) GetUserdatas(serverID string, metadata bool) (*ScalewayUserdatas, error) { +func (s *API) GetUserdatas(serverID string, metadata bool) (*Userdatas, error) { var uri, endpoint string endpoint = s.computeAPI @@ -40,7 +40,7 @@ func (s *ScalewayAPI) GetUserdatas(serverID string, metadata bool) (*ScalewayUse if err != nil { return nil, err } - var userdatas ScalewayUserdatas + var userdatas Userdatas if err = json.Unmarshal(body, &userdatas); err != nil { return nil, err @@ -48,12 +48,12 @@ func (s *ScalewayAPI) GetUserdatas(serverID string, metadata bool) (*ScalewayUse return &userdatas, nil } -func (s *ScalewayUserdata) String() string { +func (s *Userdata) String() string { return string(*s) } // GetUserdata gets a specific userdata for a server -func (s *ScalewayAPI) GetUserdata(serverID, key string, metadata bool) (*ScalewayUserdata, error) { +func (s *API) GetUserdata(serverID, key string, metadata bool) (*Userdata, error) { var uri, endpoint string endpoint = s.computeAPI @@ -74,13 +74,13 @@ func (s *ScalewayAPI) GetUserdata(serverID, key string, metadata bool) (*Scalewa if resp.StatusCode != http.StatusOK { return nil, fmt.Errorf("no such user_data %q (%d)", key, resp.StatusCode) } - var data ScalewayUserdata + var data Userdata data, err = ioutil.ReadAll(resp.Body) return &data, err } // PatchUserdata sets a user data -func (s *ScalewayAPI) PatchUserdata(serverID, key string, value []byte, metadata bool) error { +func (s *API) PatchUserdata(serverID, key string, value []byte, metadata bool) error { var resource, endpoint string endpoint = s.computeAPI @@ -104,7 +104,7 @@ func (s *ScalewayAPI) PatchUserdata(serverID, key string, value []byte, metadata req.Header.Set("Content-Type", "text/plain") req.Header.Set("User-Agent", s.userAgent) - resp, err := s.client.Do(req) + resp, err := s.Client.Do(req) if err != nil { return err } @@ -118,7 +118,7 @@ func (s *ScalewayAPI) PatchUserdata(serverID, key string, value []byte, metadata } // DeleteUserdata deletes a server user_data -func (s *ScalewayAPI) DeleteUserdata(serverID, key string, metadata bool) error { +func (s *API) DeleteUserdata(serverID, key string, metadata bool) error { var url, endpoint string endpoint = s.computeAPI diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/volume.go b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/volume.go similarity index 72% rename from vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/volume.go rename to vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/volume.go index e7b1adc9f..e4284cce5 100644 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/api/volume.go +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/github.com/nicolai86/scaleway-sdk/volume.go @@ -7,8 +7,8 @@ import ( "net/url" ) -// ScalewayVolume represents a Scaleway Volume -type ScalewayVolume struct { +// Volume represents a Volume +type Volume struct { // Identifier is a unique identifier for the volume Identifier string `json:"id,omitempty"` @@ -33,7 +33,7 @@ type ScalewayVolume struct { Name string `json:"name,omitempty"` } `json:"server,omitempty"` - // VolumeType is a Scaleway identifier for the kind of volume (default: l_ssd) + // VolumeType is a identifier for the kind of volume (default: l_ssd) VolumeType string `json:"volume_type,omitempty"` // ExportURI represents the url used by initrd/scripts to attach the volume @@ -41,11 +41,11 @@ type ScalewayVolume struct { } type volumeResponse struct { - Volume ScalewayVolume `json:"volume,omitempty"` + Volume Volume `json:"volume,omitempty"` } -// ScalewayVolumeDefinition represents a Scaleway volume definition -type ScalewayVolumeDefinition struct { +// VolumeDefinition represents a volume definition +type VolumeDefinition struct { // Name is the user-defined name of the volume Name string `json:"name"` @@ -59,8 +59,8 @@ type ScalewayVolumeDefinition struct { Organization string `json:"organization"` } -// ScalewayVolumePutDefinition represents a Scaleway volume with nullable fields (for PUT) -type ScalewayVolumePutDefinition struct { +// VolumePutDefinition represents a volume with nullable fields (for PUT) +type VolumePutDefinition struct { Identifier *string `json:"id,omitempty"` Size *uint64 `json:"size,omitempty"` CreationDate *string `json:"creation_date,omitempty"` @@ -75,8 +75,8 @@ type ScalewayVolumePutDefinition struct { ExportURI *string `json:"export_uri,omitempty"` } -// PostVolume creates a new volume -func (s *ScalewayAPI) PostVolume(definition ScalewayVolumeDefinition) (string, error) { +// CreateVolume creates a new volume +func (s *API) CreateVolume(definition VolumeDefinition) (*Volume, error) { definition.Organization = s.Organization if definition.Type == "" { definition.Type = "l_ssd" @@ -84,36 +84,44 @@ func (s *ScalewayAPI) PostVolume(definition ScalewayVolumeDefinition) (string, e resp, err := s.PostResponse(s.computeAPI, "volumes", definition) if err != nil { - return "", err + return nil, err } defer resp.Body.Close() body, err := s.handleHTTPError([]int{http.StatusCreated}, resp) if err != nil { - return "", err + return nil, err } var volume volumeResponse if err = json.Unmarshal(body, &volume); err != nil { - return "", err + return nil, err } - return volume.Volume.Identifier, nil + return &volume.Volume, nil } -// PutVolume updates a volume -func (s *ScalewayAPI) PutVolume(volumeID string, definition ScalewayVolumePutDefinition) error { +// UpdateVolume updates a volume +func (s *API) UpdateVolume(volumeID string, definition VolumePutDefinition) (*Volume, error) { resp, err := s.PutResponse(s.computeAPI, fmt.Sprintf("volumes/%s", volumeID), definition) if err != nil { - return err + return nil, err } defer resp.Body.Close() - _, err = s.handleHTTPError([]int{http.StatusOK}, resp) - return err + body, err := s.handleHTTPError([]int{http.StatusOK}, resp) + if err != nil { + return nil, err + } + var volume volumeResponse + + if err = json.Unmarshal(body, &volume); err != nil { + return nil, err + } + return &volume.Volume, nil } // DeleteVolume deletes a volume -func (s *ScalewayAPI) DeleteVolume(volumeID string) error { +func (s *API) DeleteVolume(volumeID string) error { resp, err := s.DeleteResponse(s.computeAPI, fmt.Sprintf("volumes/%s", volumeID)) if err != nil { return err @@ -127,11 +135,11 @@ func (s *ScalewayAPI) DeleteVolume(volumeID string) error { } type volumesResponse struct { - Volumes []ScalewayVolume `json:"volumes,omitempty"` + Volumes []Volume `json:"volumes,omitempty"` } -// GetVolumes gets the list of volumes from the ScalewayAPI -func (s *ScalewayAPI) GetVolumes() (*[]ScalewayVolume, error) { +// GetVolumes gets the list of volumes from the API +func (s *API) GetVolumes() (*[]Volume, error) { query := url.Values{} resp, err := s.GetResponsePaginate(s.computeAPI, "volumes", query) @@ -153,8 +161,8 @@ func (s *ScalewayAPI) GetVolumes() (*[]ScalewayVolume, error) { return &volumes.Volumes, nil } -// GetVolume gets a volume from the ScalewayAPI -func (s *ScalewayAPI) GetVolume(volumeID string) (*ScalewayVolume, error) { +// GetVolume gets a volume from the API +func (s *API) GetVolume(volumeID string) (*Volume, error) { resp, err := s.GetResponsePaginate(s.computeAPI, "volumes/"+volumeID, url.Values{}) if err != nil { return nil, err @@ -165,11 +173,11 @@ func (s *ScalewayAPI) GetVolume(volumeID string) (*ScalewayVolume, error) { if err != nil { return nil, err } - var oneVolume volumeResponse + var volume volumeResponse - if err = json.Unmarshal(body, &oneVolume); err != nil { + if err = json.Unmarshal(body, &volume); err != nil { return nil, err } // FIXME region, arch, owner, title - return &oneVolume.Volume, nil + return &volume.Volume, nil } diff --git a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/vendor.json b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/vendor.json index 4d3bfab6f..dfe73626d 100644 --- a/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/vendor.json +++ b/vendor/github.com/hashicorp/go-discover/provider/scaleway/vendor/vendor.json @@ -2,7 +2,7 @@ "comment": "", "ignore": "test", "package": [ - {"path":"github.com/nicolai86/scaleway-sdk/api","checksumSHA1":"ROp7ZtwHdxYKpmwycOxbOOXNnzo=","revision":"33df10cad9fff60467a3dcb992d5340c2b9a8046","revisionTime":"2017-09-17T18:57:50Z"}, + {"path":"github.com/nicolai86/scaleway-sdk","checksumSHA1":"w5i5Tximdwrgf2TDbyVr0KmNO9Q=","revision":"798f60e20bb2466bc3d8f36f1cf4f98410e49b6a","revisionTime":"2018-06-28T01:02:48Z"}, {"path":"golang.org/x/net/context","checksumSHA1":"GtamqiJoL7PGHsN454AoffBFMa8=","revision":"c73622c77280266305273cb545f54516ced95b93","revisionTime":"2017-06-11T01:16:46Z"}, {"path":"golang.org/x/sync/errgroup","checksumSHA1":"S0DP7Pn7sZUmXc55IzZnNvERu6s=","revision":"8e0aa688b654ef28caa72506fa5ec8dba9fc7690","revisionTime":"2017-07-19T03:38:01Z"} ], diff --git a/vendor/github.com/hashicorp/go-discover/provider/vsphere/vsphere_discover.go b/vendor/github.com/hashicorp/go-discover/provider/vsphere/vsphere_discover.go index fc719bbfc..00f0e25fc 100644 --- a/vendor/github.com/hashicorp/go-discover/provider/vsphere/vsphere_discover.go +++ b/vendor/github.com/hashicorp/go-discover/provider/vsphere/vsphere_discover.go @@ -45,7 +45,7 @@ func setLog(l *log.Logger) { func discoverErr(format string, a ...interface{}) error { var s string if len(a) > 1 { - s = fmt.Sprintf(format, a) + s = fmt.Sprintf(format, a...) } else { s = format } diff --git a/vendor/vendor.json b/vendor/vendor.json index df2226742..eec5bb2bc 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -60,18 +60,18 @@ {"path":"github.com/hashicorp/errwrap","checksumSHA1":"cdOCt0Yb+hdErz8NAQqayxPmRsY=","revision":"7554cd9344cec97297fa6649b055a8c98c2a1e55","revisionTime":"2014-10-28T05:47:10Z"}, {"path":"github.com/hashicorp/go-checkpoint","checksumSHA1":"D267IUMW2rcb+vNe3QU+xhfSrgY=","revision":"1545e56e46dec3bba264e41fde2c1e2aa65b5dd4","revisionTime":"2017-10-09T17:35:28Z"}, {"path":"github.com/hashicorp/go-cleanhttp","checksumSHA1":"YAq1rqZIp+M74Q+jMBQkkMKm3VM=","revision":"d5fe4b57a186c716b0e00b8c301cbd9b4182694d","revisionTime":"2017-12-18T14:54:08Z"}, - {"path":"github.com/hashicorp/go-discover","checksumSHA1":"OfeOXV6yViJa9mm5NTeQL3TDJXg=","revision":"1b9cec3de1d963ee4354e0151cbcc0a976791be6","revisionTime":"2018-07-18T15:35:10Z"}, - {"path":"github.com/hashicorp/go-discover/provider/aliyun","checksumSHA1":"Jww5zrDwjMoFF31RqBapilTdi18=","revision":"b55bdf9045538dc6f39482d97b128959e8f089a6","revisionTime":"2018-05-04T18:26:03Z","tree":true}, - {"path":"github.com/hashicorp/go-discover/provider/aws","checksumSHA1":"Vit45xRjrJ6h7IGJndrBjodVUAE=","revision":"b55bdf9045538dc6f39482d97b128959e8f089a6","revisionTime":"2018-05-04T18:26:03Z","tree":true}, - {"path":"github.com/hashicorp/go-discover/provider/azure","checksumSHA1":"FpPWpmKgj6ONMcWL7ebfXd8K6Kw=","revision":"b55bdf9045538dc6f39482d97b128959e8f089a6","revisionTime":"2018-05-04T18:26:03Z","tree":true}, - {"path":"github.com/hashicorp/go-discover/provider/digitalocean","checksumSHA1":"TthiY6qza4DnHPLXBq7re5ngNOY=","revision":"b55bdf9045538dc6f39482d97b128959e8f089a6","revisionTime":"2018-05-04T18:26:03Z","tree":true}, - {"path":"github.com/hashicorp/go-discover/provider/gce","checksumSHA1":"bQHkaF9dUFUYJLQ0MkVLIlCIVaE=","revision":"b55bdf9045538dc6f39482d97b128959e8f089a6","revisionTime":"2018-05-04T18:26:03Z","tree":true}, - {"path":"github.com/hashicorp/go-discover/provider/os","checksumSHA1":"b4K8mZAZZ78/rMiSNIPM9H9MBSI=","revision":"b55bdf9045538dc6f39482d97b128959e8f089a6","revisionTime":"2018-05-04T18:26:03Z","tree":true}, - {"path":"github.com/hashicorp/go-discover/provider/packet","checksumSHA1":"y19sWSVrdVfzaRGPS3NcLWe4FpU=","revision":"fc7e9a8d27eb257682acc87071b3721f8250bd67","revisionTime":"2018-07-17T23:41:26Z"}, - {"path":"github.com/hashicorp/go-discover/provider/scaleway","checksumSHA1":"GQ/3AvzdX6T0rtEFeGNYhwt17Zs=","revision":"b55bdf9045538dc6f39482d97b128959e8f089a6","revisionTime":"2018-05-04T18:26:03Z","tree":true}, - {"path":"github.com/hashicorp/go-discover/provider/softlayer","checksumSHA1":"SIyZ44AHIUTBfI336ACpCeybsLg=","revision":"b55bdf9045538dc6f39482d97b128959e8f089a6","revisionTime":"2018-05-04T18:26:03Z","tree":true}, - {"path":"github.com/hashicorp/go-discover/provider/triton","checksumSHA1":"OmBrnagVa2akyR9nbQjia28lunE=","revision":"b55bdf9045538dc6f39482d97b128959e8f089a6","revisionTime":"2018-05-04T18:26:03Z"}, - {"path":"github.com/hashicorp/go-discover/provider/vsphere","checksumSHA1":"UyXDtdqk+9nb1ReU10nB+sKtmCI=","revision":"fc7e9a8d27eb257682acc87071b3721f8250bd67","revisionTime":"2018-07-17T23:41:26Z"}, + {"path":"github.com/hashicorp/go-discover","checksumSHA1":"qJN0TixDHZdaP3z110+oNszPlUg=","revision":"f9c9239562a8e21e5a37f1f2604d8f1c11bc3893","revisionTime":"2018-08-31T15:49:06Z"}, + {"path":"github.com/hashicorp/go-discover/provider/aliyun","checksumSHA1":"Jww5zrDwjMoFF31RqBapilTdi18=","revision":"f9c9239562a8e21e5a37f1f2604d8f1c11bc3893","revisionTime":"2018-08-31T15:49:06Z","tree":true}, + {"path":"github.com/hashicorp/go-discover/provider/aws","checksumSHA1":"Vit45xRjrJ6h7IGJndrBjodVUAE=","revision":"f9c9239562a8e21e5a37f1f2604d8f1c11bc3893","revisionTime":"2018-08-31T15:49:06Z","tree":true}, + {"path":"github.com/hashicorp/go-discover/provider/azure","checksumSHA1":"dMU80T10KQFZNqpBBjzf7ymFNBw=","revision":"f9c9239562a8e21e5a37f1f2604d8f1c11bc3893","revisionTime":"2018-08-31T15:49:06Z","tree":true}, + {"path":"github.com/hashicorp/go-discover/provider/digitalocean","checksumSHA1":"TthiY6qza4DnHPLXBq7re5ngNOY=","revision":"f9c9239562a8e21e5a37f1f2604d8f1c11bc3893","revisionTime":"2018-08-31T15:49:06Z","tree":true}, + {"path":"github.com/hashicorp/go-discover/provider/gce","checksumSHA1":"bQHkaF9dUFUYJLQ0MkVLIlCIVaE=","revision":"f9c9239562a8e21e5a37f1f2604d8f1c11bc3893","revisionTime":"2018-08-31T15:49:06Z","tree":true}, + {"path":"github.com/hashicorp/go-discover/provider/os","checksumSHA1":"SbPabgJWHX8uVsLwlGqpVLs20XU=","revision":"f9c9239562a8e21e5a37f1f2604d8f1c11bc3893","revisionTime":"2018-08-31T15:49:06Z","tree":true}, + {"path":"github.com/hashicorp/go-discover/provider/packet","checksumSHA1":"y19sWSVrdVfzaRGPS3NcLWe4FpU=","revision":"f9c9239562a8e21e5a37f1f2604d8f1c11bc3893","revisionTime":"2018-08-31T15:49:06Z"}, + {"path":"github.com/hashicorp/go-discover/provider/scaleway","checksumSHA1":"amLxw8GikdQQ2U+HT1+GzdZG3Dw=","revision":"f9c9239562a8e21e5a37f1f2604d8f1c11bc3893","revisionTime":"2018-08-31T15:49:06Z","tree":true}, + {"path":"github.com/hashicorp/go-discover/provider/softlayer","checksumSHA1":"SIyZ44AHIUTBfI336ACpCeybsLg=","revision":"f9c9239562a8e21e5a37f1f2604d8f1c11bc3893","revisionTime":"2018-08-31T15:49:06Z","tree":true}, + {"path":"github.com/hashicorp/go-discover/provider/triton","checksumSHA1":"OmBrnagVa2akyR9nbQjia28lunE=","revision":"f9c9239562a8e21e5a37f1f2604d8f1c11bc3893","revisionTime":"2018-08-31T15:49:06Z"}, + {"path":"github.com/hashicorp/go-discover/provider/vsphere","checksumSHA1":"s5lxWYL2UiEeOksa3DVEYWJsH1I=","revision":"f9c9239562a8e21e5a37f1f2604d8f1c11bc3893","revisionTime":"2018-08-31T15:49:06Z"}, {"path":"github.com/hashicorp/go-hclog","checksumSHA1":"qhjAx0nMYBeQqRTaf7sQYpfUIq0=","revision":"69ff559dc25f3b435631604f573a5fa1efdb6433","revisionTime":"2018-04-02T20:04:05Z"}, {"path":"github.com/hashicorp/go-immutable-radix","checksumSHA1":"Cas2nprG6pWzf05A2F/OlnjUu2Y=","revision":"8aac2701530899b64bdea735a1de8da899815220","revisionTime":"2017-07-25T22:12:15Z"}, {"path":"github.com/hashicorp/go-memdb","checksumSHA1":"T65qvYBTy4rYks7oN+U0muEqtRw=","revision":"2b2d6c35e14e7557ea1003e707d5e179fa315028","revisionTime":"2017-07-25T22:15:03Z"},