Skip to content

Commit

Permalink
Support #2118: KS APIkey Reset
Browse files Browse the repository at this point in the history
  • Loading branch information
kavya498 authored and hkantare committed Dec 30, 2020
1 parent 861a6ef commit 381154f
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 26 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.12

require (
github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75 // indirect
github.com/IBM-Cloud/bluemix-go v0.0.0-20201222104207-ac387d69450c
github.com/IBM-Cloud/bluemix-go v0.0.0-20201230053147-e03f93e5013a
github.com/IBM-Cloud/power-go-client v1.0.53
github.com/IBM/apigateway-go-sdk v0.0.0-20200414212859-416e5948678a
github.com/IBM/go-sdk-core v1.1.0
Expand Down
17 changes: 2 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75/go.mod h1:4/6eNcqZ09
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/go.mod h1:nuWgzSkT5PnyOd+272uUmV0dnAnAn42Mk7PiQC5VzN4=
github.com/IBM-Cloud/bluemix-go v0.0.0-20201222104207-ac387d69450c h1:iuHCP1LnLY5mWCeByCoTv+JU+PkMcK7c7pY+CEg4qYo=
github.com/IBM-Cloud/bluemix-go v0.0.0-20201222104207-ac387d69450c/go.mod h1:gPJbH1etcDj7qS/hBRiLuYW9CY0bRcostSKusa51xR0=
github.com/IBM-Cloud/bluemix-go v0.0.0-20201230053147-e03f93e5013a h1:Lg81dp8Ohj/I6evkdWTEOZo4/DCuXtkXL03OykiZ2Co=
github.com/IBM-Cloud/bluemix-go v0.0.0-20201230053147-e03f93e5013a/go.mod h1:gPJbH1etcDj7qS/hBRiLuYW9CY0bRcostSKusa51xR0=
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.6.7/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
github.com/IBM-Cloud/power-go-client v1.0.53 h1:v29RRy5S3z950rgOXGEHab4h0LI9L8/8qot30JjmQXs=
github.com/IBM-Cloud/power-go-client v1.0.53/go.mod h1:+mOxjyLeLIloR4EMHTpiDbN+FilZpiVHTwu5eqi+cbI=
Expand Down Expand Up @@ -65,7 +65,6 @@ github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5 h1:VauE2GcJNZFun2O
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5/go.mod h1:gxOHeajFfvGQh/fxlC8oOKBe23xnnJTif00IFFbiT+o=
github.com/Shopify/sarama v1.26.4 h1:+17TxUq/PJEAfZAll0T7XJjSgQWCpaQSoki/x5yN8o8=
github.com/Shopify/sarama v1.26.4/go.mod h1:NbSGBSSndYaIhRcBtY9V0U7AyH+x71bG668AuWys/yU=
github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/Unknwon/com v0.0.0-20151008135407-28b053d5a292/go.mod h1:KYCjqMOeHpNuTOiFQU6WEcTG7poCJrUs0YgyHNtn1no=
github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw=
Expand Down Expand Up @@ -158,7 +157,6 @@ github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/form3tech-oss/jwt-go v3.2.1+incompatible h1:xdtqez379uWVJ9P3qQMX8W+F/nqsTdUvyMZB36tnacA=
github.com/form3tech-oss/jwt-go v3.2.1+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03DbaAcR7Ks/o=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
Expand Down Expand Up @@ -243,7 +241,6 @@ github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho=
github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0=
github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY=
Expand Down Expand Up @@ -275,7 +272,6 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU
github.com/golang/groupcache v0.0.0-20180513044358-24b0969c4cb7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down Expand Up @@ -319,7 +315,6 @@ github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoA
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
github.com/hashicorp/aws-sdk-go-base v0.4.0/go.mod h1:eRhlz3c4nhqxFZJAahJEFL7gh6Jyj5rQmQc7F9eHFyQ=
github.com/hashicorp/consul v0.0.0-20171026175957-610f3c86a089/go.mod h1:mFrjN1mfidgJfYP1xrJCF+AfRhr6Eaqhb2+sfyn/OOI=
Expand Down Expand Up @@ -402,7 +397,6 @@ github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeY
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/joyent/triton-go v0.0.0-20180313100802-d8f9c0314926/go.mod h1:U+RSyWxWd04xTqnuOQxnai7XGS2PrPY2cfGoDKtMHjA=
Expand All @@ -422,11 +416,9 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
Expand Down Expand Up @@ -534,7 +526,6 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/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/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/posener/complete v1.2.1 h1:LrvDIY//XNo65Lq84G/akBuMGlawHvGBABv8f/ZN6DI=
Expand Down Expand Up @@ -582,7 +573,6 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/svanharmelen/jsonapi v0.0.0-20180618144545-0c0828c3f16d/go.mod h1:BSTlc8jOjh0niykqEGVXOLXdi9o0r0kR8tCYiMvjFgw=
github.com/tencentcloud/tencentcloud-sdk-go v3.0.82+incompatible/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4=
Expand Down Expand Up @@ -792,7 +782,6 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
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/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
Expand All @@ -801,7 +790,6 @@ gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8
gopkg.in/go-playground/validator.v9 v9.30.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
gopkg.in/go-playground/validator.v9 v9.31.0 h1:bmXmP2RSNtFES+bn4uYuHT7iJFJv7Vj+an+ZQdDaD1M=
gopkg.in/go-playground/validator.v9 v9.31.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
gopkg.in/h2non/gock.v1 v1.0.15 h1:SzLqcIlb/fDfg7UvukMpNcWsu7sI5tWwL+KCATZqks0=
gopkg.in/h2non/gock.v1 v1.0.15/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE=
gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/jcmturner/aescts.v1 v1.0.1 h1:cVVZBK2b1zY26haWB4vbBiZrfFQnfbTVrE3xZq6hrEw=
Expand All @@ -823,7 +811,6 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
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.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
Expand Down
24 changes: 23 additions & 1 deletion ibm/data_source_ibm_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,21 @@ func dataSourceIBMContainerCluster() *schema.Resource {
Optional: true,
Description: "If set to false bounded services won't be listed.",
},

"api_key_id": {
Type: schema.TypeString,
Computed: true,
Description: "ID of APIkey",
},
"api_key_owner_name": {
Type: schema.TypeString,
Computed: true,
Description: "Name of the key owner",
},
"api_key_owner_email": {
Type: schema.TypeString,
Computed: true,
Description: "email id of the key owner",
},
ResourceControllerURL: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -414,6 +428,14 @@ func dataSourceIBMContainerClusterRead(d *schema.ResourceData, meta interface{})
return err
}
d.Set(ResourceControllerURL, controller+"/kubernetes/clusters")
apikeyAPI := csClient.Apikeys()
apikeyConfig, err := apikeyAPI.GetApiKeyInfo(name, targetEnv)
if err != nil {
return err
}
d.Set("api_key_id", apikeyConfig.ID)
d.Set("api_key_owner_name", apikeyConfig.Name)
d.Set("api_key_owner_email", apikeyConfig.Email)
d.Set(ResourceName, clusterFields.Name)
d.Set(ResourceCRN, clusterFields.CRN)
d.Set(ResourceStatus, clusterFields.State)
Expand Down
32 changes: 32 additions & 0 deletions ibm/data_source_ibm_container_vpc_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,21 @@ func dataSourceIBMContainerVPCCluster() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"api_key_id": {
Type: schema.TypeString,
Computed: true,
Description: "ID of APIkey",
},
"api_key_owner_name": {
Type: schema.TypeString,
Computed: true,
Description: "Name of the key owner",
},
"api_key_owner_email": {
Type: schema.TypeString,
Computed: true,
Description: "email id of the key owner",
},

