diff --git a/go.mod b/go.mod index 701454e9bd..a74d21b12f 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,18 @@ module github.com/terraform-providers/terraform-provider-scaleway require ( - github.com/aws/aws-sdk-go v1.22.0 + github.com/apache/thrift v0.12.0 // indirect + github.com/aws/aws-sdk-go v1.25.3 github.com/hashicorp/go-retryablehttp v0.5.2 - github.com/hashicorp/terraform v0.12.8 + github.com/hashicorp/terraform v0.12.9 github.com/mitchellh/go-homedir v1.1.0 github.com/nicolai86/scaleway-sdk v0.0.0-20181024210327-b20018e944c4 - github.com/scaleway/scaleway-sdk-go v1.0.0-beta.3 + github.com/openzipkin/zipkin-go v0.1.6 // indirect + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.3.0.20191001144154-3345f37979fe github.com/stretchr/testify v1.3.0 + golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d // indirect golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522 + google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c // indirect + gopkg.in/yaml.v2 v2.2.2 ) diff --git a/go.sum b/go.sum index 659085fed1..f1db3b072b 100644 --- a/go.sum +++ b/go.sum @@ -3,6 +3,13 @@ cloud.google.com/go v0.31.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.36.0 h1:+aCSj7tOo2LODWVEuZDZeGCckdt6MlSF+X/rB3wUiS8= cloud.google.com/go v0.36.0/go.mod h1:RUoy9p/M4ge0HzT8L+SDZ8jg+Q6fth0CiBuhFJpSV40= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1 h1:lRi0CHyU+ytlvylOlFKKq0af6JncuyoRh1J+QJBqQx0= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU= dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU= dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= @@ -15,6 +22,7 @@ github.com/Azure/go-autorest v10.15.4+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxS github.com/Azure/go-ntlmssp v0.0.0-20180810175552-4a21cbd618b4 h1:pSm8mp0T2OH2CPmPDPtwHPr3VAQaOwVF/JbllOPP4xA= github.com/Azure/go-ntlmssp v0.0.0-20180810175552-4a21cbd618b4/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022 h1:y8Gs8CzNfDF5AZvjr+5UyGQvQEBL7pwo+v+wX6q9JI8= github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022/go.mod h1:nuWgzSkT5PnyOd+272uUmV0dnAnAn42Mk7PiQC5VzN4= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= @@ -42,6 +50,8 @@ github.com/antchfx/xquery v0.0.0-20180515051857-ad5b8c7a47b0/go.mod h1:LzD22aAzD github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apparentlymart/go-cidr v1.0.0 h1:lGDvXx8Lv9QHjrAVP7jyzleG4F9+FkRhJcEsDFxeb8w= github.com/apparentlymart/go-cidr v1.0.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= +github.com/apparentlymart/go-cidr v1.0.1 h1:NmIwLZ/KdsjIUlhf+/Np40atNXm/+lZ5txfTJ/SpF+U= +github.com/apparentlymart/go-cidr v1.0.1/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= @@ -57,6 +67,8 @@ github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3A github.com/aws/aws-sdk-go v1.16.36/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.22.0 h1:e88V6+dSEyBibUy0ekOydtTfNWzqG3hrtCR8SF6UqqY= github.com/aws/aws-sdk-go v1.22.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.25.3 h1:uM16hIw9BotjZKMZlX05SN2EFtaWfi/NonPKIARiBLQ= +github.com/aws/aws-sdk-go v1.25.3/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= @@ -130,8 +142,11 @@ 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/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= @@ -142,12 +157,16 @@ github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go v2.0.0+incompatible h1:j0GKcs05QVmm7yesiZq2+9cxHkNK9YM6zKx4D2qucQU= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3 h1:siORttZ36U2R/WjiJuDz8znElWBiAlO9rVt+mqJt0Cc= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gophercloud/gophercloud v0.0.0-20190208042652-bc37892e1968 h1:Pu+HW4kcQozw0QyrTTgLE+3RXNqFhQNNzhbnoLFL83c= github.com/gophercloud/gophercloud v0.0.0-20190208042652-bc37892e1968/go.mod h1:3WdhXV3rUYy9p6AUW8d94kr+HS62Y4VL9mBnFxsD8q4= github.com/gophercloud/utils v0.0.0-20190128072930-fbb6ab446f01 h1:OgCNGSnEalfkRpn//WGJHhpo7fkP+LhTpvEITZ7CkK4= @@ -177,6 +196,8 @@ github.com/hashicorp/go-cleanhttp v0.5.0 h1:wvCrVc9TjDls6+YGAF2hAifE1E5U1+b4tH6K github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-getter v1.3.1-0.20190627223108-da0323b9545e h1:6krcdHPiS+aIP9XKzJzSahfjD7jG7Z+4+opm0z39V1M= github.com/hashicorp/go-getter v1.3.1-0.20190627223108-da0323b9545e/go.mod h1:/O1k/AizTN0QmfEKknCYGvICeyKUDqCYA8vvWtGWDeQ= +github.com/hashicorp/go-getter v1.4.0 h1:ENHNi8494porjD0ZhIrjlAHnveSFhY7hvOJrV/fsKkw= +github.com/hashicorp/go-getter v1.4.0/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.0.0-20181001195459-61d530d6c27f h1:Yv9YzBlAETjy6AOX9eLBZ3nshNVRREgerT/3nvxlGho= github.com/hashicorp/go-hclog v0.0.0-20181001195459-61d530d6c27f/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= @@ -206,6 +227,8 @@ github.com/hashicorp/go-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PF github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f h1:UdxlrJz4JOnY8W+DbLISwf2B8WXEolNRA8BGCwI9jws= github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= github.com/hashicorp/hcl2 v0.0.0-20190821123243-0c888d1241f6 h1:JImQpEeUQ+0DPFMaWzLA0GdUNPaUlCXLpfiqkSZBUfc= @@ -219,6 +242,8 @@ github.com/hashicorp/serf v0.0.0-20160124182025-e4ec8cc423bb h1:ZbgmOQt8DOg796fi github.com/hashicorp/serf v0.0.0-20160124182025-e4ec8cc423bb/go.mod h1:h/Ru6tmZazX7WO/GDmwdpS975F019L4t5ng5IgwbNrE= github.com/hashicorp/terraform v0.12.8 h1:51Z5K8oj42KZi0IiTf99wMTujDpvsTd3eaF1k5z1URk= github.com/hashicorp/terraform v0.12.8/go.mod h1:8rXMj8q+hRsR/28WWWyiHu1GEDSjWaHPoV14E66X5VU= +github.com/hashicorp/terraform v0.12.9 h1:ClfUndj2L94SWUiBRNikWBHu5+U/KmvaUKbLTbuo5mM= +github.com/hashicorp/terraform v0.12.9/go.mod h1:qqvw7OZzW6mePSM0k2+rOzOD4U8YgHJF6T1qUCR7aAU= github.com/hashicorp/terraform-config-inspect v0.0.0-20190821133035-82a99dc22ef4 h1:fTkL0YwjohGyN7AqsDhz6bwcGBpT+xBqi3Qhpw58Juw= github.com/hashicorp/terraform-config-inspect v0.0.0-20190821133035-82a99dc22ef4/go.mod h1:JDmizlhaP5P0rYTTZB0reDMefAiJyfWPEtugV4in1oI= github.com/hashicorp/vault v0.10.4/go.mod h1:KfSyffbKxoVyspOdlaGVjIuwLobi07qD1bAbosPMpP0= @@ -235,6 +260,7 @@ github.com/joyent/triton-go v0.0.0-20180313100802-d8f9c0314926 h1:kie3qOosvRKqwi github.com/joyent/triton-go v0.0.0-20180313100802-d8f9c0314926/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/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= 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/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= @@ -330,6 +356,7 @@ github.com/packer-community/winrmcp v0.0.0-20180102160824-81144009af58 h1:m3CEgv github.com/packer-community/winrmcp v0.0.0-20180102160824-81144009af58/go.mod h1:f6Izs6JvFTdnRbziASagjZ2vmf55NSIkC/weStxCHqk= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= 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= @@ -354,6 +381,8 @@ github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/scaleway/scaleway-sdk-go v1.0.0-beta.3 h1:4o0hpXUFqgMR1NnGbX7SeHFODlkHOZqoeVkABmnM0P8= github.com/scaleway/scaleway-sdk-go v1.0.0-beta.3/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.3.0.20191001144154-3345f37979fe h1:uXO2guxH4DXhq57lY5VvPxhHyPmhqf4yeGh+PcWmjY0= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.3.0.20191001144154-3345f37979fe/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= @@ -423,6 +452,9 @@ go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2 h1:NAfh7zF0/3/HqtMvJNZ/RFrSlCE6ZTlHmKfhL/Dm1Jk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= @@ -436,13 +468,19 @@ golang.org/x/crypto v0.0.0-20190222235706-ffb98f73852f/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 h1:p/H982KKEjUnLJkM3tt/LemDnOc1GiZL5FCVlORJ5zo= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -456,13 +494,20 @@ golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190502183928-7f726cade0ab h1:9RfW3ktsOZxgo9YNbBAjq1FWzc/igwEcUzZz8IXgSbk= golang.org/x/net v0.0.0-20190502183928-7f726cade0ab/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 h1:Wo7BWFiOk0QRFMLYMqJGFMd9CgUAcGx7V+qEg/h5IBI= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -484,9 +529,14 @@ golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82 h1:vsphBvatvfbhlb4PO1BYSr9dzugGxJ/SQHoNufZJq1w= golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa h1:KIDDMLT1O0Nr7TSxp8xM5tJcdn8tgyAONntO829og1M= golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= @@ -504,8 +554,13 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522 h1:bhOzK9QyoD0ogCnFro1m2mz41+Ib0oOhfJnBp5MR4K4= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= @@ -514,11 +569,18 @@ google.golang.org/api v0.1.0 h1:K6z2u68e86TPdSdefXdzvXgR1zEMa+459vBSfWYAZkI= google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= google.golang.org/api v0.3.1 h1:oJra/lMfmtm13/rgY/8i3MzjFWYXvQIAKjQ3HqofMk8= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0 h1:jbyannxz0XFD3zdjgrSUsaJbgpH4eTrkdhRChkHPfO8= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= @@ -527,12 +589,23 @@ google.golang.org/genproto v0.0.0-20190201180003-4b09977fb922 h1:mBVYJnbrXLA/ZCB google.golang.org/genproto v0.0.0-20190201180003-4b09977fb922/go.mod h1:L3J43x8/uS+qIUoksaLKe6OS3nUKxOKuIFz1sl2/jx4= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19 h1:Lj2SnHtxkRGJDqnGaSjo+CCdIieEnwVazbOXILwQemk= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c h1:hrpEMCZ2O7DR5gC1n2AJGVhrwiEjOi35+jxtIuZpTMo= +google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.1 h1:TrBcJ1yqAl1G++wO39nD/qtgpsW9/1+QGrluyMGEYgM= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1 h1:j6XxA85m/6txkUCHvzlV5f+HBNl/1r5cZ2A/3IEFOO8= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= @@ -552,6 +625,8 @@ grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJd honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= diff --git a/scaleway/helpers_k8s.go b/scaleway/helpers_k8s.go new file mode 100644 index 0000000000..74eb8c4b06 --- /dev/null +++ b/scaleway/helpers_k8s.go @@ -0,0 +1,76 @@ +package scaleway + +import ( + "fmt" + "time" + + "github.com/hashicorp/terraform/helper/schema" + k8s "github.com/scaleway/scaleway-sdk-go/api/k8s/v1beta3" + "github.com/scaleway/scaleway-sdk-go/scw" +) + +type kubeconfigStruct struct { + apiVersion string `yaml:"apiVersion"` + clusters []struct { + certificateAuthorityData string `yaml:"certificate-authority-data"` + server string `yaml:"server"` + } `yaml:"clusters"` + contexts []struct { + name string `yaml:"name"` + context struct { + cluster string `yaml:"cluster"` + user string `yaml:"user"` + } `yaml:"context"` + } `yaml:"contexts"` + kind string `yaml:"kind"` + users []struct { + name string `yaml:"name"` + user struct { + token string `yaml:"token"` + } `yaml:"user"` + } `yaml:"users"` +} + +const ( + K8SClusterWaitForReadyTimeout = 10 * time.Minute +) + +func getK8SAPIWithRegion(d *schema.ResourceData, m interface{}) (*k8s.API, scw.Region, error) { + meta := m.(*Meta) + k8sAPI := k8s.NewAPI(meta.scwClient) + + region, err := getRegion(d, meta) + + return k8sAPI, region, err +} + +func getK8SAPIWithRegionAndID(m interface{}, id string) (*k8s.API, scw.Region, string, error) { + meta := m.(*Meta) + k8sAPI := k8s.NewAPI(meta.scwClient) + + region, ID, err := parseRegionalID(id) + return k8sAPI, region, ID, err +} + +func waitK8SClusterReady(k8sAPI *k8s.API, region scw.Region, clusterID string) error { + now := time.Now() + for { + response, err := k8sAPI.GetCluster(&k8s.GetClusterRequest{ + Region: region, + ClusterID: clusterID, + }) + if err != nil { + return err + } + + if response.Status == k8s.ClusterStatusReady { + return nil + } + time.Sleep(time.Second * 5) + if time.Now().After(now.Add(K8SClusterWaitForReadyTimeout)) { + break + } + } + + return fmt.Errorf("Timeout waiting for cluster %s to be ready", clusterID) +} diff --git a/scaleway/resource_k8s_cluster.go b/scaleway/resource_k8s_cluster.go new file mode 100644 index 0000000000..392e646a9f --- /dev/null +++ b/scaleway/resource_k8s_cluster.go @@ -0,0 +1,663 @@ +package scaleway + +import ( + "encoding/base64" + "fmt" + "io/ioutil" + + "github.com/hashicorp/terraform/helper/schema" + k8s "github.com/scaleway/scaleway-sdk-go/api/k8s/v1beta3" + "github.com/scaleway/scaleway-sdk-go/scw" + + "gopkg.in/yaml.v2" +) + +func resourceScalewayK8SClusterBeta() *schema.Resource { + return &schema.Resource{ + Create: resourceScalewayK8SClusterBetaCreate, + Read: resourceScalewayK8SClusterBetaRead, + Update: resourceScalewayK8SClusterBetaUpdate, + Delete: resourceScalewayK8SClusterBetaDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + SchemaVersion: 0, + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Optional: true, + Description: "The name of the cluster", + }, + "description": { + Type: schema.TypeString, + Optional: true, + Description: "The description of the cluster", + }, + "version": { + Type: schema.TypeString, + Required: false, + Default: "", + Description: "The version of the cluster", + }, + "cni": { + Type: schema.TypeString, + Required: true, + Description: "The CNI plugin of the cluster", + }, + "enable_dashboard": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Enable the dashboard on the cluster", + }, + "ingress": { + Type: schema.TypeInt, + Optional: true, + Default: "no_ingress", + Description: "The ingress to be deployed on the cluster", + }, + "tags": { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Optional: true, + Description: "The tags associated with the cluster", + }, + "autoscaler_config": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The autoscaler configuration for the cluster", + Elem: autoscalerConfigSchema(), + }, + "default_pool": { + Type: schema.TypeList, + MaxItems: 1, + Required: true, + Description: "Default pool created on the cluster on creation", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "node_type": { + Type: schema.TypeString, + Required: true, + Description: "Server Type of the default pool servers", + }, + "autoscaling": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Enable the autoscaling on the default pool", + }, + "size": { + Type: schema.TypeInt, + Required: true, + Description: "Size of the default pool", + }, + "min_size": { + Type: schema.TypeInt, + Optional: true, + Description: "Minimun size of the default pool", + }, + "max_size": { + Type: schema.TypeInt, + Optional: true, + Description: "Maximum size of the default pool", + }, + "container_runtime": { + Type: schema.TypeInt, + Optional: true, + Description: "Container runtime for the default pool", + }, + // Computed elements + "id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of default pool", + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + Description: "The date and time of the creation of the default pool", + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + Description: "The date and time of the last update of the default pool", + }, + "status": { + Type: schema.TypeString, + Computed: true, + Description: "The status of the default pool", + }, + }, + }, + }, + "region": regionSchema(), + "organization_id": organizationIDSchema(), + // Computed elements + "id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the Kubernetes Cluster", + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + Description: "The date and time of the creation of the Kubernetes cluster", + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + Description: "The date and time of the last update of the Kubernetes cluster", + }, + "apiserver_url": { + Type: schema.TypeString, + Computed: true, + Description: "Kubernetes API server URL", + }, + "wildcard_dns": { + Type: schema.TypeString, + Computed: true, + Description: "Wildcard DNS pointing to all the ready nodes", + }, + "kubeconfig": { + Type: schema.TypeList, + MaxItems: 1, + Computed: true, + Description: "The kubeconfig configuration file of the Kubernetes cluster", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "config_file": { + Type: schema.TypeString, + Computed: true, + Description: "The whole kubeconfig file", + }, + "host": { + Type: schema.TypeString, + Computed: true, + Description: "The kubernetes master URL", + }, + "cluster_ca_certificate": { + Type: schema.TypeString, + Computed: true, + Description: "The kubernetes cluster CA certificate", + }, + "token": { + Type: schema.TypeString, + Computed: true, + Description: "The kubernetes cluster admin token", + }, + }, + }, + }, + "status": { + Type: schema.TypeString, + Computed: true, + Description: "The status of the cluster", + }, + }, + } +} + +func resourceScalewayK8SClusterBetaCreate(d *schema.ResourceData, m interface{}) error { + k8sAPI, region, err := getK8SAPIWithRegion(d, m) + if err != nil { + return err + } + + //// + // Create cluster + //// + name, ok := d.GetOk("name") + if !ok { + name = getRandomName("cluster") + } + + description, ok := d.GetOk("description") + if !ok { + description = "" + } + + req := &k8s.CreateClusterRequest{ + Region: region, + OrganizationID: d.Get("organization_id").(string), + Name: name.(string), + Description: description.(string), + Version: d.Get("version").(string), + Cni: d.Get("cni").(string), + EnableDashboard: d.Get("enable_dashboard").(bool), + Ingress: d.Get("ingress").(string), + } + + if raw, ok := d.GetOk("tags"); ok { + for _, tag := range raw.([]interface{}) { + req.Tags = append(req.Tags, tag.(string)) + } + } + + autoscalerReq := &k8s.CreateClusterRequestAutoscalerConfig{ + ScaleDownDisabled: scw.BoolPtr(d.Get("autoscaler_config.disable_scale_down").(bool)), + ScaleDownDelayAfterAdd: scw.StringPtr(d.Get("autoscaler_config.scale_down_delay_after_add").(string)), + Estimator: scw.StringPtr(d.Get("autoscaler_config.estimator").(string)), + Expander: scw.StringPtr(d.Get("autoscaler_config.expander").(string)), + IgnoreDaemonsetsUtilization: scw.BoolPtr(d.Get("autoscaler_config.ignore_daemonsets_utilization").(bool)), + BalanceSimilarNodeGroups: scw.BoolPtr(d.Get("autoscaler_config.balance_similar_node_groups").(bool)), + ExpendablePodsPriorityCutoff: scw.Int32Ptr(d.Get("autoscaler_config.expendable_pods_priority_cutoff").(int32)), + } + req.AutoscalerConfig = autoscalerReq + + defaultPoolReq := &k8s.CreateClusterRequestDefaultPoolConfig{ + NodeType: d.Get("default_pool.node_type").(string), + Autoscaling: d.Get("default_pool.autoscaling").(bool), + Size: d.Get("default_pool.size").(uint32), + } + + if placementGroupID, ok := d.GetOk("default_pool.placement_group_id"); ok { + defaultPoolReq.PlacementGroupID = scw.StringPtr(placementGroupID.(string)) + } + + if minSize, ok := d.GetOk("default_pool.min_size"); ok { + defaultPoolReq.MinSize = scw.Uint32Ptr(minSize.(uint32)) + } + + if maxSize, ok := d.GetOk("default_pool.max_size"); ok { + defaultPoolReq.MaxSize = scw.Uint32Ptr(maxSize.(uint32)) + } + + if containerRuntime, ok := d.GetOk("default_pool.container_runtime"); ok { + defaultPoolReq.ContainerRuntime = scw.StringPtr(containerRuntime.(string)) + } + + req.DefaultPoolConfig = defaultPoolReq + + res, err := k8sAPI.CreateCluster(req) + if err != nil { + return err + } + + d.SetId(newRegionalId(region, res.ID)) + + err = waitK8SClusterReady(k8sAPI, region, res.ID) + if err != nil { + return err + } + + return resourceScalewayK8SClusterBetaRead(d, m) +} + +// resourceScalewayK8SClusterBetaDefaultPoolRead is only called after a resourceScalewayK8SClusterBetaCreate +// thus ensuring the uniqueness of the only pool listed +func resourceScalewayK8SClusterBetaDefaultPoolRead(d *schema.ResourceData, m interface{}) error { + k8sAPI, region, clusterID, err := getK8SAPIWithRegionAndID(m, d.Id()) + if err != nil { + return err + } + + //// + // Read default Pool + //// + + var pool *k8s.Pool + + if defaultPoolID, ok := d.GetOk("default_pool.id"); ok { + poolResp, err := k8sAPI.GetPool(&k8s.GetPoolRequest{ + Region: region, + PoolID: defaultPoolID.(string), + }) + if err != nil { + return err + } + pool = poolResp + } else { + response, err := k8sAPI.ListPools(&k8s.ListPoolsRequest{ + Region: region, + ClusterID: clusterID, + }) + if err != nil { + return err + } + + if len(response.Pools) != 1 { + return fmt.Errorf("Newly created pool on cluster %s has %d pools instead of 1", clusterID, len(response.Pools)) + } + + pool = response.Pools[0] + } + + d.Set("default_pool.id", pool.ID) + d.Set("default_pool.node_type", pool.NodeType) + d.Set("default_pool.autoscaling", pool.Autoscaling) + d.Set("default_pool.size", pool.Size) + d.Set("default_pool.min_size", pool.MinSize) + d.Set("default_pool.max_size", pool.MaxSize) + d.Set("default_pool.container_runtime", pool.ContainerRuntime) + d.Set("default_pool.created_at", pool.CreatedAt) + d.Set("default_pool.updated_at", pool.UpdatedAt) + d.Set("default_pool.status", pool.Status.String()) + + return nil +} + +func resourceScalewayK8SClusterBetaRead(d *schema.ResourceData, m interface{}) error { + k8sAPI, region, clusterID, err := getK8SAPIWithRegionAndID(m, d.Id()) + if err != nil { + return err + } + + //// + // Read Cluster + //// + response, err := k8sAPI.GetCluster(&k8s.GetClusterRequest{ + Region: region, + ClusterID: clusterID, + }) + if err != nil { + if is404Error(err) { + d.SetId("") + return nil + } + return err + } + + d.Set("region", string(region)) + d.Set("name", response.Name) + d.Set("description", response.Description) + d.Set("version", response.Version) + d.Set("cni", response.Cni) + d.Set("tags", response.Tags) + d.Set("created_at", response.CreatedAt) + d.Set("updated_at", response.UpdatedAt) + d.Set("apiserver_url", response.ClusterURL) + d.Set("wildcard_dns", response.DNSWildcard) + d.Set("status", response.Status.String()) + + // autoscaler_config + d.Set("autoscaler_config.disable_scale_down", response.AutoscalerConfig.ScaleDownDisabled) + d.Set("autoscaler_config.scale_down_delay_after_add", response.AutoscalerConfig.ScaleDownDelayAfterAdd) + d.Set("autoscaler_config.estimator", response.AutoscalerConfig.Estimator) + d.Set("autoscaler_config.expander", response.AutoscalerConfig.Expander) + d.Set("autoscaler_config.ignore_daemonsets_utilization", response.AutoscalerConfig.IgnoreDaemonsetsUtilization) + d.Set("autoscaler_config.balance_similar_node_groups", response.AutoscalerConfig.BalanceSimilarNodeGroups) + d.Set("autoscaler_config.expendable_pods_priority_cutoff", response.AutoscalerConfig.ExpendablePodsPriorityCutoff) + + // default_pool_config + err = resourceScalewayK8SClusterBetaDefaultPoolRead(d, m) + if err != nil { + return err + } + + //// + // Read kubeconfig + //// + kubeconfigResp, err := k8sAPI.GetClusterKubeConfig(&k8s.GetClusterKubeConfigRequest{ + Region: region, + ClusterID: clusterID, + }) + if err != nil { + return err + } + + kubeconfigBase64Content, err := ioutil.ReadAll(kubeconfigResp.Content) + if err != nil { + return err + } + kubeconfigContent, err := base64.StdEncoding.DecodeString(string(kubeconfigBase64Content)) + if err != nil { + return err + } + + var kubeconfig kubeconfigStruct + err = yaml.Unmarshal(kubeconfigContent, &kubeconfig) + if err != nil { + return err + } + + if len(kubeconfig.clusters) != 1 { + return fmt.Errorf("The kubeconfig contains %d clusters instead of 1", len(kubeconfig.clusters)) + } + + if len(kubeconfig.users) != 1 { + return fmt.Errorf("The kubeconfig contains %d users instead of 1", len(kubeconfig.users)) + } + + d.Set("kubeconfig.config_file", string(kubeconfigContent)) + d.Set("kubeconfig.host", kubeconfig.clusters[0].server) + d.Set("kubeconfig.cluster_ca_certificate", kubeconfig.clusters[0].certificateAuthorityData) + d.Set("kubeconfig.token", kubeconfig.users[0].user.token) + + return nil +} + +// resourceScalewayK8SClusterBetaDefaultPoolUpdate is only called after a resourceScalewayK8SClusterBetaUpdate +// thus guarating that "default_pool.id" is set +func resourceScalewayK8SClusterBetaDefaultPoolUpdate(d *schema.ResourceData, m interface{}) error { + k8sAPI, region, clusterID, err := getK8SAPIWithRegionAndID(m, d.Id()) + if err != nil { + return err + } + + //// + // Update default Pool + //// + + if d.HasChange("default_pool") { + defaultPoolID := d.Get("default_pool.id").(string) + + updateRequest := &k8s.UpdatePoolRequest{ + Region: region, + PoolID: defaultPoolID, + } + + if autoscaling, ok := d.GetOk("default_pool.autoscaling"); ok { + updateRequest.Autoscaling = scw.BoolPtr(autoscaling.(bool)) + } + + if minSize, ok := d.GetOk("default_pool.min_size"); ok { + updateRequest.MinSize = scw.Uint32Ptr(minSize.(uint32)) + } + + if maxSize, ok := d.GetOk("default_pool.max_size"); ok { + updateRequest.MaxSize = scw.Uint32Ptr(maxSize.(uint32)) + } + + if size, ok := d.GetOk("default_pool.size"); ok { + updateRequest.Size = scw.Uint32Ptr(size.(uint32)) + } + + _, err := k8sAPI.UpdatePool(updateRequest) + if err != nil { + if !is404Error(err) { + return err + } + defaultPoolRequest := &k8s.CreatePoolRequest{ + Region: region, + ClusterID: clusterID, + Name: "default", + NodeType: d.Get("default_pool.node_type").(string), + Autoscaling: d.Get("default_pool.autoscaling").(bool), + Size: d.Get("default_pool.size").(uint32), + } + if placementGroupID, ok := d.GetOk("default_pool.placement_group_id"); ok { + defaultPoolRequest.PlacementGroupID = scw.StringPtr(placementGroupID.(string)) + } + + if minSize, ok := d.GetOk("default_pool.min_size"); ok { + defaultPoolRequest.MinSize = scw.Uint32Ptr(minSize.(uint32)) + } + + if maxSize, ok := d.GetOk("default_pool.max_size"); ok { + defaultPoolRequest.MaxSize = scw.Uint32Ptr(maxSize.(uint32)) + } + + if containerRuntime, ok := d.GetOk("default_pool.container_runtime"); ok { + defaultPoolRequest.ContainerRuntime = scw.StringPtr(containerRuntime.(string)) + } + + defaultPool, err := k8sAPI.CreatePool(defaultPoolRequest) + if err != nil { + return err + } + + d.Set("default_pool.id", defaultPool.ID) + } + } + return resourceScalewayK8SClusterBetaDefaultPoolRead(d, m) +} + +func resourceScalewayK8SClusterBetaUpdate(d *schema.ResourceData, m interface{}) error { + k8sAPI, region, clusterID, err := getK8SAPIWithRegionAndID(m, d.Id()) + if err != nil { + return err + } + + canUpgrade := false + + //// + // Construct UpdateClusterRequest + //// + updateRequest := &k8s.UpdateClusterRequest{ + Region: region, + ClusterID: clusterID, + } + + if d.HasChange("description") { + updateRequest.Description = scw.StringPtr(d.Get("description").(string)) + } + + if d.HasChange("tags") { + tags := StringSliceFromState(d.Get("tags").([]interface{})) + updateRequest.Tags = scw.StringsPtr(tags) + } + + if d.HasChange("version") { + versions, err := k8sAPI.ListClusterAvailableVersions(&k8s.ListClusterAvailableVersionsRequest{ + Region: region, + ClusterID: clusterID, + }) + if err != nil { + return err + } + + for _, version := range versions.Versions { + if version.Name == d.Get("version").(string) { + canUpgrade = true + break + } + } + if !canUpgrade { + return fmt.Errorf("Cluster %s can not be upgraded to version %s", clusterID, d.Get("version").(string)) + } + } + + defer lockLocalizedId(d.Id())() + + //// + // Apply Update + //// + _, err = k8sAPI.UpdateCluster(updateRequest) + if err != nil { + return err + } + + err = waitK8SClusterReady(k8sAPI, region, clusterID) + if err != nil { + return err + } + + //// + // Upgrade if needed + //// + if canUpgrade { + upgradeRequest := &k8s.UpgradeClusterRequest{ + Region: region, + ClusterID: clusterID, + Version: d.Get("version").(string), + UpgradePools: true, + } + _, err = k8sAPI.UpgradeCluster(upgradeRequest) + if err != nil { + return err + } + + err = waitK8SClusterReady(k8sAPI, region, clusterID) + if err != nil { + return err + } + } + + return resourceScalewayK8SClusterBetaRead(d, m) +} + +func resourceScalewayK8SClusterBetaDelete(d *schema.ResourceData, m interface{}) error { + k8sAPI, region, clusterID, err := getK8SAPIWithRegionAndID(m, d.Id()) + if err != nil { + return err + } + + //// + // Delete Cluster + //// + defer lockLocalizedId(d.Id())() + + _, err = k8sAPI.DeleteCluster(&k8s.DeleteClusterRequest{ + Region: region, + ClusterID: clusterID, + }) + if err != nil { + if is404Error(err) { + return err + } + } + + return nil +} + +func autoscalerConfigSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disable_scale_down": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Disable the scale down feature of the autoscaler", + }, + "scale_down_delay_after_add": { + Type: schema.TypeString, + Optional: true, + Default: "10m", + Description: "", + }, + "estimator": { + Type: schema.TypeString, + Optional: true, + Default: "binpacking", + Description: "", + }, + "expander": { + Type: schema.TypeString, + Optional: true, + Default: "random", + Description: "", + }, + "ignore_daemonsets_utilization": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "", + }, + "balance_similar_node_groups": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "", + }, + "expendable_pods_priority_cutoff": { + Type: schema.TypeInt, + Optional: true, + Default: -10, + Description: "", + }, + }, + } +} diff --git a/scaleway/resource_k8s_pool.go b/scaleway/resource_k8s_pool.go new file mode 100644 index 0000000000..a51db10d49 --- /dev/null +++ b/scaleway/resource_k8s_pool.go @@ -0,0 +1,100 @@ +package scaleway + +import ( + "github.com/hashicorp/terraform/helper/schema" +) + +func resourceScalewayK8SPoolBeta() *schema.Resource { + return &schema.Resource{ + Create: resourceScalewayK8SPoolBetaCreate, + Read: resourceScalewayK8SPoolBetaRead, + Update: resourceScalewayK8SPoolBetaUpdate, + Delete: resourceScalewayK8SPoolBetaDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + SchemaVersion: 0, + Schema: map[string]*schema.Schema{ + "cluster_id": { + Type: schema.TypeString, + Required: true, + Description: "The ID of the cluster on which this pool will be created", + }, + "name": { + Type: schema.TypeString, + Optional: true, + Description: "The name of the cluster", + }, + "server_type": { + Type: schema.TypeString, + Required: true, + Description: "Server Type of the pool servers", + }, + "autoscaling": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Enable the autoscaling on the pool", + }, + "size": { + Type: schema.TypeInt, + Required: true, + Description: "Size of the pool", + }, + "min_size": { + Type: schema.TypeInt, + Optional: true, + Description: "Minimun size of the pool", + }, + "max_size": { + Type: schema.TypeInt, + Optional: true, + Description: "Maximum size of the pool", + }, + "container_runtime": { + Type: schema.TypeInt, + Optional: true, + Description: "Container runtime for the pool", + }, + "region": regionSchema(), + "organization_id": organizationIDSchema(), + // Computed elements + "id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the pool", + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + Description: "The date and time of the creation of the pool", + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + Description: "The date and time of the last update of the pool", + }, + "version": { + Type: schema.TypeString, + Computed: true, + Description: "The Kubernetes version of the pool", + }, + }, + } +} + +func resourceScalewayK8SPoolBetaCreate(d *schema.ResourceData, m interface{}) error { + return resourceScalewayK8SPoolBetaRead(d, m) +} + +func resourceScalewayK8SPoolBetaRead(d *schema.ResourceData, m interface{}) error { + return nil +} + +func resourceScalewayK8SPoolBetaUpdate(d *schema.ResourceData, m interface{}) error { + return resourceScalewayK8SPoolBetaRead(d, m) +} + +func resourceScalewayK8SPoolBetaDelete(d *schema.ResourceData, m interface{}) error { + return nil +}