diff --git a/CHANGELOG.md b/CHANGELOG.md
index fc457ae5ce..f8218e1919 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,7 +13,7 @@ ENHANCEMENTS:
- This change fixes the local state filesystem interface to function as the statemgr API describes.
- A possible side effect is that a hard crash mid-apply will no longer have a in-progress state file to reference. This matches the other state managers.
* `tofu console` should work in Solaris and AIX as readline has been updated. ([#632](https://github.com/opentofu/opentofu/pull/632))
-
+* Added "base64gunzip" function. ([$800](https://github.com/opentofu/opentofu/issues/800))
BUG FIXES:
* `tofu test` resources cleanup at the end of tests changed to use simple reverse run block order. ([#1043](https://github.com/opentofu/opentofu/pull/1043))
diff --git a/internal/lang/funcs/descriptions.go b/internal/lang/funcs/descriptions.go
index 1c70f1efd9..b8aff58990 100644
--- a/internal/lang/funcs/descriptions.go
+++ b/internal/lang/funcs/descriptions.go
@@ -53,8 +53,8 @@ var DescriptionList = map[string]descriptionEntry{
Description: "`base64gzip` compresses a string with gzip and then encodes the result in Base64 encoding.",
ParamDescription: []string{""},
},
- "gunzipbase64": {
- Description: "`gunzipbase64` decodes a Base64-encoded string and uncompresses the result with gzip.",
+ "base64gunzip": {
+ Description: "`base64gunzip` decodes a Base64-encoded string and uncompresses the result with gzip.",
ParamDescription: []string{""},
},
"base64sha256": {
diff --git a/internal/lang/funcs/encoding.go b/internal/lang/funcs/encoding.go
index e8064841ac..63139fe566 100644
--- a/internal/lang/funcs/encoding.go
+++ b/internal/lang/funcs/encoding.go
@@ -179,8 +179,8 @@ var Base64GzipFunc = function.New(&function.Spec{
},
})
-// GunzipBase64Func constructs a function that Bae64 decodes a string and decompresses the result with gunzip.
-var GunzipBase64Func = function.New(&function.Spec{
+// Base64GunzipFunc constructs a function that Bae64 decodes a string and decompresses the result with gunzip.
+var Base64GunzipFunc = function.New(&function.Spec{
Params: []function.Parameter{
{
Name: "str",
@@ -260,11 +260,11 @@ func Base64Gzip(str cty.Value) (cty.Value, error) {
return Base64GzipFunc.Call([]cty.Value{str})
}
-// GunzipBase64 decodes a Base64-encoded string and uncompresses the result with gzip.
+// Base64Gunzip decodes a Base64-encoded string and uncompresses the result with gzip.
//
// Opentofu uses the "standard" Base64 alphabet as defined in RFC 4648 section 4.
-func GunzipBase64(str cty.Value) (cty.Value, error) {
- return GunzipBase64Func.Call([]cty.Value{str})
+func Base64Gunzip(str cty.Value) (cty.Value, error) {
+ return Base64GunzipFunc.Call([]cty.Value{str})
}
// URLEncode applies URL encoding to a given string.
diff --git a/internal/lang/funcs/encoding_test.go b/internal/lang/funcs/encoding_test.go
index 0f8304cb59..af05c4ee5c 100644
--- a/internal/lang/funcs/encoding_test.go
+++ b/internal/lang/funcs/encoding_test.go
@@ -7,8 +7,9 @@ import (
"fmt"
"testing"
- "github.com/opentofu/opentofu/internal/lang/marks"
"github.com/zclconf/go-cty/cty"
+
+ "github.com/opentofu/opentofu/internal/lang/marks"
)
func TestBase64Decode(t *testing.T) {
@@ -159,7 +160,7 @@ func TestBase64Gzip(t *testing.T) {
}
}
-func TestGunzipBase64(t *testing.T) {
+func TestBase64Gunzip(t *testing.T) {
tests := []struct {
String cty.Value
Want cty.Value
@@ -173,8 +174,8 @@ func TestGunzipBase64(t *testing.T) {
}
for _, test := range tests {
- t.Run(fmt.Sprintf("gunzipbase64(%#v)", test.String), func(t *testing.T) {
- got, err := GunzipBase64(test.String)
+ t.Run(fmt.Sprintf("base64gunzip(%#v)", test.String), func(t *testing.T) {
+ got, err := Base64Gunzip(test.String)
if test.Err {
if err == nil {
diff --git a/internal/lang/functions.go b/internal/lang/functions.go
index 96521bddfd..6f0c33fddf 100644
--- a/internal/lang/functions.go
+++ b/internal/lang/functions.go
@@ -43,7 +43,7 @@ func (s *Scope) Functions() map[string]function.Function {
"base64decode": funcs.Base64DecodeFunc,
"base64encode": funcs.Base64EncodeFunc,
"base64gzip": funcs.Base64GzipFunc,
- "gunzipbase64": funcs.GunzipBase64Func,
+ "base64gunzip": funcs.Base64GunzipFunc,
"base64sha256": funcs.Base64Sha256Func,
"base64sha512": funcs.Base64Sha512Func,
"bcrypt": funcs.BcryptFunc,
diff --git a/internal/lang/functions_test.go b/internal/lang/functions_test.go
index a84ab423a3..52006efb20 100644
--- a/internal/lang/functions_test.go
+++ b/internal/lang/functions_test.go
@@ -13,9 +13,10 @@ import (
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hclsyntax"
homedir "github.com/mitchellh/go-homedir"
+ "github.com/zclconf/go-cty/cty"
+
"github.com/opentofu/opentofu/internal/experiments"
"github.com/opentofu/opentofu/internal/lang/marks"
- "github.com/zclconf/go-cty/cty"
)
// TestFunctions tests that functions are callable through the functionality
@@ -108,9 +109,9 @@ func TestFunctions(t *testing.T) {
},
},
- "gunzipbase64": {
+ "base64gunzip": {
{
- `gunzipbase64("H4sIAAAAAAAA/ypJLS4BAAAA//8BAAD//wx+f9gEAAAA")`,
+ `base64gunzip("H4sIAAAAAAAA/ypJLS4BAAAA//8BAAD//wx+f9gEAAAA")`,
cty.StringVal("test"),
},
},
diff --git a/website/data/language-nav-data.json b/website/data/language-nav-data.json
index 857ea1ac9a..d32e609ca2 100644
--- a/website/data/language-nav-data.json
+++ b/website/data/language-nav-data.json
@@ -518,8 +518,8 @@
"path": "language/functions/csvdecode"
},
{
- "title": "gunzipbase64",
- "path": "language/functions/gunzipbase64"
+ "title": "base64gunzip",
+ "path": "language/functions/base64gunzip"
},
{
"title": "jsondecode",
@@ -932,8 +932,8 @@
"hidden": true
},
{
- "title": "gunzipbase64",
- "path": "language/functions/gunzipbase64",
+ "title": "base64gunzip",
+ "path": "language/functions/base64gunzip",
"hidden": true
},
{
diff --git a/website/docs/language/functions/gunzipbase64.mdx b/website/docs/language/functions/base64gunzip.mdx
similarity index 62%
rename from website/docs/language/functions/gunzipbase64.mdx
rename to website/docs/language/functions/base64gunzip.mdx
index 623aad82e8..0e447e52eb 100644
--- a/website/docs/language/functions/gunzipbase64.mdx
+++ b/website/docs/language/functions/base64gunzip.mdx
@@ -1,12 +1,12 @@
---
-page_title: gunzipbase64 - Functions - Configuration Language
+page_title: base64gunzip - Functions - Configuration Language
description: |-
- The gunzipbase64 funtion decodes a Base64-encoded string and uncompresses the result with gzip.
+ The base64gunzip funtion decodes a Base64-encoded string and uncompresses the result with gzip.
---
-# `gunzipbase64` Function
+# `base64gunzip` Function
-`gunzipbase64` decodes a Base64-encoded string and uncompresses the result with gzip.
+`base64gunzip` decodes a Base64-encoded string and uncompresses the result with gzip.
Opentofu uses the "standard" Base64 alphabet as defined in
[RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).