From 4a6f85e01fee4b4817503a2178dea226692fe0f0 Mon Sep 17 00:00:00 2001 From: Daniel Banck Date: Wed, 15 Feb 2023 14:53:55 +0100 Subject: [PATCH] Generate function signatures for Terraform >= 1.4 --- go.mod | 8 +- go.sum | 137 ++- internal/funcs/generated/1.4.0.go | 1330 +++++++++++++++++++++++++ internal/funcs/generated/README.md | 22 + internal/funcs/generated/doc.go | 4 + internal/funcs/generated/functions.go | 19 + internal/funcs/generated/gen/gen.go | 286 ++++++ schema/core_schema.go | 1 + schema/functions.go | 4 + 9 files changed, 1804 insertions(+), 7 deletions(-) create mode 100644 internal/funcs/generated/1.4.0.go create mode 100644 internal/funcs/generated/README.md create mode 100644 internal/funcs/generated/doc.go create mode 100644 internal/funcs/generated/functions.go create mode 100644 internal/funcs/generated/gen/gen.go diff --git a/go.mod b/go.mod index 884b8023..a2dbbd76 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,10 @@ require ( github.com/google/go-cmp v0.5.9 github.com/hashicorp/go-cleanhttp v0.5.2 github.com/hashicorp/go-version v1.6.0 + github.com/hashicorp/hc-install v0.5.0 github.com/hashicorp/hcl-lang v0.0.0-20230214101706-045d9c04b46b github.com/hashicorp/hcl/v2 v2.16.1 + github.com/hashicorp/terraform-exec v0.17.3 github.com/hashicorp/terraform-json v0.15.0 github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c github.com/mh-cbon/go-fmt-fail v0.0.0-20160815164508-67765b3fbcb5 @@ -22,6 +24,8 @@ require ( github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect - golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect - golang.org/x/text v0.3.7 // indirect + golang.org/x/crypto v0.5.0 // indirect + golang.org/x/mod v0.8.0 // indirect + golang.org/x/net v0.5.0 // indirect + golang.org/x/text v0.6.0 // indirect ) diff --git a/go.sum b/go.sum index 1a6fd0f9..533c6555 100644 --- a/go.sum +++ b/go.sum @@ -1,62 +1,140 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= +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/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 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= 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/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= +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/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-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= 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= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/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-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/hc-install v0.5.0 h1:D9bl4KayIYKEeJ4vUDe9L5huqxZXczKaykSRcmQ0xY0= +github.com/hashicorp/hc-install v0.5.0/go.mod h1:JyzMfbzfSBSjoDCRPna1vi/24BEDxFaCPfdHtM5SCdo= github.com/hashicorp/hcl-lang v0.0.0-20230214101706-045d9c04b46b h1:gA/Xpuy6huQJnOSlHlFhTZzajl4Rb7UiASvMz8RGEIM= github.com/hashicorp/hcl-lang v0.0.0-20230214101706-045d9c04b46b/go.mod h1:alGNoXhoyCKUDHKM6iK88G5bgPym9agemDf6AEB26j0= github.com/hashicorp/hcl/v2 v2.16.1 h1:BwuxEMD/tsYgbhIW7UuI3crjovf3MzuFWiVgiv57iHg= github.com/hashicorp/hcl/v2 v2.16.1/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/terraform-exec v0.17.3 h1:MX14Kvnka/oWGmIkyuyvL6POx25ZmKrjlaclkx3eErU= +github.com/hashicorp/terraform-exec v0.17.3/go.mod h1:+NELG0EqQekJzhvikkeQsOAZpsw0cv/03rbeQJqscAI= github.com/hashicorp/terraform-json v0.15.0 h1:/gIyNtR6SFw6h5yzlbDbACyGvIhKtQi8mTsbkNd79lE= github.com/hashicorp/terraform-json v0.15.0/go.mod h1:+L1RNzjDU5leLFZkHTFTbJXaoqUC6TqXlFgDoOXrtvk= github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg= github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +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/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/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -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/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= +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-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mh-cbon/go-fmt-fail v0.0.0-20160815164508-67765b3fbcb5 h1:shw+DWUaHIyW64Tv30ASCbC6QO6fLy+M5SJb5pJVEI4= github.com/mh-cbon/go-fmt-fail v0.0.0-20160815164508-67765b3fbcb5/go.mod h1:nHPoxaBUc5CDAMIv0MNmn5PBjWbTs9BI/eh30/n0U6g= +github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= +github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +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-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= -github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= +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/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 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/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/vmihailenco/msgpack v3.3.3+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.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= @@ -64,30 +142,79 @@ github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +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-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= +golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= +golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/text v0.3.0/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/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= +golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 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= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +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/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +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.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/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/funcs/generated/1.4.0.go b/internal/funcs/generated/1.4.0.go new file mode 100644 index 00000000..11b4d0a9 --- /dev/null +++ b/internal/funcs/generated/1.4.0.go @@ -0,0 +1,1330 @@ +// Code generated by "gen"; DO NOT EDIT. +package funcs + +import ( + "github.com/hashicorp/hcl-lang/schema" + "github.com/zclconf/go-cty/cty" + "github.com/zclconf/go-cty/cty/function" +) + +func v1_4_0_Functions() map[string]schema.FuncSignature { + return map[string]schema.FuncSignature{ + "abs": { + Params: []function.Parameter{ + { + Name: "num", + Type: cty.Number, + }, + }, + ReturnType: cty.Number, + Description: "`abs` returns the absolute value of the given number. In other words, if the number is zero or positive then it is returned as-is, but if it is negative then it is multiplied by -1 to make it positive before returning it.", + }, + "abspath": { + Params: []function.Parameter{ + { + Name: "path", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`abspath` takes a string containing a filesystem path and converts it to an absolute path. That is, if the path is not absolute, it will be joined with the current working directory.", + }, + "alltrue": { + Params: []function.Parameter{ + { + Name: "list", + Type: cty.List(cty.Bool), + }, + }, + ReturnType: cty.Bool, + Description: "`alltrue` returns `true` if all elements in a given collection are `true` or `"true"`. It also returns `true` if the collection is empty.", + }, + "anytrue": { + Params: []function.Parameter{ + { + Name: "list", + Type: cty.List(cty.Bool), + }, + }, + ReturnType: cty.Bool, + Description: "`anytrue` returns `true` if any element in a given collection is `true` or `"true"`. It also returns `false` if the collection is empty.", + }, + "base64decode": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`base64decode` takes a string containing a Base64 character sequence and returns the original string.", + }, + "base64encode": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`base64encode` applies Base64 encoding to a string.", + }, + "base64gzip": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`base64gzip` compresses a string with gzip and then encodes the result in Base64 encoding.", + }, + "base64sha256": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`base64sha256` computes the SHA256 hash of a given string and encodes it with Base64. This is not equivalent to `base64encode(sha256("test"))` since `sha256()` returns hexadecimal representation.", + }, + "base64sha512": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`base64sha512` computes the SHA512 hash of a given string and encodes it with Base64. This is not equivalent to `base64encode(sha512("test"))` since `sha512()` returns hexadecimal representation.", + }, + "basename": { + Params: []function.Parameter{ + { + Name: "path", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`basename` takes a string containing a filesystem path and removes all except the last portion from it.", + }, + "bcrypt": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + VarParam: &function.Parameter{ + Name: "cost", + Description: "The `cost` argument is optional and will default to 10 if unspecified.", + Type: cty.Number, + }, + ReturnType: cty.String, + Description: "`bcrypt` computes a hash of the given string using the Blowfish cipher, returning a string in [the _Modular Crypt Format_](https://passlib.readthedocs.io/en/stable/modular_crypt_format.html) usually expected in the shadow password file on many Unix systems.", + }, + "can": { + Params: []function.Parameter{ + { + Name: "expression", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.Bool, + Description: "`can` evaluates the given expression and returns a boolean value indicating whether the expression produced a result without any errors.", + }, + "ceil": { + Params: []function.Parameter{ + { + Name: "num", + Type: cty.Number, + }, + }, + ReturnType: cty.Number, + Description: "`ceil` returns the closest whole number that is greater than or equal to the given value, which may be a fraction.", + }, + "chomp": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`chomp` removes newline characters at the end of a string.", + }, + "chunklist": { + Params: []function.Parameter{ + { + Name: "list", + Type: cty.List(cty.DynamicPseudoType), + }, + { + Name: "size", + Description: "The maximum length of each chunk. All but the last element of the result is guaranteed to be of exactly this size.", + Type: cty.Number, + }, + }, + ReturnType: cty.List(cty.List(cty.DynamicPseudoType)), + Description: "`chunklist` splits a single list into fixed-size chunks, returning a list of lists.", + }, + "cidrhost": { + Params: []function.Parameter{ + { + Name: "prefix", + Description: "`prefix` must be given in CIDR notation, as defined in [RFC 4632 section 3.1](https://tools.ietf.org/html/rfc4632#section-3.1).", + Type: cty.String, + }, + { + Name: "hostnum", + Description: "`hostnum` is a whole number that can be represented as a binary integer with no more than the number of digits remaining in the address after the given prefix.", + Type: cty.Number, + }, + }, + ReturnType: cty.String, + Description: "`cidrhost` calculates a full host IP address for a given host number within a given IP network address prefix.", + }, + "cidrnetmask": { + Params: []function.Parameter{ + { + Name: "prefix", + Description: "`prefix` must be given in CIDR notation, as defined in [RFC 4632 section 3.1](https://tools.ietf.org/html/rfc4632#section-3.1).", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`cidrnetmask` converts an IPv4 address prefix given in CIDR notation into a subnet mask address.", + }, + "cidrsubnet": { + Params: []function.Parameter{ + { + Name: "prefix", + Description: "`prefix` must be given in CIDR notation, as defined in [RFC 4632 section 3.1](https://tools.ietf.org/html/rfc4632#section-3.1).", + Type: cty.String, + }, + { + Name: "newbits", + Description: "`newbits` is the number of additional bits with which to extend the prefix.", + Type: cty.Number, + }, + { + Name: "netnum", + Description: "`netnum` is a whole number that can be represented as a binary integer with no more than `newbits` binary digits, which will be used to populate the additional bits added to the prefix.", + Type: cty.Number, + }, + }, + ReturnType: cty.String, + Description: "`cidrsubnet` calculates a subnet address within given IP network address prefix.", + }, + "cidrsubnets": { + Params: []function.Parameter{ + { + Name: "prefix", + Description: "`prefix` must be given in CIDR notation, as defined in [RFC 4632 section 3.1](https://tools.ietf.org/html/rfc4632#section-3.1).", + Type: cty.String, + }, + }, + VarParam: &function.Parameter{ + Name: "newbits", + Description: "", + Type: cty.Number, + }, + ReturnType: cty.List(cty.String), + Description: "`cidrsubnets` calculates a sequence of consecutive IP address ranges within a particular CIDR prefix.", + }, + "coalesce": { + VarParam: &function.Parameter{ + Name: "vals", + Description: "", + Type: cty.DynamicPseudoType, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`coalesce` takes any number of arguments and returns the first one that isn't null or an empty string.", + }, + "coalescelist": { + VarParam: &function.Parameter{ + Name: "vals", + Description: "List or tuple values to test in the given order.", + Type: cty.DynamicPseudoType, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`coalescelist` takes any number of list arguments and returns the first one that isn't empty.", + }, + "compact": { + Params: []function.Parameter{ + { + Name: "list", + Type: cty.List(cty.String), + }, + }, + ReturnType: cty.List(cty.String), + Description: "`compact` takes a list of strings and returns a new list with any empty string elements removed.", + }, + "concat": { + VarParam: &function.Parameter{ + Name: "seqs", + Description: "", + Type: cty.DynamicPseudoType, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`concat` takes two or more lists and combines them into a single list.", + }, + "contains": { + Params: []function.Parameter{ + { + Name: "list", + Type: cty.DynamicPseudoType, + }, + { + Name: "value", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`contains` determines whether a given list or set contains a given single value as one of its elements.", + }, + "csvdecode": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`csvdecode` decodes a string containing CSV-formatted data and produces a list of maps representing that data.", + }, + "dirname": { + Params: []function.Parameter{ + { + Name: "path", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`dirname` takes a string containing a filesystem path and removes the last portion from it.", + }, + "distinct": { + Params: []function.Parameter{ + { + Name: "list", + Type: cty.List(cty.DynamicPseudoType), + }, + }, + ReturnType: cty.List(cty.DynamicPseudoType), + Description: "`distinct` takes a list and returns a new list with any duplicate elements removed.", + }, + "element": { + Params: []function.Parameter{ + { + Name: "list", + Type: cty.DynamicPseudoType, + }, + { + Name: "index", + Type: cty.Number, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`element` retrieves a single element from a list.", + }, + "endswith": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + { + Name: "suffix", + Type: cty.String, + }, + }, + ReturnType: cty.Bool, + Description: "`endswith` takes two values: a string to check and a suffix string. The function returns true if the first string ends with that exact suffix.", + }, + "file": { + Params: []function.Parameter{ + { + Name: "path", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`file` reads the contents of a file at the given path and returns them as a string.", + }, + "filebase64": { + Params: []function.Parameter{ + { + Name: "path", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`filebase64` reads the contents of a file at the given path and returns them as a base64-encoded string.", + }, + "filebase64sha256": { + Params: []function.Parameter{ + { + Name: "path", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`filebase64sha256` is a variant of `base64sha256` that hashes the contents of a given file rather than a literal string.", + }, + "filebase64sha512": { + Params: []function.Parameter{ + { + Name: "path", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`filebase64sha512` is a variant of `base64sha512` that hashes the contents of a given file rather than a literal string.", + }, + "fileexists": { + Params: []function.Parameter{ + { + Name: "path", + Type: cty.String, + }, + }, + ReturnType: cty.Bool, + Description: "`fileexists` determines whether a file exists at a given path.", + }, + "filemd5": { + Params: []function.Parameter{ + { + Name: "path", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`filemd5` is a variant of `md5` that hashes the contents of a given file rather than a literal string.", + }, + "fileset": { + Params: []function.Parameter{ + { + Name: "path", + Type: cty.String, + }, + { + Name: "pattern", + Type: cty.String, + }, + }, + ReturnType: cty.Set(cty.String), + Description: "`fileset` enumerates a set of regular file names given a path and pattern. The path is automatically removed from the resulting set of file names and any result still containing path separators always returns forward slash (`/`) as the path separator for cross-system compatibility.", + }, + "filesha1": { + Params: []function.Parameter{ + { + Name: "path", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`filesha1` is a variant of `sha1` that hashes the contents of a given file rather than a literal string.", + }, + "filesha256": { + Params: []function.Parameter{ + { + Name: "path", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`filesha256` is a variant of `sha256` that hashes the contents of a given file rather than a literal string.", + }, + "filesha512": { + Params: []function.Parameter{ + { + Name: "path", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`filesha512` is a variant of `sha512` that hashes the contents of a given file rather than a literal string.", + }, + "flatten": { + Params: []function.Parameter{ + { + Name: "list", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`flatten` takes a list and replaces any elements that are lists with a flattened sequence of the list contents.", + }, + "floor": { + Params: []function.Parameter{ + { + Name: "num", + Type: cty.Number, + }, + }, + ReturnType: cty.Number, + Description: "`floor` returns the closest whole number that is less than or equal to the given value, which may be a fraction.", + }, + "format": { + Params: []function.Parameter{ + { + Name: "format", + Type: cty.String, + }, + }, + VarParam: &function.Parameter{ + Name: "args", + Description: "", + Type: cty.DynamicPseudoType, + }, + ReturnType: cty.DynamicPseudoType, + Description: "The `format` function produces a string by formatting a number of other values according to a specification string. It is similar to the `printf` function in C, and other similar functions in other programming languages.", + }, + "formatdate": { + Params: []function.Parameter{ + { + Name: "format", + Type: cty.String, + }, + { + Name: "time", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`formatdate` converts a timestamp into a different time format.", + }, + "formatlist": { + Params: []function.Parameter{ + { + Name: "format", + Type: cty.String, + }, + }, + VarParam: &function.Parameter{ + Name: "args", + Description: "", + Type: cty.DynamicPseudoType, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`formatlist` produces a list of strings by formatting a number of other values according to a specification string.", + }, + "indent": { + Params: []function.Parameter{ + { + Name: "spaces", + Description: "Number of spaces to add after each newline character.", + Type: cty.Number, + }, + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`indent` adds a given number of spaces to the beginnings of all but the first line in a given multi-line string.", + }, + "index": { + Params: []function.Parameter{ + { + Name: "list", + Type: cty.DynamicPseudoType, + }, + { + Name: "value", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`index` finds the element index for a given value in a list.", + }, + "join": { + Params: []function.Parameter{ + { + Name: "separator", + Description: "Delimiter to insert between the given strings.", + Type: cty.String, + }, + }, + VarParam: &function.Parameter{ + Name: "lists", + Description: "One or more lists of strings to join.", + Type: cty.List(cty.String), + }, + ReturnType: cty.String, + Description: "`join` produces a string by concatenating together all elements of a given list of strings with the given delimiter.", + }, + "jsondecode": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`jsondecode` interprets a given string as JSON, returning a representation of the result of decoding that string.", + }, + "jsonencode": { + Params: []function.Parameter{ + { + Name: "val", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.String, + Description: "`jsonencode` encodes a given value to a string using JSON syntax.", + }, + "keys": { + Params: []function.Parameter{ + { + Name: "inputMap", + Description: "The map to extract keys from. May instead be an object-typed value, in which case the result is a tuple of the object attributes.", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`keys` takes a map and returns a list containing the keys from that map.", + }, + "length": { + Params: []function.Parameter{ + { + Name: "value", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.Number, + Description: "`length` determines the length of a given list, map, or string.", + }, + "log": { + Params: []function.Parameter{ + { + Name: "num", + Type: cty.Number, + }, + { + Name: "base", + Type: cty.Number, + }, + }, + ReturnType: cty.Number, + Description: "`log` returns the logarithm of a given number in a given base.", + }, + "lookup": { + Params: []function.Parameter{ + { + Name: "inputMap", + Type: cty.DynamicPseudoType, + }, + { + Name: "key", + Type: cty.String, + }, + }, + VarParam: &function.Parameter{ + Name: "default", + Description: "", + Type: cty.DynamicPseudoType, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`lookup` retrieves the value of a single element from a map, given its key. If the given key does not exist, the given default value is returned instead.", + }, + "lower": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`lower` converts all cased letters in the given string to lowercase.", + }, + "matchkeys": { + Params: []function.Parameter{ + { + Name: "values", + Type: cty.List(cty.DynamicPseudoType), + }, + { + Name: "keys", + Type: cty.List(cty.DynamicPseudoType), + }, + { + Name: "searchset", + Type: cty.List(cty.DynamicPseudoType), + }, + }, + ReturnType: cty.List(cty.DynamicPseudoType), + Description: "`matchkeys` constructs a new list by taking a subset of elements from one list whose indexes match the corresponding indexes of values in another list.", + }, + "max": { + VarParam: &function.Parameter{ + Name: "numbers", + Description: "", + Type: cty.Number, + }, + ReturnType: cty.Number, + Description: "`max` takes one or more numbers and returns the greatest number from the set.", + }, + "md5": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`md5` computes the MD5 hash of a given string and encodes it with hexadecimal digits.", + }, + "merge": { + VarParam: &function.Parameter{ + Name: "maps", + Description: "", + Type: cty.DynamicPseudoType, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`merge` takes an arbitrary number of maps or objects, and returns a single map or object that contains a merged set of elements from all arguments.", + }, + "min": { + VarParam: &function.Parameter{ + Name: "numbers", + Description: "", + Type: cty.Number, + }, + ReturnType: cty.Number, + Description: "`min` takes one or more numbers and returns the smallest number from the set.", + }, + "nonsensitive": { + Params: []function.Parameter{ + { + Name: "value", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`nonsensitive` takes a sensitive value and returns a copy of that value with the sensitive marking removed, thereby exposing the sensitive value.", + }, + "one": { + Params: []function.Parameter{ + { + Name: "list", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`one` takes a list, set, or tuple value with either zero or one elements. If the collection is empty, `one` returns `null`. Otherwise, `one` returns the first element. If there are two or more elements then `one` will return an error.", + }, + "parseint": { + Params: []function.Parameter{ + { + Name: "number", + Type: cty.DynamicPseudoType, + }, + { + Name: "base", + Type: cty.Number, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`parseint` parses the given string as a representation of an integer in the specified base and returns the resulting number. The base must be between 2 and 62 inclusive.", + }, + "pathexpand": { + Params: []function.Parameter{ + { + Name: "path", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`pathexpand` takes a filesystem path that might begin with a `~` segment, and if so it replaces that segment with the current user's home directory path.", + }, + "pow": { + Params: []function.Parameter{ + { + Name: "num", + Type: cty.Number, + }, + { + Name: "power", + Type: cty.Number, + }, + }, + ReturnType: cty.Number, + Description: "`pow` calculates an exponent, by raising its first argument to the power of the second argument.", + }, + "range": { + VarParam: &function.Parameter{ + Name: "params", + Description: "", + Type: cty.Number, + }, + ReturnType: cty.List(cty.Number), + Description: "`range` generates a list of numbers using a start value, a limit value, and a step value.", + }, + "regex": { + Params: []function.Parameter{ + { + Name: "pattern", + Type: cty.String, + }, + { + Name: "string", + Type: cty.String, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`regex` applies a [regular expression](https://en.wikipedia.org/wiki/Regular_expression) to a string and returns the matching substrings.", + }, + "regexall": { + Params: []function.Parameter{ + { + Name: "pattern", + Type: cty.String, + }, + { + Name: "string", + Type: cty.String, + }, + }, + ReturnType: cty.List(cty.DynamicPseudoType), + Description: "`regexall` applies a [regular expression](https://en.wikipedia.org/wiki/Regular_expression) to a string and returns a list of all matches.", + }, + "replace": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + { + Name: "substr", + Type: cty.String, + }, + { + Name: "replace", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`replace` searches a given string for another given substring, and replaces each occurrence with a given replacement string.", + }, + "reverse": { + Params: []function.Parameter{ + { + Name: "list", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`reverse` takes a sequence and produces a new sequence of the same length with all of the same elements as the given sequence but in reverse order.", + }, + "rsadecrypt": { + Params: []function.Parameter{ + { + Name: "ciphertext", + Type: cty.String, + }, + { + Name: "privatekey", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`rsadecrypt` decrypts an RSA-encrypted ciphertext, returning the corresponding cleartext.", + }, + "sensitive": { + Params: []function.Parameter{ + { + Name: "value", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`sensitive` takes any value and returns a copy of it marked so that Terraform will treat it as sensitive, with the same meaning and behavior as for [sensitive input variables](/language/values/variables#suppressing-values-in-cli-output).", + }, + "setintersection": { + Params: []function.Parameter{ + { + Name: "first_set", + Type: cty.Set(cty.DynamicPseudoType), + }, + }, + VarParam: &function.Parameter{ + Name: "other_sets", + Description: "", + Type: cty.Set(cty.DynamicPseudoType), + }, + ReturnType: cty.Set(cty.DynamicPseudoType), + Description: "The `setintersection` function takes multiple sets and produces a single set containing only the elements that all of the given sets have in common. In other words, it computes the [intersection](https://en.wikipedia.org/wiki/Intersection_\\(set_theory\\)) of the sets.", + }, + "setproduct": { + VarParam: &function.Parameter{ + Name: "sets", + Description: "The sets to consider. Also accepts lists and tuples, and if all arguments are of list or tuple type then the result will preserve the input ordering", + Type: cty.DynamicPseudoType, + }, + ReturnType: cty.DynamicPseudoType, + Description: "The `setproduct` function finds all of the possible combinations of elements from all of the given sets by computing the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product).", + }, + "setsubtract": { + Params: []function.Parameter{ + { + Name: "a", + Type: cty.Set(cty.DynamicPseudoType), + }, + { + Name: "b", + Type: cty.Set(cty.DynamicPseudoType), + }, + }, + ReturnType: cty.Set(cty.DynamicPseudoType), + Description: "The `setsubtract` function returns a new set containing the elements from the first set that are not present in the second set. In other words, it computes the [relative complement](https://en.wikipedia.org/wiki/Complement_\\(set_theory\\)#Relative_complement) of the second set.", + }, + "setunion": { + Params: []function.Parameter{ + { + Name: "first_set", + Type: cty.Set(cty.DynamicPseudoType), + }, + }, + VarParam: &function.Parameter{ + Name: "other_sets", + Description: "", + Type: cty.Set(cty.DynamicPseudoType), + }, + ReturnType: cty.Set(cty.DynamicPseudoType), + Description: "The `setunion` function takes multiple sets and produces a single set containing the elements from all of the given sets. In other words, it computes the [union](https://en.wikipedia.org/wiki/Union_\\(set_theory\\)) of the sets.", + }, + "sha1": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`sha1` computes the SHA1 hash of a given string and encodes it with hexadecimal digits.", + }, + "sha256": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`sha256` computes the SHA256 hash of a given string and encodes it with hexadecimal digits.", + }, + "sha512": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`sha512` computes the SHA512 hash of a given string and encodes it with hexadecimal digits.", + }, + "signum": { + Params: []function.Parameter{ + { + Name: "num", + Type: cty.Number, + }, + }, + ReturnType: cty.Number, + Description: "`signum` determines the sign of a number, returning a number between -1 and 1 to represent the sign.", + }, + "slice": { + Params: []function.Parameter{ + { + Name: "list", + Type: cty.DynamicPseudoType, + }, + { + Name: "start_index", + Type: cty.Number, + }, + { + Name: "end_index", + Type: cty.Number, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`slice` extracts some consecutive elements from within a list.", + }, + "sort": { + Params: []function.Parameter{ + { + Name: "list", + Type: cty.List(cty.String), + }, + }, + ReturnType: cty.List(cty.String), + Description: "`sort` takes a list of strings and returns a new list with those strings sorted lexicographically.", + }, + "split": { + Params: []function.Parameter{ + { + Name: "separator", + Type: cty.String, + }, + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.List(cty.String), + Description: "`split` produces a list by dividing a given string at all occurrences of a given separator.", + }, + "startswith": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + { + Name: "prefix", + Type: cty.String, + }, + }, + ReturnType: cty.Bool, + Description: "`startswith` takes two values: a string to check and a prefix string. The function returns true if the string begins with that exact prefix.", + }, + "strrev": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`strrev` reverses the characters in a string. Note that the characters are treated as _Unicode characters_ (in technical terms, Unicode [grapheme cluster boundaries](https://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries) are respected).", + }, + "substr": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + { + Name: "offset", + Type: cty.Number, + }, + { + Name: "length", + Type: cty.Number, + }, + }, + ReturnType: cty.String, + Description: "`substr` extracts a substring from a given string by offset and (maximum) length.", + }, + "sum": { + Params: []function.Parameter{ + { + Name: "list", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`sum` takes a list or set of numbers and returns the sum of those numbers.", + }, + "templatefile": { + Params: []function.Parameter{ + { + Name: "path", + Type: cty.String, + }, + { + Name: "vars", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`templatefile` reads the file at the given path and renders its content as a template using a supplied set of template variables.", + }, + "textdecodebase64": { + Params: []function.Parameter{ + { + Name: "source", + Type: cty.String, + }, + { + Name: "encoding", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`textdecodebase64` function decodes a string that was previously Base64-encoded, and then interprets the result as characters in a specified character encoding.", + }, + "textencodebase64": { + Params: []function.Parameter{ + { + Name: "string", + Type: cty.String, + }, + { + Name: "encoding", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`textencodebase64` encodes the unicode characters in a given string using a specified character encoding, returning the result base64 encoded because Terraform language strings are always sequences of unicode characters.", + }, + "timeadd": { + Params: []function.Parameter{ + { + Name: "timestamp", + Type: cty.String, + }, + { + Name: "duration", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`timeadd` adds a duration to a timestamp, returning a new timestamp.", + }, + "timecmp": { + Params: []function.Parameter{ + { + Name: "timestamp_a", + Type: cty.String, + }, + { + Name: "timestamp_b", + Type: cty.String, + }, + }, + ReturnType: cty.Number, + Description: "`timecmp` compares two timestamps and returns a number that represents the ordering of the instants those timestamps represent.", + }, + "timestamp": { + ReturnType: cty.String, + Description: "`timestamp` returns a UTC timestamp string in [RFC 3339](https://tools.ietf.org/html/rfc3339) format.", + }, + "title": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`title` converts the first letter of each word in the given string to uppercase.", + }, + "tobool": { + Params: []function.Parameter{ + { + Name: "v", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.Bool, + Description: "`tobool` converts its argument to a boolean value.", + }, + "tolist": { + Params: []function.Parameter{ + { + Name: "v", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.List(cty.DynamicPseudoType), + Description: "`tolist` converts its argument to a list value.", + }, + "tomap": { + Params: []function.Parameter{ + { + Name: "v", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.Map(cty.DynamicPseudoType), + Description: "`tomap` converts its argument to a map value.", + }, + "tonumber": { + Params: []function.Parameter{ + { + Name: "v", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.Number, + Description: "`tonumber` converts its argument to a number value.", + }, + "toset": { + Params: []function.Parameter{ + { + Name: "v", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.Set(cty.DynamicPseudoType), + Description: "`toset` converts its argument to a set value.", + }, + "tostring": { + Params: []function.Parameter{ + { + Name: "v", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.String, + Description: "`tostring` converts its argument to a string value.", + }, + "transpose": { + Params: []function.Parameter{ + { + Name: "values", + Type: cty.Map(cty.List(cty.String)), + }, + }, + ReturnType: cty.Map(cty.List(cty.String)), + Description: "`transpose` takes a map of lists of strings and swaps the keys and values to produce a new map of lists of strings.", + }, + "trim": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + { + Name: "cutset", + Description: "A string containing all of the characters to trim. Each character is taken separately, so the order of characters is insignificant.", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`trim` removes the specified set of characters from the start and end of the given string.", + }, + "trimprefix": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + { + Name: "prefix", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`trimprefix` removes the specified prefix from the start of the given string. If the string does not start with the prefix, the string is returned unchanged.", + }, + "trimspace": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`trimspace` removes any space characters from the start and end of the given string.", + }, + "trimsuffix": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + { + Name: "suffix", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`trimsuffix` removes the specified suffix from the end of the given string.", + }, + "try": { + VarParam: &function.Parameter{ + Name: "expressions", + Description: "", + Type: cty.DynamicPseudoType, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`try` evaluates all of its argument expressions in turn and returns the result of the first one that does not produce any errors.", + }, + "upper": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`upper` converts all cased letters in the given string to uppercase.", + }, + "urlencode": { + Params: []function.Parameter{ + { + Name: "str", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`urlencode` applies URL encoding to a given string.", + }, + "uuid": { + ReturnType: cty.String, + Description: "`uuid` generates a unique identifier string.", + }, + "uuidv5": { + Params: []function.Parameter{ + { + Name: "namespace", + Type: cty.String, + }, + { + Name: "name", + Type: cty.String, + }, + }, + ReturnType: cty.String, + Description: "`uuidv5` generates a _name-based_ UUID, as described in [RFC 4122 section 4.3](https://tools.ietf.org/html/rfc4122#section-4.3), also known as a "version 5" UUID.", + }, + "values": { + Params: []function.Parameter{ + { + Name: "mapping", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`values` takes a map and returns a list containing the values of the elements in that map.", + }, + "yamldecode": { + Params: []function.Parameter{ + { + Name: "src", + Type: cty.String, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`yamldecode` parses a string as a subset of YAML, and produces a representation of its value.", + }, + "yamlencode": { + Params: []function.Parameter{ + { + Name: "value", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.String, + Description: "`yamlencode` encodes a given value to a string using [YAML 1.2](https://yaml.org/spec/1.2/spec.html) block syntax.", + }, + "zipmap": { + Params: []function.Parameter{ + { + Name: "keys", + Type: cty.List(cty.String), + }, + { + Name: "values", + Type: cty.DynamicPseudoType, + }, + }, + ReturnType: cty.DynamicPseudoType, + Description: "`zipmap` constructs a map from a list of keys and a corresponding list of values.", + }, + } +} diff --git a/internal/funcs/generated/README.md b/internal/funcs/generated/README.md new file mode 100644 index 00000000..aa6c5d43 --- /dev/null +++ b/internal/funcs/generated/README.md @@ -0,0 +1,22 @@ +# Generated Terraform function signatures + +This package can generate function signature files for Terraform >= 1.4 automatically. + +It is intended to run whenever HashiCorp releases a new Terraform. If the Terraform version contains updated function signatures, it generates a new file for that version. When no changes are detected, one should commit the version bump in `gen/gen.go`. + +It may only work with full releases and will likely fail for pre-releases or versions containing metadata. + +## Running + +Update the `terraformVersion` in `gen/gen.go` with the version of the new Terraform release. + +Run `go generate ./internal/funcs/generated`. This command will: + +1. Install the specified Terraform version. +1. Run `terraform metadata functions -json` to obtain the function signatures. +1. Compare a hash of the JSON string to `functionSignatureHash` in `gen/gen.go`. + 1. If there are no changes, we will stop here. +1. Create a new Go file with the function signatures of that Terraform version. +1. Regenerate the function signature selection in `functions.go`. + +If everything looks solid, update the `functionSignatureHash` with the one from the output, and commit all changes. \ No newline at end of file diff --git a/internal/funcs/generated/doc.go b/internal/funcs/generated/doc.go new file mode 100644 index 00000000..1f88df05 --- /dev/null +++ b/internal/funcs/generated/doc.go @@ -0,0 +1,4 @@ +// Package generates function signature files for Terraform >= 1.4 +package funcs + +//go:generate go run gen/gen.go diff --git a/internal/funcs/generated/functions.go b/internal/funcs/generated/functions.go new file mode 100644 index 00000000..529fde7e --- /dev/null +++ b/internal/funcs/generated/functions.go @@ -0,0 +1,19 @@ +// Code generated by "gen"; DO NOT EDIT. +package funcs + +import ( + "github.com/hashicorp/go-version" + "github.com/hashicorp/hcl-lang/schema" +) + +var ( + v1_4_0 = version.Must(version.NewVersion("1.4.0")) +) + +func Functions(v *version.Version) map[string]schema.FuncSignature { + if v.GreaterThanOrEqual(v1_4_0) { + return v1_4_0_Functions() + } + + return v1_4_0_Functions() +} diff --git a/internal/funcs/generated/gen/gen.go b/internal/funcs/generated/gen/gen.go new file mode 100644 index 00000000..85e3ef4e --- /dev/null +++ b/internal/funcs/generated/gen/gen.go @@ -0,0 +1,286 @@ +package main + +import ( + "bytes" + "context" + "crypto/sha256" + "encoding/json" + "fmt" + "go/format" + "io/ioutil" + "log" + "os" + "path/filepath" + "sort" + "strings" + "text/template" + + "github.com/hashicorp/go-version" + hcinstall "github.com/hashicorp/hc-install" + "github.com/hashicorp/hc-install/product" + "github.com/hashicorp/hc-install/releases" + "github.com/hashicorp/hc-install/src" + "github.com/hashicorp/terraform-exec/tfexec" + tfjson "github.com/hashicorp/terraform-json" +) + +const ( + terraformVersion = "1.4.0" + functionSignatureHash = "94f55d9c950d686244657db39894b15ce2548095c9b68fe497d763448bb5e25d" +) + +func main() { + ctx := context.Background() + + functions, err := signaturesFromTerraform(ctx) + if err != nil { + log.Fatal(err) + } + newSignatureHash, err := signatureHash(functions) + if err != nil { + log.Fatal(err) + } + if newSignatureHash == functionSignatureHash { + log.Println("function signatures haven't changed, nothing to do here") + return + } + log.Printf("generating new signatures for %q\n", newSignatureHash) + functionsFile := fmt.Sprintf("%s.go", terraformVersion) + writeFunctions(functionsFile, functions) + + versions, err := generatedVersions(".") + if err != nil { + log.Fatal(err) + } + log.Printf("found versions %s, regenerating includes", versions) + writeFunctionVersions("functions.go", versions) +} + +// signaturesFromTerraform gets the function signatures for the specified +// Terraform version. +func signaturesFromTerraform(ctx context.Context) (*tfjson.MetadataFunctions, error) { + // find or install Terraform + log.Println("ensuring terraform is installed") + installDir, err := ioutil.TempDir("", "hcinstall") + if err != nil { + return nil, err + } + defer os.RemoveAll(installDir) + i := hcinstall.NewInstaller() + execPath, err := i.Ensure(ctx, []src.Source{ + &releases.ExactVersion{ + Product: product.Terraform, + InstallDir: installDir, + Version: version.Must(version.NewVersion(terraformVersion)), + }, + }) + if err != nil { + return nil, err + } + defer i.Remove(ctx) + + // log version + tf, err := tfexec.NewTerraform(installDir, execPath) + if err != nil { + return nil, err + } + coreVersion, _, err := tf.Version(ctx, true) + if err != nil { + return nil, err + } + log.Printf("using Terraform %s (%s)", coreVersion, execPath) + + return tf.MetadataFunctions(ctx) +} + +// signatureHash calculates the SHA256 checksum for the given function +// signatures. +func signatureHash(functions *tfjson.MetadataFunctions) (string, error) { + var rawJson bytes.Buffer + err := json.NewEncoder(&rawJson).Encode(functions) + if err != nil { + return "", fmt.Errorf("failed to encode functions: %w", err) + } + + hash := sha256.Sum256(rawJson.Bytes()) + return fmt.Sprintf("%x", hash), nil +} + +// writeFunctions generates the Go code for the function signatures, +// formats it and writes it to a new file. +func writeFunctions(filename string, functions *tfjson.MetadataFunctions) { + outputTpl := `// Code generated by "gen"; DO NOT EDIT. +package funcs + +import ( + "github.com/hashicorp/hcl-lang/schema" + "github.com/zclconf/go-cty/cty" + "github.com/zclconf/go-cty/cty/function" +) +func {{ .FunctionName }}() map[string]schema.FuncSignature { + return map[string]schema.FuncSignature{ +{{- range $funcName, $func := .Signatures }} + {{- $varpar := $func.VariadicParameter }} + {{- $params := $func.Parameters }} + "{{ $funcName }}": { + {{- with $params }} + Params: []function.Parameter{ + {{- range $key, $value := $params }} + {{- $desc := $value.Description }} + { + Name: "{{ $value.Name }}", + {{- with $desc }} + Description: "{{ escapeDescription . }}",{{- end }} + Type: {{ $value.Type.GoString }}, + }, + {{- end }} + },{{- end }} + {{- with $varpar }} + VarParam: &function.Parameter{ + Name: "{{ .Name }}", + Description: "{{ .Description }}", + Type: {{ .Type.GoString }}, + },{{- end }} + ReturnType: {{ $func.ReturnType.GoString }}, + Description: "{{ escapeDescription $func.Description }}", + }, +{{- end }} + } +} +` + + tpl, err := template.New("output").Funcs(template.FuncMap{ + "escapeDescription": escapeDescription, + }).Parse(outputTpl) + if err != nil { + log.Fatal(err) + } + + type data struct { + FunctionName string + Signatures map[string]*tfjson.FunctionSignature + } + + var buf bytes.Buffer + err = tpl.Execute(&buf, data{ + FunctionName: fmt.Sprintf("v%s_Functions", escapeVersion(terraformVersion)), + Signatures: functions.Signatures, + }) + if err != nil { + log.Fatal(err) + } + + p, err := format.Source(buf.Bytes()) + if err != nil { + log.Fatal(err) + } + + f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE, 0o644) + if err != nil { + log.Fatal(err) + } + _, err = f.Write(p) + if err != nil { + log.Fatal(err) + } +} + +func escapeDescription(description string) string { + return strings.ReplaceAll(description, `\`, `\\`) +} + +func escapeVersion(version string) string { + return strings.ReplaceAll(version, ".", "_") +} + +// generatedVersions returns a sorted slice of all available function +// signature files within a path. It will skip all directories and +// filenames that don't parse as a version string. +func generatedVersions(path string) ([]*version.Version, error) { + files, err := ioutil.ReadDir(path) + if err != nil { + return nil, err + } + + versions := []*version.Version{} + for _, file := range files { + if file.IsDir() { + continue + } + filename := strings.TrimSuffix(file.Name(), filepath.Ext(file.Name())) + + v, err := version.NewVersion(filename) + if err != nil { + // Skip any filenames that don't parse as version string + continue + } + versions = append(versions, v) + } + + sort.Sort(sort.Reverse(version.Collection(versions))) + + return versions, nil +} + +// writeFunctionVersions generates Go code for selecting the correct generated +// function signature for a specific version. +func writeFunctionVersions(filename string, versions []*version.Version) { + outputTpl := `// Code generated by "gen"; DO NOT EDIT. +package funcs + +import ( + "github.com/hashicorp/go-version" + "github.com/hashicorp/hcl-lang/schema" +) + +var ( +{{- range $version := .Versions }} + v{{ escapeVersion $version.String }} = version.Must(version.NewVersion("{{ $version.String }}")) +{{- end }} +) + +func Functions(v *version.Version) map[string]schema.FuncSignature { +{{- range $version := .Versions }} + if v.GreaterThanOrEqual(v{{ escapeVersion $version.String }}) { + return v{{ escapeVersion $version.String }}_Functions() + } +{{- end }} + + return v1_4_0_Functions() +} +` + + tpl, err := template.New("output").Funcs(template.FuncMap{ + "escapeDescription": escapeDescription, + "escapeVersion": escapeVersion, + }).Parse(outputTpl) + if err != nil { + log.Fatal(err) + } + + type data struct { + Versions []*version.Version + } + + var buf bytes.Buffer + err = tpl.Execute(&buf, data{ + Versions: versions, + }) + if err != nil { + log.Fatal(err) + } + + p, err := format.Source(buf.Bytes()) + if err != nil { + log.Fatal(err) + } + + f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE, 0o644) + if err != nil { + log.Fatal(err) + } + _, err = f.Write(p) + if err != nil { + log.Fatal(err) + } +} diff --git a/schema/core_schema.go b/schema/core_schema.go index bf111463..64b23f0e 100644 --- a/schema/core_schema.go +++ b/schema/core_schema.go @@ -21,6 +21,7 @@ var ( v1_1 = version.Must(version.NewVersion("1.1")) v1_2 = version.Must(version.NewVersion("1.2")) v1_3 = version.Must(version.NewVersion("1.3")) + v1_4 = version.Must(version.NewVersion("1.4")) ) // CoreModuleSchemaForVersion finds a module schema which is relevant diff --git a/schema/functions.go b/schema/functions.go index 6f74b9dd..0e31697c 100644 --- a/schema/functions.go +++ b/schema/functions.go @@ -11,6 +11,7 @@ import ( funcs_v0_14 "github.com/hashicorp/terraform-schema/internal/funcs/0.14" funcs_v0_15 "github.com/hashicorp/terraform-schema/internal/funcs/0.15" funcs_v1_3 "github.com/hashicorp/terraform-schema/internal/funcs/1.3" + funcs_generated "github.com/hashicorp/terraform-schema/internal/funcs/generated" ) func FunctionsForVersion(v *version.Version) (map[string]schema.FuncSignature, error) { @@ -19,6 +20,9 @@ func FunctionsForVersion(v *version.Version) (map[string]schema.FuncSignature, e return nil, fmt.Errorf("invalid version: %w", err) } + if ver.GreaterThanOrEqual(v1_4) { + return funcs_generated.Functions(ver), nil + } if ver.GreaterThanOrEqual(v1_3) { return funcs_v1_3.Functions(ver), nil }