plist

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

common/configurationprofiles/plist/plistdiffsuppression.go contains the functions to process configuration profiles for diff suppression.

common/configurationprofiles/plist/payload.go Description: This file contains the ConfigurationProfile and PayloadContent structs, as well as functions for unmarshalling, marshalling, and validating plist payloads.

common/configurationprofiles/plist/shared.go contains the shared functions to process configuration profiles.

common/configurationprofiles/plist/state.go contains the functions to process configuration profiles for terraform state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertHCLToPlist

func ConvertHCLToPlist(d *schema.ResourceData) (string, error)

ConvertHCLToPlist builds a plist from the Terraform HCL schema data

func ConvertPlistToHCL

func ConvertPlistToHCL(plistXML string) ([]interface{}, error)

ConvertPlistToHCL converts a plist XML string to Terraform HCL schema data

func DecodePlist

func DecodePlist(plistData []byte) (map[string]interface{}, error)

Function to decode a plist into a map without removing any fields

func EncodePlist

func EncodePlist(cleanedData map[string]interface{}) (string, error)

EncodePlist encodes a cleaned map back to plist XML format

func GetTypedValue

func GetTypedValue(value interface{}) interface{}

GetTypedValue converts the value from the HCL always stored as string into the appropriate type for plist serialization.

func MarshalPayload

func MarshalPayload(profile *ConfigurationProfile) (string, error)

MarshalPayload marshals a ConfigurationProfile struct into a plist payload using mapstructure.

func MergeConfigurationPayloadFieldsIntoMap

func MergeConfigurationPayloadFieldsIntoMap(payload *PayloadContent) map[string]interface{}

MergeConfigurationPayloadFieldsIntoMap merges the fields of a ConfigurationPayload struct into a map.

func MergeConfigurationProfileFieldsIntoMap

func MergeConfigurationProfileFieldsIntoMap(profile *ConfigurationProfile) map[string]interface{}

MergeConfigurationProfileFieldsIntoMap merges the fields of a ConfigurationProfile struct into a map.

func NormalizePayloadState

func NormalizePayloadState(payload any) string

NormalizePayloadState normalizes a payload state by unmarshalling and remarshal it.

func ProcessConfigurationProfileForDiffSuppression

func ProcessConfigurationProfileForDiffSuppression(plistData string, fieldsToRemove []string) (string, error)

ProcessConfigurationProfileForDiffSuppression processes the plist data, removes specified fields, and returns the cleaned plist XML as a string.

func ProcessConfigurationProfileForState

func ProcessConfigurationProfileForState(plistData string) (string, error)

ProcessConfigurationProfileForState processes the plist data, removes specified fields, and returns the cleaned plist XML as a string.

func RemoveFields

func RemoveFields(data map[string]interface{}, fieldsToRemove []string, path string)

RemoveFields removes specified fields from a nested map

func SortPlistKeys

func SortPlistKeys(data map[string]interface{}) map[string]interface{}

SortPlistKeys recursively sorts the keys of a nested map in alphabetical order, and sorts elements within arrays if they are strings or dictionaries.

func ValidatePayload

func ValidatePayload(payload interface{}, key string) (warns []string, errs []error)

ValidatePayload validates a payload by unmarshalling it and checking for required fields.

func ValidatePayloadFields

func ValidatePayloadFields(profile *ConfigurationProfile) []error

ValidatePayloadFields validates the fields of a ConfigurationProfile struct.

Types

type ConfigurationProfile

type ConfigurationProfile struct {
	// Standard / Expected
	PayloadDescription       string           `mapstructure:"PayloadDescription"`
	PayloadDisplayName       string           `mapstructure:"PayloadDisplayName" validate:"required"`
	PayloadEnabled           bool             `mapstructure:"PayloadEnabled" validate:"required"`
	PayloadIdentifier        string           `mapstructure:"PayloadIdentifier" validate:"required"`
	PayloadOrganization      string           `mapstructure:"PayloadOrganization" validate:"required"`
	PayloadRemovalDisallowed bool             `mapstructure:"PayloadRemovalDisallowed" validate:"required"`
	PayloadScope             string           `mapstructure:"PayloadScope" validate:"required,oneof=System User Computer"`
	PayloadType              string           `mapstructure:"PayloadType" validate:"required,eq=Configuration"`
	PayloadUUID              string           `mapstructure:"PayloadUUID" validate:"required"`
	PayloadVersion           int              `mapstructure:"PayloadVersion" validate:"required,eq=1"`
	PayloadContent           []PayloadContent `mapstructure:"PayloadContent"`

	// Catch all for unexpected fields
	Unexpected map[string]interface{} `mapstructure:",remain"`
}

ConfigurationProfile represents a root level MacOS configuration profile.

func UnmarshalPayload

func UnmarshalPayload(payload string) (*ConfigurationProfile, error)

UnmarshalPayload unmarshals a plist payload into a ConfigurationProfile struct using mapstructure.

type PayloadContent

type PayloadContent struct {

	// Standard / Expected
	PayloadDescription  string `mapstructure:"PayloadDescription"`
	PayloadDisplayName  string `mapstructure:"PayloadDisplayName"`
	PayloadEnabled      bool   `mapstructure:"PayloadEnabled"`
	PayloadIdentifier   string `mapstructure:"PayloadIdentifier"`
	PayloadOrganization string `mapstructure:"PayloadOrganization"`
	PayloadType         string `mapstructure:"PayloadType"`
	PayloadUUID         string `mapstructure:"PayloadUUID"`
	PayloadVersion      int    `mapstructure:"PayloadVersion"`
	PayloadScope        string `mapstructure:"PayloadScope"`

	// Variable
	ConfigurationItems map[string]interface{} `mapstructure:",remain"`
}

ConfigurationPayload represents a nested MacOS configuration profile.

Directories

Path Synopsis
test
encode command
removekeys command
sortkeys command
state command

Jump to

Keyboard shortcuts

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