Help us shape the future of Go! Take the 2026 Go Developer Survey

protect

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Quiet bool

Quiet suppresses progress messages.

View Source
var Resources = []ResourceDef{
	{FilterKey: "roles", DisplayName: "Roles", TFType: "jamfprotect_role", OutputFile: "roles.tf"},
	{FilterKey: "groups", DisplayName: "Groups", TFType: "jamfprotect_group", OutputFile: "groups.tf"},
	{FilterKey: "users", DisplayName: "Users", TFType: "jamfprotect_user", OutputFile: "users.tf"},
	{FilterKey: "api_clients", DisplayName: "API Clients", TFType: "jamfprotect_api_client", OutputFile: "api_clients.tf"},
	{FilterKey: "analytics", DisplayName: "Analytics", TFType: "jamfprotect_analytic", OutputFile: "analytics.tf"},
	{FilterKey: "analytics_managed", DisplayName: "Jamf Managed Analytics", TFType: "jamfprotect_analytic_managed", OutputFile: "analytics_managed.tf"},
	{FilterKey: "analytic_sets", DisplayName: "Analytic Sets", TFType: "jamfprotect_analytic_set", OutputFile: "analytic_sets.tf"},
	{FilterKey: "exception_sets", DisplayName: "Exception Sets", TFType: "jamfprotect_exception_set", OutputFile: "exception_sets.tf"},
	{FilterKey: "action_configurations", DisplayName: "Action Configurations", TFType: "jamfprotect_action_configuration", OutputFile: "action_configurations.tf"},
	{FilterKey: "telemetry", DisplayName: "Telemetry", TFType: "jamfprotect_telemetry", OutputFile: "telemetry.tf"},
	{FilterKey: "unified_logging_filters", DisplayName: "Unified Logging Filters", TFType: "jamfprotect_unified_logging_filter", OutputFile: "unified_logging_filters.tf"},
	{FilterKey: "unified_logging_filter_sets", DisplayName: "Unified Logging Filter Sets", TFType: "jamfprotect_unified_logging_filter_set", OutputFile: "unified_logging_filter_sets.tf"},
	{FilterKey: "custom_prevent_lists", DisplayName: "Custom Prevent Lists", TFType: "jamfprotect_custom_prevent_list", OutputFile: "custom_prevent_lists.tf"},
	{FilterKey: "removable_storage_control_sets", DisplayName: "Removable Storage Control Sets", TFType: "jamfprotect_removable_storage_control_set", OutputFile: "removable_storage_control_sets.tf"},
	{FilterKey: "plans", DisplayName: "Plans", TFType: "jamfprotect_plan", OutputFile: "plans.tf"},
	{FilterKey: "change_management", DisplayName: "Change Management (singleton)", TFType: "jamfprotect_change_management", OutputFile: "change_management.tf"},
	{FilterKey: "data_forwarding", DisplayName: "Data Forwarding (singleton)", TFType: "jamfprotect_data_forwarding", OutputFile: "data_forwarding.tf"},
	{FilterKey: "data_retention", DisplayName: "Data Retention (singleton)", TFType: "jamfprotect_data_retention", OutputFile: "data_retention.tf"},
}

Resources is the ordered list of all supported Jamf Protect resource types. Order matches the interactive selection prompt order.

Functions

func CountResources

func CountResources(generatedFile string) (map[string]int, error)

CountResources counts resource blocks by type in the generated file.

func DefaultRules

func DefaultRules() []postprocess.ReferenceRule

DefaultRules returns the reference rules for Jamf Protect resource types.

func GenerateQueryFile

func GenerateQueryFile(outputDir string, selectedResources map[string]bool) error

GenerateQueryFile writes a .tfquery.hcl file with list blocks for selected resource types. Singleton import blocks are written separately via WriteSingletonImports (called after terraform query completes, so the import blocks don't interfere with the query step). If selectedResources is nil, all resource types are included.

func ParseQueryEvents added in v0.2.0

func ParseQueryEvents(eventsFile string) (map[string]map[string]string, error)

ParseQueryEvents reads a terraform query -json event log and returns a nested map of resourceType -> id -> display_name. Events without an ID or display_name are skipped. Lines that fail to parse are ignored (the log includes other event types we don't care about).

func PopulateRegistryFromGenerated

func PopulateRegistryFromGenerated(generatedFile string, reg *registry.Registry) error

PopulateRegistryFromGenerated parses a generated HCL file and populates the registry with resource type + ID -> address mappings. IDs are extracted from import blocks (which use "identity { id = ... }" for query-generated imports, or flat "id = ..." for singleton imports).

func PopulateRegistryFromImportFiles

func PopulateRegistryFromImportFiles(outputDir string, reg *registry.Registry) error

PopulateRegistryFromImportFiles reads all *_import.tf files in a directory and populates the registry. This handles the case where import blocks have already been split into per-type files by the post-processor.

func RenameLabels

func RenameLabels(generatedFile string) error

RenameLabels rewrites auto-generated labels (like "all_0") in the generated HCL file to friendly names derived from resource attributes.

func RenameLabelsWithEvents added in v0.2.0

func RenameLabelsWithEvents(generatedFile string, idToName map[string]map[string]string) error

RenameLabelsWithEvents is like RenameLabels but uses display_name values captured from the terraform query JSON event stream as a fallback for resource types whose name attribute is not present in the generated HCL (e.g. jamfprotect_analytic_managed).

func ResourceTypeDisplayName

func ResourceTypeDisplayName(resourceType string) string

ResourceTypeDisplayName returns a human-readable name for a resource type.

func RunPipeline

func RunPipeline(opts *PipelineOptions) (*postprocess.FixResult, error)

RunPipeline executes the full Jamf Protect export pipeline: generate provider config → query file → terraform init → terraform query → post-process. Returns the validation fix result (may be nil) and any fatal error.

func TypeToFileMap

func TypeToFileMap() map[string]string

TypeToFileMap returns a map of TF resource type → output filename, derived from the Resources table.

func ValidFilterNames

func ValidFilterNames() map[string]string

ValidFilterNames returns a map of user-friendly filter names → canonical keys.

func WriteSingletonImports

func WriteSingletonImports(outputDir string, selectedResources map[string]bool, skipDataForwarding bool) error

WriteSingletonImports writes import blocks for singleton resources to singletons_import.tf. Must be called after terraform query completes. skipDataForwarding excludes data_forwarding when pre-discovery found no forwarding services enabled.

Types

type PipelineOptions

type PipelineOptions struct {
	OutputDir          string
	URL                string
	ClientID           string
	ClientSecret       string
	SelectedResources  map[string]bool
	SkipReferences     bool
	ProviderVersion    string
	Quiet              bool
	Verbose            bool
	SkipDataForwarding bool                   // pre-discovered: no forwarding services enabled
	StatusFunc         func(string, int, int) // optional callback: (message, current, total)
}

PipelineOptions holds all parameters needed to run the Jamf Protect pipeline.

type ResourceDef

type ResourceDef struct {
	FilterKey   string // key for -include-resources / -exclude-resources
	DisplayName string // human-readable name for prompts and output
	TFType      string // Terraform resource type name
	OutputFile  string // filename in the output directory
}

ResourceDef describes a single Jamf Protect resource type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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