utils

package
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

utilities.go For utility/helper functions to support the jamf pro tf provider

utilities.go For utility/helper functions to support the jamf pro tf provider

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64EncodeIfNot added in v0.0.11

func Base64EncodeIfNot(value string) string

Base64EncodeIfNot encodes a string value if it isn't already encoded using base64.StdEncoding.EncodeToString. If the input is already base64 encoded, return the original input unchanged.

func DecodePlistToCustomType added in v0.0.11

func DecodePlistToCustomType(data []byte, customType *plistCustomType) (int, error)

DecodePlistToCustomType decodes plist data from a byte slice into a provided plistCustomType pointer. Updates the value pointed by `customType` with the decoded data. Returns the format of the plist and an error if decoding fails.

func DecodePlistToMap added in v0.0.11

func DecodePlistToMap(data []byte) (map[string]interface{}, int, error)

DecodePlistToMap decodes plist data from a byte slice into a map[string]interface{}. Returns the decoded map, the format of the plist, and an error if decoding fails.

func DecodeXmlString added in v0.0.11

func DecodeXmlString(s string) string

DecodeXmlString unescapes HTML entities in a string back to their original XML special characters.

func EncodeCustomTypeToPlist added in v0.0.11

func EncodeCustomTypeToPlist(customType plistCustomType, format int) error

EncodeCustomTypeToPlist encodes an instance of plistCustomType to a plist format and writes it to standard output. The `format` parameter determines the plist format (e.g., XML, Binary). Returns an error if encoding fails.

func EncodeMapToPlist added in v0.0.11

func EncodeMapToPlist(data map[string]interface{}, format int) error

EncodeMapToPlist encodes a map[string]interface{} to a plist format and writes it to standard output. The `format` parameter determines the plist format (e.g., XML, Binary). Returns an error if encoding fails.

func EncodeXmlString added in v0.0.11

func EncodeXmlString(s string) string

EncodeXmlString escapes special XML characters in a string and replaces them with their corresponding HTML entities.

func NormalizeXml added in v0.0.11

func NormalizeXml(xmlString interface{}) string

NormalizeXml takes an XML content represented by the `xmlString` parameter of type `interface{}` and returns a normalized, consistently formatted XML string. The function performs the following steps: 1. Checks if the input `xmlString` is nil or an empty string, returning an empty string if true. 2. Attempts to unmarshal the input string (asserted to `string` from `interface{}`) into a generic interface{} type to parse the XML structure. 3. If unmarshaling fails (indicating invalid XML content), returns an error message string. 4. If unmarshaling succeeds, marshals the object back into XML using `xml.MarshalIndent` to ensure consistent formatting and indentation. 5. Returns the resulting normalized XML string. Note: The function assumes `xmlString` can be type asserted to `string` and may panic otherwise. It is intended for use with valid XML content that needs normalization for consistency or readability.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL