From 423686e846d8c9a7512b692713b7d93844ba2ae6 Mon Sep 17 00:00:00 2001 From: CharlieBlain Date: Fri, 7 Jan 2022 11:16:52 +0000 Subject: [PATCH] Removed atf and added pkg/utils for reading yaml --- go.mod | 1 - go.sum | 50 -------- pkg/atf/README.md | 182 ----------------------------- pkg/atf/acc.go | 124 -------------------- pkg/atf/constants.go | 21 ---- pkg/atf/helper.go | 160 -------------------------- pkg/atf/helper_test.go | 185 ------------------------------ pkg/atf/reader.go | 255 ----------------------------------------- pkg/utils/utils.go | 20 ++++ 9 files changed, 20 insertions(+), 978 deletions(-) delete mode 100644 pkg/atf/README.md delete mode 100644 pkg/atf/acc.go delete mode 100644 pkg/atf/constants.go delete mode 100644 pkg/atf/helper.go delete mode 100644 pkg/atf/helper_test.go delete mode 100644 pkg/atf/reader.go create mode 100644 pkg/utils/utils.go diff --git a/go.mod b/go.mod index e04a5c2..d4dac6f 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/hashicorp/terraform-plugin-sdk/v2 v2.9.0 github.com/spf13/viper v1.10.0 github.com/stretchr/testify v1.7.0 - github.com/tidwall/gjson v1.12.1 gopkg.in/square/go-jose.v2 v2.6.0 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index 8d437e0..d84956e 100644 --- a/go.sum +++ b/go.sum @@ -27,7 +27,6 @@ cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+Y cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= cloud.google.com/go v0.98.0/go.mod h1:ua6Ush4NALrHk5QXDWnjvZHN93OuF0HfuEPq9I1X0cM= -cloud.google.com/go v0.99.0 h1:y/cM2iqGgGi5D5DQZl6D9STN/3dR/Vx5Mp8s752oJTY= cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= @@ -46,7 +45,6 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0 h1:STgFzyU5/8miMl0//zKh2aQeTyeaUH3WN9bSUiJ09bA= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -56,12 +54,9 @@ github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy86 github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= -github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= @@ -71,7 +66,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/andybalholm/crlf v0.0.0-20171020200849-670099aa064f/go.mod h1:k8feO4+kXDxro6ErPXBRTJ/ro2mf0SsFG8s7doP9kJE= -github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apparentlymart/go-cidr v1.0.1/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= @@ -88,15 +82,12 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= -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/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -127,7 +118,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -144,21 +134,15 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= -github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34= github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-git-fixtures/v4 v4.2.1 h1:n9gGL1Ct/yIw+nfsfr8s4+sbhT+Ncu2SubfXjIWgci8= github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= -github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -177,7 +161,6 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/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= @@ -208,7 +191,6 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= github.com/golang/snappy v0.0.3/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= @@ -226,11 +208,9 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -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/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.2.1 h1:d8MncMlErDFTwQGBK1xhv026j9kqhvw1Qv9IbWT1VLQ= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= 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= @@ -251,22 +231,18 @@ 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/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1 h1:dp3bWCh+PPO1zjRRiCSczJav13sBvG4UhNyVTa1KqdU= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/consul/api v1.11.0/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= 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= github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= -github.com/hashicorp/go-getter v1.5.3 h1:NF5+zOlQegim+w/EUhSLh6QhXHmZMEeHLQzllkQ3ROU= github.com/hashicorp/go-getter v1.5.3/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXjMEgDD8+i7ZI= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= @@ -285,7 +261,6 @@ github.com/hashicorp/go-plugin v1.4.1 h1:6UltRQlLN9iZO513VveELp5xyaFxVD2+1OVylE+ github.com/hashicorp/go-plugin v1.4.1/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ38b18Udy6vYQ= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= @@ -302,7 +277,6 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl/v2 v2.3.0 h1:iRly8YaMwTBAKhn1Ybk7VSdzbnopghktCD031P8ggUE= github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8= -github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= @@ -310,9 +284,7 @@ github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOn github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= -github.com/hashicorp/terraform-exec v0.15.0 h1:cqjh4d8HYNQrDoEmlSGelHmg2DYDh5yayckvJ5bV18E= github.com/hashicorp/terraform-exec v0.15.0/go.mod h1:H4IG8ZxanU+NW0ZpDRNsvh9f0ul7C0nHP+rUR/CHs7I= -github.com/hashicorp/terraform-json v0.13.0 h1:Li9L+lKD1FO5RVFRM1mMMIBDoUHslOniyEi5CM+FWGY= github.com/hashicorp/terraform-json v0.13.0/go.mod h1:y5OdLBCT+rxbwnpxZs9kGL7R9ExU76+cpdY8zHwoazk= github.com/hashicorp/terraform-plugin-go v0.4.0 h1:LFbXNeLDo0J/wR0kUzSPq0RpdmFh2gNedzU0n/gzPAo= github.com/hashicorp/terraform-plugin-go v0.4.0/go.mod h1:7u/6nt6vaiwcWE2GuJKbJwNlDFnf5n95xKw4hqIVr58= @@ -326,15 +298,12 @@ github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47 github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= 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/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= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -343,11 +312,9 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.11.2 h1:MiK62aErc3gIiVEtyzKfeOHgW7atJb5g/KNX5m3c2nQ= github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= @@ -366,7 +333,6 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+ github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= @@ -393,7 +359,6 @@ github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFW github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= @@ -426,7 +391,6 @@ github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhEC github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -453,7 +417,6 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= @@ -482,21 +445,13 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/tidwall/gjson v1.12.1 h1:ikuZsLdhr8Ws0IdROXUS1Gi4v9Z4pGqpX/CvJkxvfpo= -github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= -github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= -github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ= github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= -github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -516,7 +471,6 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -635,7 +589,6 @@ golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 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= @@ -718,7 +671,6 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211205182925-97ca703d548d h1:FjkYO/PPp4Wi0EAUOVLxePm7qVW4r4ctbWpURyuOD0E= golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -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= @@ -824,7 +776,6 @@ google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqiv google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU= google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.62.0 h1:PhGymJMXfGBzc4lBRmrx9+1w4w2wEzURHNGF/sD/xGc= google.golang.org/api v0.62.0/go.mod h1:dKmwPCydfsad4qCH08MSdgWjfHOyfpd4VtDGgRFdavw= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -958,7 +909,6 @@ gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= -gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/pkg/atf/README.md b/pkg/atf/README.md deleted file mode 100644 index 961c482..0000000 --- a/pkg/atf/README.md +++ /dev/null @@ -1,182 +0,0 @@ -# Running and Writing Acceptance Tests for VMaaS -- [Running an Acceptance Test](#running-an-acceptance-test) -- [Writing an Acceptance Test](#writing-an-acceptance-test) - - [Writing Acceptance Test for New Resource/Datasource](#writing-acceptance-test-for-new-resource-datasource) -- [Writing Acceptance Test Suite](#writing-acceptance-test-suite) - - [Acceptance Test Suite folder Structure](#acceptance-test-suite-folder-structure) - -## Running an Acceptance Test - -Acceptance tests can be run using the `acceptance` target in the Terraform -`Makefile`. Prior to running acceptance test you may need to set provider -IAM configuration as environment. - -```bash -export HPEGL_IAM_SERVICE_URL= -export HPEGL_TENANT_ID= -export HPEGL_USER_SECRET= -export HPEGL_USER_ID= -export HPEGL_VMAAS_LOCATION= -export HPEGL_VMAAS_SPACE_NAME= -``` - -By Default acceptance test will run test cases from folder `acc-testcases`. -If you need to specify different test suite or folder, please set environment -`TF_ACC_TEST_PATH` - -For example: -```bash -export TF_ACC_TEST_PATH=$PWD/mytestcases -make acceptance -``` -above script will run acceptance test from specified folder and it is expected that -you will cover all the test cases there. - - -## Writing an Acceptance Test - -Acceptance test should be written using vmaas acceptance test framework or `atf`. This -framework supports writing test suites for both resources and data sources. - -### Writing Acceptance Test for New Resource/Datasource - -Create new test file wil the format `__test.go`. -Exmaple: -- `resource_instance_test.go` (for resource `hpegl_vmaas_instance`). -- `data_source_network_test.go` (for data source `hpegl_vmaas_network`) -You only need to create a new file if there is no test file exists. Otherwise you can use the existing file -and add your test suite there. - -If you need to create entire new test suite then create new Test function as well. -Please follow the naming convention for function name as `TestAcc`. - -General example to create acceptance test -```go -// This example is for acceptance test for plan data source -func TestAccResourceMyResourceCreate(t *testing.T) { - acc := &atf.Acc{ - PreCheck: testAccPreCheck, - Providers: testAccProviders, - ResourceName: "hpegl_vmaas_plan", - Version: "case_2", // Use version if you need to run multiple step cases, if not then skip this field - // Version field should also be unique - GetAPI: func(attr map[string]string) (interface{}, error) { - cl, cfg := getAPIClient() - iClient := api_client.PlansAPIService{ - Client: cl, - Cfg: cfg, - } - id := toInt(attr["id"]) - - return iClient.GetSpecificMyResource(context.Background(), id) - }, - - ValidateResourceDestroy: func(attr map[string]string) error{ - // validate resource is deleted - } - } - - acc.RunDataSourceTests(t) -} -``` - -`GetAPI` function should contains Get Specific API for the a resource/Data source. This is -used for validation of the specific resource/data source. - -## Writing Acceptance Test Suite - -Acceptance test suite should be written over default location `acc-testcases` if default acceptance -test suite is used, or else add test case in `TF_ACC_TEST_PATH` folder. - -### Acceptance Test Suite folder Structure - -TF_ACC_TEST_PATH folder structure as follows - - . - ├── resource - │ ├─ my_resource.yaml - │ ├─ my_resource-case_2.yaml - │ ├─ ... - │ └─ . - └── data-sources - ├─ my_datasource.yaml - ├─ ... - └─ . - -The filename of the test should be the resource/data_source name without "hpegl_vmaas_" string. -for example, resource `hpegl_vmaas_instance` filename will be `instance.yaml`. - -Also you may needto append `Version` (if you specified one in the test case on corresponding resource test go file) -prepended with `-`. -for example, resource `hpegl_vmaas_instance` with `Version: "case2"` will be `instance-case2.yaml`. - -### Creating new test suite - -To create entire new test suite, where you need to create a resource (or run new Plan for data source/Resource), -optionally apply updates on resource, create new file with appended `Version`(if a test suite already presented) -along with filename (In this case you also need to create new test function in corresponding go test file with `Version`), - -Structure of the test suite yaml file will be -```yml -acc: # this should be parent field for every test suite - - name: # you can specify name of the test suite here, Apart from the readability - # there are no real world use for the 'name' field - vars: # Variable decleration, this is can be used to generate random values and store in it - rand_name: "%rand_int{0,100}" - rand_size: "%rand_int" - data: 235 - config: |- # Config holds the terraform actual configuration. - < - First configuration in test suite will create the resource and rest will update the resource. - If `expect_error` is specified in first config, then second configuration will be used to - create a new resource. - terraform configuration. Here you don't want to - specify resource name or local name, but only the fields under it. - for example: - ``` - resource "hpegl_vmaas_my_resource" "tf_resource" { - name = "resource_name" - tag { - tag_name = "test" - } - } - ``` - above configuration in test case should represent as follows - - config: - name = "resource_name" - tag { - tag_name = "test" - } - - Acceptance test framework will prepend the resource name and local name along - with this - - To use variable name in configuration give $(variable_name), atf will resolve and replace - with proper value > - - validation: # validation can contains n number of child validations - json.instance.status: "running" # Currently json or tf validations are supported - # in json validation, atf framework will call get API for instance with ID of the created instance - # and get instance.status field from response json and check equality to "running" - tf.network.0.is_primary: true # in tf validation corresponding field in state field is compared to RHS - expect_error: - - - name: - config: |- - < this configuration will result into update operation. - Here you need to provide entire configuration with updated fields - For example, to change name of the resource from "resource_name" to "resource_name_2" - the config looks as follows - - config: - name = "resource_name_2" - tag { - tag_name = "test" - } - validation: # here you can validate updated fields as well as existing fields - ... - ... - -ignore: -``` diff --git a/pkg/atf/acc.go b/pkg/atf/acc.go deleted file mode 100644 index 30307f9..0000000 --- a/pkg/atf/acc.go +++ /dev/null @@ -1,124 +0,0 @@ -// (C) Copyright 2021 Hewlett Packard Enterprise Development LP - -package atf - -import ( - "fmt" - "os" - "strings" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -// GetAPIFunc accepts terraform states attribures as params and -// expects response and error as return values -type GetAPIFunc func(attr map[string]string) (interface{}, error) -type ValidateResourceDestroyFunc func(attr map[string]string) error -type Acc struct { - // in PreCheck each service team should provides validation which done - // beforehand (before running the configurations). For example valildate - // paritcular env is set or not. - PreCheck func(t *testing.T) - // Providers used in testing - Providers map[string]*schema.Provider - // GetAPI used to check the truth and do the validation purpose after the - // configuration applied on the test. GetAPI expected to be an API call - // and get the specific resource from the infrastructure. - GetAPI GetAPIFunc - // Name of the resource/Data source - ResourceName string - // Version indicates the version of test case. This should be unique accross - // all the test cases for a specific resource/data source. Version helps to - // write different and independent test cases of same resource/ data source - Version string - ValidateResourceDestroy ValidateResourceDestroyFunc -} - -// RunResourcePlanTest to run resource plan only test case. This will take first -// config from specific resource. -func (a *Acc) RunResourcePlanTest(t *testing.T) { - checkSkip(t) - a.runPlanTest(t, true) -} - -// RunDataSourceTests to run data source plan only test case. This will take first -// config from specific data source -func (a *Acc) RunDataSourceTests(t *testing.T) { - checkSkip(t) - r := newReader(t, false, a.ResourceName) - testSteps := r.getTestCases(a.Version, a.GetAPI) - - resource.ParallelTest(t, resource.TestCase{ - IsUnitTest: false, - PreCheck: func() { a.PreCheck(t) }, - Providers: a.Providers, - Steps: testSteps, - }) -} - -// RunResourceTests creates test cases and run tests which includes create/update/delete/read -func (a *Acc) RunResourceTests(t *testing.T) { - checkSkip(t) - // skip resource create/update/delete operation in short mode - if testing.Short() { - t.Skipf("Skipping %s resource testing in short mode", a.ResourceName) - } - - // populate test cases - r := newReader(t, true, a.ResourceName) - testSteps := r.getTestCases(a.Version, a.GetAPI) - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { a.PreCheck(t) }, - Providers: a.Providers, - CheckDestroy: resource.ComposeTestCheckFunc( - a.checkResourceDestroy, - ), - Steps: testSteps, - }) -} - -// checkResourceDestroy checks resource destroy conditions. This will check the resource actually exists -// and then run user validation if any -func (a *Acc) checkResourceDestroy(s *terraform.State) error { - rs, ok := s.RootModule().Resources[fmt.Sprintf("%s.tf_%s", a.ResourceName, getLocalName(a.ResourceName))] - if !ok { - return fmt.Errorf("[Check Destroy] resource %s not found", a.ResourceName) - } - // skip destroy validation if developer doesn't specify - if a.ValidateResourceDestroy == nil { - return nil - } - - return a.ValidateResourceDestroy(rs.Primary.Attributes) -} - -// runs plan test for resource or data source. only first config from test case -// will considered on plan test -func (a *Acc) runPlanTest(t *testing.T, isResource bool) { - // populate test cases - r := newReader(t, isResource, a.ResourceName) - testSteps := r.getTestCases(a.Version, a.GetAPI) - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { a.PreCheck(t) }, - Providers: a.Providers, - Steps: []resource.TestStep{ - { - Config: testSteps[0].Config, - PlanOnly: true, - ExpectNonEmptyPlan: true, - Check: testSteps[0].Check, - }, - }, - }) -} - -// checkSkip ensure to exclude acceptance test while running UTs. -func checkSkip(t *testing.T) { - if strings.ToLower(os.Getenv("TF_ACC")) != "true" && os.Getenv("TF_ACC") != "1" { - t.Skip("acceptance test is skipped since TF_ACC is not set") - } -} diff --git a/pkg/atf/constants.go b/pkg/atf/constants.go deleted file mode 100644 index 53640a5..0000000 --- a/pkg/atf/constants.go +++ /dev/null @@ -1,21 +0,0 @@ -// (C) Copyright 2021 Hewlett Packard Enterprise Development LP - -package atf - -const providerStanza = ` - provider hpegl { - vmaas {} - } -` - -var accTestPath = "../../acc-testcases" - -const ( - accKey = "acc" - jsonKey = "json" - tfKey = "tf" - - randMaxLimit = 9999999 - testFuncPrefix = "Test" - AccTestPathKey = "TF_ACC_TEST_PATH" -) diff --git a/pkg/atf/helper.go b/pkg/atf/helper.go deleted file mode 100644 index bf0d76a..0000000 --- a/pkg/atf/helper.go +++ /dev/null @@ -1,160 +0,0 @@ -// (C) Copyright 2021 Hewlett Packard Enterprise Development LP - -package atf - -import ( - "crypto/md5" - "encoding/json" - "fmt" - "math/rand" - "reflect" - "runtime" - "strconv" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/tidwall/gjson" -) - -// validateResource validates the resource exists in state file -func validateResource(name string, validations []validation, getAPI GetAPIFunc) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return fmt.Errorf("[Validate Resource] resource %s not found", name) - } - - id := rs.Primary.Attributes["id"] - if id == "" { - return fmt.Errorf("resource %s ID is not set", name) - } - - resp, err := getAPI(rs.Primary.Attributes) - if err != nil { - return err - } - - jsonBody, err := json.Marshal(resp) - if err != nil { - return err - } - jsonStr := string(jsonBody) - for _, v := range validations { - var result string - if v.isJSON { - result = gjson.Get(jsonStr, v.key).String() - } else { - result = rs.Primary.Attributes[v.key] - } - if result != fmt.Sprint(v.value) { - return fmt.Errorf("validation failed for %s. On API response, expected %s = %s, but got %v", - name, v.key, result, v.value) - } - } - - return nil - } -} - -// getLocalName truncates hpegl_serviceName_ and returns back remaining. -func getLocalName(res string) string { - count := 0 - for i, r := range res { - if count == 2 { - return res[i:] - } - if r == '_' { - count++ - } - } - - panic("invalid resource name") -} - -func getTag(isResource bool) string { - if isResource { - return "resources" - } - - return "data-sources" -} - -func getType(isResource bool) string { - if isResource { - return "resource" - } - - return "data" -} - -func toInt(str string) int { - i, _ := strconv.Atoi(str) - - return i -} - -// newRand will create different random number if it is called from different -// go routine. This will ensure there will be no collision in random number and -// Parallel testing is possible -func newRand() *rand.Rand { - // get the parent test function name - s := myCaller() - // hash the test - m := md5.New() - m.Write([]byte(s)) - sourceStr := m.Sum(nil) - var sourceInt int64 - for _, i := range sourceStr { - sourceInt += int64(i) - } - - return rand.New(rand.NewSource(sourceInt + time.Now().Unix())) -} - -func getFrame(skipFrames int) string { - // We need the frame at index skipFrames+2, since we never want runtime.Callers and getFrame - targetFrameIndex := skipFrames + 2 - - // Set size to targetFrameIndex+2 to ensure we have room for one more caller than we need - programCounters := make([]uintptr, targetFrameIndex+2) - n := runtime.Callers(0, programCounters) - - pkgName := reflect.TypeOf(reader{}).PkgPath() - - if n > 0 { - frames := runtime.CallersFrames(programCounters[:n]) - for more, frameIndex := true, 0; more && frameIndex <= targetFrameIndex; frameIndex++ { - var frameCandidate runtime.Frame - frameCandidate, more = frames.Next() - - frameName := frameCandidate.Function - if len(frameName) > len(pkgName)+5 && frameName[len(pkgName)+1:len(pkgName)+5] == testFuncPrefix { - return frameName - } - } - } - - return "unknown" -} - -// MyCaller returns the caller of the function that called it :), that is -// the parent test case function name -func myCaller() string { - // Skip GetCallerFunctionName and the function to get the caller of - return getFrame(15) -} - -// join strings wih '.' -func path(v ...interface{}) string { - if len(v) == 0 { - return "" - } - - var p string - for _, val := range v { - p += "." + fmt.Sprint(val) - } - - return p[1:] -} diff --git a/pkg/atf/helper_test.go b/pkg/atf/helper_test.go deleted file mode 100644 index b1e17de..0000000 --- a/pkg/atf/helper_test.go +++ /dev/null @@ -1,185 +0,0 @@ -// (C) Copyright 2021 Hewlett Packard Enterprise Development LP - -package atf - -import ( - "strings" - "testing" -) - -func Test_path(t *testing.T) { - tests := []struct { - name string - args []interface{} - want string - }{ - { - name: "2 value", - args: []interface{}{"acc", 0}, - want: "acc.0", - }, - { - name: "1 value", - args: []interface{}{"acc"}, - want: "acc", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := path(tt.args...); got != tt.want { - t.Errorf("path() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_getLocalName(t *testing.T) { - type args struct { - res string - } - tests := []struct { - name string - args args - want string - }{ - { - name: "Test case 1: hpegl_vmaas_instance", - args: args{ - res: "hpegl_vmaas_instance", - }, - want: "instance", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := getLocalName(tt.args.res); got != tt.want { - t.Errorf("getLocalName() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_getTag(t *testing.T) { - type args struct { - isResource bool - } - tests := []struct { - name string - args args - want string - }{ - { - name: "Test case 1- resource", - args: args{ - isResource: true, - }, - want: "resources", - }, - { - name: "Test case 2- data source", - args: args{ - isResource: false, - }, - want: "data-sources", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := getTag(tt.args.isResource); got != tt.want { - t.Errorf("getTag() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_getType(t *testing.T) { - type args struct { - isResource bool - } - tests := []struct { - name string - args args - want string - }{ - { - name: "Test case 1, resource", - args: args{ - isResource: true, - }, - want: "resource", - }, - { - name: "Test case 2, data source", - args: args{ - isResource: false, - }, - want: "data", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := getType(tt.args.isResource); got != tt.want { - t.Errorf("getType() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_toInt(t *testing.T) { - type args struct { - str string - } - tests := []struct { - name string - args args - want int - }{ - { - name: "Test 1", - args: args{ - str: "12", - }, - want: 12, - }, - { - name: "Test 2, invalid data", - args: args{ - str: "abc", - }, - want: 0, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := toInt(tt.args.str); got != tt.want { - t.Errorf("toInt() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_getFrame(t *testing.T) { - type args struct { - skipFrames int - } - tests := []struct { - name string - args args - want string - }{ - { - name: "Test case 1", - args: args{ - skipFrames: 10, - }, - want: "Test_getFrame", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := getFrame(tt.args.skipFrames); !strings.Contains(got, tt.want) { - t.Errorf("getFrame() = %v, should cotains %v", got, tt.want) - } - }) - } -} diff --git a/pkg/atf/reader.go b/pkg/atf/reader.go deleted file mode 100644 index d71ccfa..0000000 --- a/pkg/atf/reader.go +++ /dev/null @@ -1,255 +0,0 @@ -// (C) Copyright 2021 Hewlett Packard Enterprise Development LP - -// package atf or acceptance-test-framework consists of helper files to parse, -// validate and run acceptance test with vmaas specified terraform acceptance -// test case format -package atf - -import ( - "fmt" - "os" - "regexp" - "strconv" - "strings" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/spf13/viper" -) - -// accConfig struct holds terraform configuration of a resource/data source -// along with parsed validations -type accConfig struct { - // terraform configuration - config string - validations []validation -} - -// validation holds parsed validation -type validation struct { - // isJSON denotes whether this validate against Get API or - // terraform state file - isJSON bool - // json field key or state file attribute key - key string - // value is a singleton data which we will validate against - value interface{} -} - -// reader encapsulate all the reading and parsing test files -type reader struct { - t *testing.T - // denotes whether this is resource or data source - isResource bool - // resource/data source name - name string - // expectError - expectError *regexp.Regexp - // all the parsed variables stored in vars map - vars map[string]interface{} -} - -// newReader retun new reader instance -func newReader(t *testing.T, isResource bool, name string) *reader { - return &reader{ - t: t, - isResource: isResource, - name: name, - vars: make(map[string]interface{}), - } -} - -func (r *reader) fatalf(format string, v ...interface{}) { - r.t.Fatalf("[acc-test] test case for resource "+r.name+" failed. "+format, v...) -} - -func (r *reader) skipf(format string, v ...interface{}) { - r.t.Skipf("[acc-test] test case for resource "+r.name+" is skipped. "+format, v...) -} - -// parse variable decleration in 'vars:' field -func (r *reader) readVars(v *viper.Viper) { - vars, ok := v.Get("vars").(map[string]interface{}) - if !ok { - return - } - - for key, val := range vars { - r.vars[key] = parseMeta(fmt.Sprint(val)) - } -} - -// getViperConfig read a file using viper. The filepath to the test will determin by following logic -// ${TF_ACC_TEST_PATH}/(resource/data-sources)/ -func (r *reader) getViperConfig(version string) *viper.Viper { - tfName := getLocalName(r.name) - if path := os.Getenv(AccTestPathKey); path != "" { - accTestPath = path - } - var postfix string - if version != "" { - postfix = fmt.Sprintf("-%s", version) - } - v := viper.New() - v.SetConfigFile(fmt.Sprintf("%s/%s/%s%s.yaml", accTestPath, getTag(r.isResource), tfName, postfix)) - err := v.ReadInConfig() - if err != nil { - r.skipf("error while reading config, %v", err) - } - - return v -} - -// replaceVar replaces with varaibles with thier definition -func (r *reader) replaceVar(vars map[string]interface{}, config string) string { - exp := `\$\([a-zA-Z_0-9]+\)` - reg := regexp.MustCompile(exp) - - // loop through all the variables on the configuration and replace with appropriate - // values - matches := reg.FindAllString(config, -1) - for _, m := range matches { - varName, ok := vars[m[2:len(m)-1]] - // check variable definition exists - if !ok { - r.fatalf("variable definition for %s not found", varName) - } - config = strings.Replace(config, m, fmt.Sprint(varName), 1) - } - - return config -} - -// parseMeta currently supports generating of random string. But in future this -// can enhance to support random string or any other data types. -// %rand_int will generate random number under randMaxLimit -// %rand_int{a,b} will generate random number in between a and b. -func parseMeta(data string) string { - exp := `%(rand_int)(\{[0-9]+,[0-9]+\})?` - reg := regexp.MustCompile(exp) - - matches := reg.FindAllString(data, -1) - var randInt int - r := newRand() - for _, m := range matches { - offReg := regexp.MustCompile(`[0-9]+,[0-9]`) - numStr := offReg.FindString(m) - if numStr != "" { - intSplit := strings.Split(numStr, ",") - n1 := toInt(intSplit[0]) - n2 := toInt(intSplit[1]) - randInt = r.Intn(n2-n1) + n1 - } else { - randInt = r.Intn(randMaxLimit) - } - data = strings.Replace(data, m, strconv.Itoa(randInt), 1) - } - - return data -} - -// parseValidations take care parsing the validation and populate validation struct -// currently we are only supporting json/tf validation. Here we can't use any -// meta function (such as len() or greatedThan() etc) on validation, but can be included -// in near future -func (r *reader) parseValidations(vip *viper.Viper, i int) []validation { - vls, ok := vip.Get(fmt.Sprintf("%s.%d.validations", accKey, i)).(map[interface{}]interface{}) - if !ok { - return nil - } - m := make([]validation, 0, len(vls)) - for k, v := range vls { - kStr := k.(string) - kSplit := strings.Split(kStr, ".") - if len(kSplit) > 1 && (kSplit[0] == jsonKey || kSplit[0] == tfKey) { - isJSON := false - if kSplit[0] == jsonKey { - isJSON = true - } - - m = append(m, validation{ - isJSON: isJSON, - key: kStr[len(kSplit[0])+1:], - value: v, - }) - } else { - r.fatalf("invalid validation format. validation format should be '[json|tf].key1.key2....keyn: value'") - } - } - - return m -} - -// parseExpectErr converts string parsed by user to regex object -func (r *reader) parseExpectErr(v *viper.Viper, i int) { - if expectErrStr := v.GetString(path(accKey, i, "expect_error")); expectErrStr != "" { - var err error - r.expectError, err = regexp.Compile(expectErrStr) - if err != nil { - r.fatalf("error while compiling regex %s, got error %v", expectErrStr, err) - } - } -} - -// parseConfig populates terraform configuration and parse to accConfig -func (r *reader) parseConfig(v *viper.Viper) []accConfig { - tfKey := getLocalName(r.name) - - testCases := v.Get(accKey).([]interface{}) - configs := make([]accConfig, len(testCases)) - // loop each test case in a file and append following line - // tf_ { - // At the end of loop we will have a complete configuration along - // with provider config as well - for i := range testCases { - tfConfig := r.replaceVar(r.vars, v.GetString(path(accKey, i, "config"))) - configs[i].config = fmt.Sprintf(` - %s - %s "%s" "tf_%s" { - %s - } - `, - providerStanza, getType(r.isResource), r.name, tfKey, tfConfig, - ) - // parse expect error and validation as well - r.parseExpectErr(v, i) - configs[i].validations = r.parseValidations(v, i) - } - - return configs -} - -// getTestCases populate TestSteps -func (r *reader) getTestCases(version string, getAPI GetAPIFunc) []resource.TestStep { - v := r.getViperConfig(version) - // ignore field in test suite can be used to skip specific test file altogather without - // actually deleting it - if v.GetBool("ignore") { - r.t.Skip("ignoring tests for resource ", r.name) - } - - r.readVars(v) - configs := r.parseConfig(v) - testSteps := make([]resource.TestStep, 0, len(configs)) - - tag := "" - if !r.isResource { - tag = "data." - } - - for _, c := range configs { - testSteps = append(testSteps, resource.TestStep{ - Config: c.config, - Check: resource.ComposeTestCheckFunc( - validateResource( - fmt.Sprintf("%s%s.tf_%s", tag, r.name, getLocalName(r.name)), - c.validations, - getAPI, - ), - ), - ExpectError: r.expectError, - }) - } - - return testSteps -} diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go new file mode 100644 index 0000000..8d20a4f --- /dev/null +++ b/pkg/utils/utils.go @@ -0,0 +1,20 @@ +// (C) Copyright 2021 Hewlett Packard Enterprise Development LP +package utils + +import ( + "os" + + "github.com/spf13/viper" +) + +func ReadAccConfig(path string) { + if os.Getenv("TF_ACC") == "true" { + viper.AddConfigPath(path) + viper.SetConfigType("yaml") + viper.SetConfigName(os.Getenv("TF_ACC_CONFIG")) + err := viper.ReadInConfig() + if err != nil { + panic("fatal error config file: " + err.Error()) + } + } +}