Documentation
¶
Overview ¶
Package transforms provides utility functions for data transformation operations like JSON normalization, base64 encoding/decoding, and gzip compression/decompression.
Index ¶
- Variables
- func Base64Decode(content string) (string, error)
- func Base64Encode[T string | []byte](content T) (string, error)
- func Base64GzipDecode(content string) (string, error)
- func Base64GzipEncode(content string) (string, error)
- func IsJSON(content string) bool
- func JSONBase64GzipDecode(content string) (any, error)
- func JSONBase64GzipEncode(content string) (string, error)
- func JSONNormalize(content string) (string, error)
- func JSONNormalizePretty(content string) (string, error)
- func PayloadToGzip(content string) (string, diag.Diagnostics)
- func SourceFileToPayload(srcPath string, tokens map[string]string) (string, string, diag.Diagnostics)
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyContent = errors.New("empty content") ErrEmptyJSON = errors.New("empty JSON content") )
Functions ¶
func Base64Decode ¶
Base64Decode decodes a base64 encoded string.
func Base64Encode ¶
Base64Encode encodes a string or byte slice to base64.
func Base64GzipDecode ¶
Base64GzipDecode decodes and decompresses base64 gzipped content.
func Base64GzipEncode ¶
Base64GzipEncode compresses and base64 encodes content.
func JSONBase64GzipDecode ¶
JSONBase64GzipDecode decodes, decompresses and unmarshals base64 gzipped JSON content.
func JSONBase64GzipEncode ¶
JSONBase64GzipEncode normalizes, compresses, and base64 encodes JSON content.
func JSONNormalize ¶
JSONNormalize normalizes JSON content to a compact format.
func JSONNormalizePretty ¶
JSONNormalizePretty normalizes JSON content to a human-readable format with indentation.
func PayloadToGzip ¶
func PayloadToGzip(content string) (string, diag.Diagnostics)
PayloadToGzip transforms a base64 encoded content string to a gzip compressed base64 string. If the content is valid JSON, it uses JSON-specific encoding.
func SourceFileToPayload ¶
func SourceFileToPayload(srcPath string, tokens map[string]string) (string, string, diag.Diagnostics)
SourceFileToPayload transforms a source file into a base64 encoded payload and calculates its SHA256 hash. It optionally processes the file as a template with the provided tokens.
Types ¶
This section is empty.