ResourceControllerURL: {
Type: schema.TypeString,
Expand Down Expand Up @@ -345,6 +360,23 @@ func dataSourceIBMContainerClusterVPCRead(d *schema.ResourceData, meta interface
if err != nil {
return err
}
csClientv1, err := meta.(ClientSession).ContainerAPI()
if err != nil {
return err
}
apikeyAPI := csClientv1.Apikeys()
v1targetEnv, err := getClusterTargetHeader(d, meta)
if err != nil {
return err
}
apikeyConfig, err := apikeyAPI.GetApiKeyInfo(clusterID, v1targetEnv)
if err != nil {

return err
}
d.Set("api_key_id", apikeyConfig.ID)
d.Set("api_key_owner_name", apikeyConfig.Name)
d.Set("api_key_owner_email", apikeyConfig.Email)
d.Set(ResourceControllerURL, controller+"/kubernetes/clusters")
d.Set(ResourceName, cls.Name)
d.Set(ResourceCRN, cls.CRN)
Expand Down
1 change: 1 addition & 0 deletions ibm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ func Provider() terraform.ResourceProvider {
"ibm_compute_vm_instance": resourceIBMComputeVmInstance(),
"ibm_container_addons": resourceIBMContainerAddOns(),
"ibm_container_alb": resourceIBMContainerALB(),
"ibm_container_api_key_reset": resourceIBMContainerAPIKeyReset(),
"ibm_container_vpc_alb": resourceIBMContainerVpcALB(),
"ibm_container_vpc_worker_pool": resourceIBMContainerVpcWorkerPool(),
"ibm_container_vpc_cluster": resourceIBMContainerVpcCluster(),
Expand Down
76 changes: 76 additions & 0 deletions ibm/resource_ibm_container_api_key_reset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package ibm

import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func resourceIBMContainerAPIKeyReset() *schema.Resource {
return &schema.Resource{
Create: resourceIBMContainerAPIKeyResetUpdate,
Read: resourceIBMContainerAPIKeyResetRead,
Update: resourceIBMContainerAPIKeyResetUpdate,
Delete: resourceIBMContainerAPIKeyResetdelete,

Schema: map[string]*schema.Schema{
"region": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "Region which api key has to be reset",
},
"resource_group_id": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
Description: "ID of Resource Group",
},
"reset_api_key": {
Type: schema.TypeInt,
Optional: true,
Description: "Determines if apikey has to be reset or not",
Default: 1,
},
},
}
}

func resourceIBMContainerAPIKeyResetUpdate(d *schema.ResourceData, meta interface{}) error {

if d.HasChange("reset_api_key") {
apikeyClient, err := meta.(ClientSession).ContainerAPI()
if err != nil {
return err
}
apikeyAPI := apikeyClient.Apikeys()
region := d.Get("region").(string)
targetEnv, err := getClusterTargetHeader(d, meta)
if err != nil {
return err
}
targetEnv.Region = region
err = apikeyAPI.ResetApiKey(targetEnv)
if err != nil {
return err
}
if targetEnv.ResourceGroup == "" {
defaultRg, err := defaultResourceGroup(meta)
if err != nil {
return err
}
targetEnv.ResourceGroup = defaultRg
}

d.SetId(fmt.Sprintf("%s/%s", region, targetEnv.ResourceGroup))
}

return nil
}
func resourceIBMContainerAPIKeyResetRead(d *schema.ResourceData, meta interface{}) error {
return nil
}
func resourceIBMContainerAPIKeyResetdelete(d *schema.ResourceData, meta interface{}) error {
d.SetId("")
return nil
}
17 changes: 9 additions & 8 deletions ibm/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ import (
"strconv"
"strings"

"github.com/IBM/ibm-cos-sdk-go-config/resourceconfigurationv1"
"github.com/IBM/ibm-cos-sdk-go/service/s3"
kp "github.com/IBM/keyprotect-go-client"
"github.com/apache/openwhisk-client-go/whisk"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/softlayer/softlayer-go/datatypes"
"github.com/softlayer/softlayer-go/sl"

"github.com/IBM-Cloud/bluemix-go/api/container/containerv1"
"github.com/IBM-Cloud/bluemix-go/api/container/containerv2"
"github.com/IBM-Cloud/bluemix-go/api/iampap/iampapv1"
Expand All @@ -23,13 +31,6 @@ import (
"github.com/IBM-Cloud/bluemix-go/api/schematics"
"github.com/IBM-Cloud/bluemix-go/api/usermanagement/usermanagementv2"
"github.com/IBM-Cloud/bluemix-go/models"
"github.com/IBM/ibm-cos-sdk-go-config/resourceconfigurationv1"
"github.com/IBM/ibm-cos-sdk-go/service/s3"
kp "github.com/IBM/keyprotect-go-client"
"github.com/apache/openwhisk-client-go/whisk"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/softlayer/softlayer-go/datatypes"
"github.com/softlayer/softlayer-go/sl"
)

const (
Expand Down Expand Up @@ -1797,7 +1798,7 @@ func defaultResourceGroup(meta interface{}) (string, error) {
return "", err
}
if len(grpList) <= 0 {
return "", fmt.Errorf("The targeted resource group could not be found. Make sure you have required permissions to access the resource group.")
return "", fmt.Errorf("The default resource group could not be found. Make sure you have required permissions to access the resource group.")
}
return grpList[0].ID, nil
}
Expand Down
3 changes: 3 additions & 0 deletions website/docs/d/container_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@ The following attributes are exported:
* `public_service_endpoint` - Is public service endpoint enabled to make the master publicly accessible.
* `private_service_endpoint` - Is private service endpoint enabled to make the master privately accessible.
* `crn` - CRN of the instance.
* `api_key_id` - ID of APIkey.
* `api_key_owner_name` - "Name of the key owner.
* `api_key_owner_email` - Email id of the key owner
5 changes: 4 additions & 1 deletion website/docs/d/container_vpc_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ The following attributes are exported:
* `master_url` - Url of the master
* `status` - Status of cluster master.
* `health` - Health of cluster master
* `kube_version` - The Kubernetes version, including at least the major.minor version.To see available versions, run 'ibmcloud ks versions'.
* `kube_version` - The Kubernetes version, including at least the major.minor version.To see available versions, run 'ibmcloud ks versions'.
* `api_key_id` - ID of APIkey.
* `api_key_owner_name` - "Name of the key owner.
* `api_key_owner_email` - Email id of the key owner
Loading

0 comments on commit 381154f

Please sign in to comment.