Skip to content

Commit

Permalink
Code review fixes
Browse files Browse the repository at this point in the history
- Add nl-1 endpoint to the regions
- Use dbaas-go v0.6.0 with config parser
  • Loading branch information
Gogen120 committed Sep 21, 2022
1 parent bdae820 commit 3730c4e
Show file tree
Hide file tree
Showing 21 changed files with 74 additions and 100 deletions.
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.17
require (
github.com/hashicorp/go-retryablehttp v0.6.6
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1
github.com/selectel/dbaas-go v0.5.0
github.com/selectel/dbaas-go v0.7.0
github.com/selectel/domains-go v0.3.0
github.com/selectel/go-selvpcclient v1.12.0
github.com/selectel/mks-go v0.12.0
Expand All @@ -21,7 +21,7 @@ require (
github.com/fatih/color v1.7.0 // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/gophercloud/gophercloud v0.17.0 // indirect
github.com/gophercloud/gophercloud v1.0.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand Down Expand Up @@ -52,13 +52,13 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/zclconf/go-cty v1.9.1 // indirect
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect
golang.org/x/net v0.0.0-20210326060303-6b1517762897 // indirect
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/text v0.3.6 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20200711021454-869866162049 // indirect
google.golang.org/grpc v1.32.0 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
30 changes: 17 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
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.17.0 h1:BgVw0saxyeHWH5us/SQe1ltp0GRnytjmOLXDA8pO77E=
github.com/gophercloud/gophercloud v0.17.0/go.mod h1:wRtmUelyIIv3CSSDI47aUwbs075O6i+LY+pXsKCBsb4=
github.com/gophercloud/gophercloud v1.0.0 h1:9nTGx0jizmHxDobe4mck89FyQHVyA3CaXLIUSGJjP9k=
github.com/gophercloud/gophercloud v1.0.0/go.mod h1:Q8fZtyi5zZxPS/j9aj3sSxtvj41AdQMDwyo1myduD5c=
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-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU=
Expand Down Expand Up @@ -218,8 +218,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/jarcoal/httpmock v1.0.8 h1:8kI16SoO6LQKgPE7PvQuV+YuD/inwHd7fOOe2zMbo4k=
github.com/jarcoal/httpmock v1.0.8/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik=
github.com/jarcoal/httpmock v1.2.0 h1:gSvTxxFR/MEMfsGrvRbdfpRUMBStovlSRLw0Ep1bwwc=
github.com/jarcoal/httpmock v1.2.0/go.mod h1:oCoTsnAz4+UoOUIf5lJOWV2QQIW5UoeUI6aM2YnWAZk=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
Expand Down Expand Up @@ -257,6 +257,7 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10=
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/maxatome/go-testdeep v1.11.0/go.mod h1:011SgQ6efzZYAen6fDn4BqQ+lUR72ysdyKe7Dyogw70=
github.com/mitchellh/cli v1.1.2/go.mod h1:6iaV0fGdElS6dPBx0EApTxHrcWvmJphyh2n8YBLPPZ4=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
Expand Down Expand Up @@ -289,8 +290,8 @@ github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndr
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4=
github.com/selectel/dbaas-go v0.5.0 h1:bDiRSBGG6x34vAaHhbSkmAgnnpbiyiHZHkzieRVjBIo=
github.com/selectel/dbaas-go v0.5.0/go.mod h1:H2NC+UrVQzKea92LYyHZj51uuX43sUiAc+iyx/yTCGw=
github.com/selectel/dbaas-go v0.7.0 h1:IBEU7EAPlkQ7wGjtIz9bppthpTZLGn3E6TVX7JWMtWk=
github.com/selectel/dbaas-go v0.7.0/go.mod h1:8D945oFzpx94v08zIb4s1bRTPCdPoNVnBu4umMYFJrQ=
github.com/selectel/domains-go v0.3.0 h1:0shjqQmpkWc6eM1SwgKqbTTNiT5G2BOEnvS7JvuF96g=
github.com/selectel/domains-go v0.3.0/go.mod h1:AhXhwyMSTkpEWFiBLUvzFP76W+WN+ZblwmjLJLt7y58=
github.com/selectel/go-selvpcclient v1.12.0 h1:LsT074HOVF1dWYapsAWjaaJDQhmDPpcsVjSwQ1r1fj0=
Expand Down Expand Up @@ -342,11 +343,11 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e h1:MUP6MR3rJ7Gk9LEia0LP2ytiH6MuCfs7qYz+47jGdD8=
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -409,8 +410,9 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210326060303-6b1517762897 h1:KrsHThm5nFk34YtATK1LsThyGhGbGe1olrte/HInHvs=
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -440,7 +442,6 @@ golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -458,19 +459,20 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -607,8 +609,10 @@ gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRN
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
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=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func dataSourceDBaaSAvailableExtensionV1() *schema.Resource {
ru7Region,
ru8Region,
ru9Region,
nl1Region,
}, false),
},
"filter": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func dataSourceDBaaSConfigurationParameterV1() *schema.Resource {
ru7Region,
ru8Region,
ru9Region,
nl1Region,
}, false),
},
"filter": {
Expand Down
1 change: 1 addition & 0 deletions selectel/data_source_selectel_dbaas_datastore_type_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func dataSourceDBaaSDatastoreTypeV1() *schema.Resource {
ru7Region,
ru8Region,
ru9Region,
nl1Region,
}, false),
},
"filter": {
Expand Down
1 change: 1 addition & 0 deletions selectel/data_source_selectel_dbaas_flavor_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func dataSourceDBaaSFlavorV1() *schema.Resource {
ru7Region,
ru8Region,
ru9Region,
nl1Region,
}, false),
},
"flavors": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func dataSourceDBaaSPrometheusMetricTokenV1() *schema.Resource {
ru7Region,
ru8Region,
ru9Region,
nl1Region,
}, false),
},
"prometheus_metrics_tokens": {
Expand Down
24 changes: 4 additions & 20 deletions selectel/dbaas.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
ru7DBaaSV1Endpoint = "https://ru-7.dbaas.selcloud.ru/v1"
ru8DBaaSV1Endpoint = "https://ru-8.dbaas.selcloud.ru/v1"
ru9DBaaSV1Endpoint = "https://ru-9.dbaas.selcloud.ru/v1"
nl1DBaaSV1Endpoint = "https://nl-1.dbaas.selcloud.ru/v1"
)

