Documentation
¶
Index ¶
- Variables
- func CountResources(generatedFile string) (map[string]int, error)
- func DefaultRules() []postprocess.ReferenceRule
- func GenerateQueryFile(outputDir string, selectedResources map[string]bool) error
- func ParseQueryEvents(eventsFile string) (map[string]map[string]string, error)
- func PopulateRegistryFromGenerated(generatedFile string, reg *registry.Registry) error
- func PopulateRegistryFromImportFiles(outputDir string, reg *registry.Registry) error
- func RenameLabels(generatedFile string) error
- func RenameLabelsWithEvents(generatedFile string, idToName map[string]map[string]string) error
- func ResourceTypeDisplayName(resourceType string) string
- func RunPipeline(opts *PipelineOptions) (*postprocess.FixResult, error)
- func TypeToFileMap() map[string]string
- func ValidFilterNames() map[string]string
- func WriteSingletonImports(outputDir string, selectedResources map[string]bool, skipDataForwarding bool) error
- type PipelineOptions
- type ResourceDef
Constants ¶
This section is empty.
Variables ¶
var Quiet bool
Quiet suppresses progress messages.
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 ¶
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 ¶
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
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 ¶
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 ¶
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 ¶
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
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 ¶
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 ¶
TypeToFileMap returns a map of TF resource type → output filename, derived from the Resources table.
func ValidFilterNames ¶
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.