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 ¶
- func Base64EncodeIfNot(value string) string
- func DecodePlistToCustomType(data []byte, customType *plistCustomType) (int, error)
- func DecodePlistToMap(data []byte) (map[string]interface{}, int, error)
- func DecodeXmlString(s string) string
- func EncodeCustomTypeToPlist(customType plistCustomType, format int) error
- func EncodeMapToPlist(data map[string]interface{}, format int) error
- func EncodeXmlString(s string) string
- func NormalizeXml(xmlString interface{}) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64EncodeIfNot ¶ added in v0.0.11
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
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
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
DecodeXmlString unescapes HTML entities in a string back to their original XML special characters.
func EncodeCustomTypeToPlist ¶ added in v0.0.11
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
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
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.