func getDBaaSV1Endpoint(region string) (endpoint string) {
Expand All @@ -43,6 +44,8 @@ func getDBaaSV1Endpoint(region string) (endpoint string) {
endpoint = ru8DBaaSV1Endpoint
case ru9Region:
endpoint = ru9DBaaSV1Endpoint
case nl1Region:
endpoint = nl1DBaaSV1Endpoint
}

return
Expand Down Expand Up @@ -149,20 +152,6 @@ func flavorHashSetFunc() schema.SchemaSetFunc {
return schema.HashResource(flavorSchema())
}

func convertFieldFromStringToType(fieldValue string) interface{} {
if val, err := strconv.Atoi(fieldValue); err == nil {
return val
} else if val, err := strconv.ParseFloat(fieldValue, 64); err == nil {
return val
} else if val, err := strconv.ParseFloat(fieldValue, 32); err == nil {
return val
} else if val, err := strconv.ParseBool(fieldValue); err == nil {
return val
} else {
return fieldValue
}
}

func waitForDBaaSDatastoreV1ActiveState(
ctx context.Context, client *dbaas.API, datastoreID string, timeout time.Duration) error {
pending := []string{
Expand Down Expand Up @@ -361,12 +350,7 @@ func updateDatastoreConfig(ctx context.Context, d *schema.ResourceData, client *
if err != nil {
return err
}
configMap := d.Get("config").(map[string]interface{})
config := make(map[string]interface{})
for paramName, paramValue := range configMap {
paramValueStr := paramValue.(string)
config[paramName] = convertFieldFromStringToType(paramValueStr)
}
config := d.Get("config").(map[string]interface{})

for param := range datastore.Config {
if _, ok := config[param]; !ok {
Expand Down
49 changes: 23 additions & 26 deletions selectel/dbaas_postgresql_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,33 @@ import (
"github.com/selectel/dbaas-go"
)

func resourceDBaaSPostgreSQLDatastoreV1PoolerFromSet(poolerSet *schema.Set) (*dbaas.Pooler, error) {
if poolerSet.Len() == 0 {
return nil, nil
}
func parsePoolerSet(poolerSet *schema.Set) (string, int, error) {
var resourceModeRaw, resourceSizeRaw interface{}
var ok bool

resourcePoolerMap := poolerSet.List()[0].(map[string]interface{})
if resourceModeRaw, ok = resourcePoolerMap["mode"]; !ok {
return &dbaas.Pooler{}, errors.New("pooler.mode value isn't provided")
return "", 0, errors.New("pooler.mode value isn't provided")
}
if resourceSizeRaw, ok = resourcePoolerMap["size"]; !ok {
return &dbaas.Pooler{}, errors.New("pooler.size value isn't provided")
return "", 0, errors.New("pooler.size value isn't provided")
}

resourceMode := resourceModeRaw.(string)
resourceSize := resourceSizeRaw.(int)
return resourceModeRaw.(string), resourceSizeRaw.(int), nil
}

func resourceDBaaSPostgreSQLDatastoreV1PoolerFromSet(poolerSet *schema.Set) (*dbaas.Pooler, error) {
if poolerSet.Len() == 0 {
return nil, nil
}
poolerMode, poolerSize, err := parsePoolerSet(poolerSet)
if err != nil {
return nil, errParseDatastoreV1Pooler(err)
}

pooler := &dbaas.Pooler{
Mode: resourceMode,
Size: resourceSize,
Mode: poolerMode,
Size: poolerSize,
}

return pooler, nil
Expand All @@ -39,26 +45,17 @@ func resourceDBaaSPostgreSQLDatastoreV1PoolerOptsFromSet(poolerSet *schema.Set)
if poolerSet.Len() == 0 {
return dbaas.DatastorePoolerOpts{}, nil
}
var resourceModeRaw, resourceSizeRaw interface{}
var ok bool

resourcePoolerMap := poolerSet.List()[0].(map[string]interface{})
if resourceModeRaw, ok = resourcePoolerMap["mode"]; !ok {
return dbaas.DatastorePoolerOpts{}, errors.New("pooler.mode value isn't provided")
}
if resourceSizeRaw, ok = resourcePoolerMap["size"]; !ok {
return dbaas.DatastorePoolerOpts{}, errors.New("pooler.size value isn't provided")
poolerMode, poolerSize, err := parsePoolerSet(poolerSet)
if err != nil {
return dbaas.DatastorePoolerOpts{}, errParseDatastoreV1Pooler(err)
}

resourceMode := resourceModeRaw.(string)
resourceSize := resourceSizeRaw.(int)

pooler := dbaas.DatastorePoolerOpts{
Mode: resourceMode,
Size: resourceSize,
poolerOpts := dbaas.DatastorePoolerOpts{
Mode: poolerMode,
Size: poolerSize,
}

return pooler, nil
return poolerOpts, nil
}

func updatePostgreSQLDatastorePooler(ctx context.Context, d *schema.ResourceData, client *dbaas.API) error {
Expand Down
1 change: 1 addition & 0 deletions selectel/resource_selectel_dbaas_database_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func resourceDBaaSDatabaseV1() *schema.Resource {
ru7Region,
ru8Region,
ru9Region,
nl1Region,
}, false),
},
"datastore_id": {
Expand Down
10 changes: 2 additions & 8 deletions selectel/resource_selectel_dbaas_datastore_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func resourceDBaaSDatastoreV1() *schema.Resource {
ru7Region,
ru8Region,
ru9Region,
nl1Region,
}, false),
},
"subnet_id": {
Expand Down Expand Up @@ -220,21 +221,14 @@ func resourceDBaaSDatastoreV1Create(ctx context.Context, d *schema.ResourceData,
return diag.FromErr(errParseDatastoreV1Restore(err))
}

configMap := d.Get("config").(map[string]interface{})
config := make(map[string]interface{})
for paramName, paramValue := range configMap {
paramValueStr := paramValue.(string)
config[paramName] = convertFieldFromStringToType(paramValueStr)
}

datastoreCreateOpts := dbaas.DatastoreCreateOpts{
Name: d.Get("name").(string),
TypeID: d.Get("type_id").(string),
SubnetID: d.Get("subnet_id").(string),
NodeCount: d.Get("node_count").(int),
Pooler: pooler,
Restore: restore,
Config: config,
Config: d.Get("config").(map[string]interface{}),
}

if flavorOk {
Expand Down
1 change: 1 addition & 0 deletions selectel/resource_selectel_dbaas_extension_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func resourceDBaaSExtensionV1() *schema.Resource {
ru7Region,
ru8Region,
ru9Region,
nl1Region,
}, false),
},
"available_extension_id": {
Expand Down
1 change: 1 addition & 0 deletions selectel/resource_selectel_dbaas_grant_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func resourceDBaaSGrantV1() *schema.Resource {
ru7Region,
ru8Region,
ru9Region,
nl1Region,
}, false),
},
"datastore_id": {
Expand Down
1 change: 1 addition & 0 deletions selectel/resource_selectel_dbaas_mysql_database_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func resourceDBaaSMySQLDatabaseV1() *schema.Resource {
ru7Region,
ru8Region,
ru9Region,
nl1Region,
}, false),
},
"datastore_id": {
Expand Down
Loading

0 comments on commit 3730c4e

Please sign in to comment.