compare

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package compare provides functionality for comparing two Port organizations.

Package compare provides functionality for comparing two Port organizations.

Package compare provides functionality for comparing two Port organizations.

Package compare provides functionality for comparing two Port organizations.

Package compare provides functionality for comparing two Port organizations.

Index

Constants

This section is empty.

Variables

View Source
var ExcludedFields = map[string]bool{
	"_id":       true,
	"id":        true,
	"orgId":     true,
	"createdAt": true,
	"createdBy": true,
	"updatedAt": true,
	"updatedBy": true,
	"icon":      true,
	"color":     true,
}

ExcludedFields contains fields to exclude from comparison. These fields are typically auto-generated or organization-specific.

Functions

func FormatPath

func FormatPath(path string) string

FormatPath formats a diff path for display.

Types

type CompareResult

type CompareResult struct {
	Source               string
	Target               string
	Timestamp            string
	Identical            bool
	Blueprints           ResourceDiff
	Actions              ResourceDiff
	Scorecards           ResourceDiff
	Pages                ResourceDiff
	Integrations         ResourceDiff
	Teams                ResourceDiff
	Users                ResourceDiff
	Automations          ResourceDiff
	BlueprintPermissions ResourceDiff
	ActionPermissions    ResourceDiff
	Entities             ResourceDiff
}

CompareResult represents the full comparison result.

type DiffSummary

type DiffSummary struct {
	Added    int
	Modified int
	Removed  int
}

DiffSummary represents the summary of differences for a resource type.

type Differ

type Differ struct {
	// contains filtered or unexported fields
}

Differ computes differences between two organizations.

func NewDiffer

func NewDiffer() *Differ

NewDiffer creates a new differ with default excluded fields.

func (*Differ) Diff

func (d *Differ) Diff(source, target *export.Data, include []string) *CompareResult

Diff compares source and target org data, optionally filtered to specific resource types. An empty include slice means all resource types are compared.

type FetchOptions

type FetchOptions struct {
	OrgName          string
	FilePath         string
	ClientID         string
	ClientSecret     string
	APIUrl           string
	IncludeResources []string
}

FetchOptions contains options for fetching org data.

type Fetcher

type Fetcher struct {
	// contains filtered or unexported fields
}

Fetcher loads organization data from live orgs or export files.

func NewFetcher

func NewFetcher(configManager *config.ConfigManager) *Fetcher

NewFetcher creates a new fetcher.

func (*Fetcher) Fetch

func (f *Fetcher) Fetch(ctx context.Context, opts FetchOptions) (*OrgData, error)

Fetch loads organization data from either a live org or export file.

type FieldDiff

type FieldDiff struct {
	Path        string
	SourceValue interface{}
	TargetValue interface{}
}

FieldDiff represents a single field-level difference.

type HTMLData

type HTMLData struct {
	Source        string
	Target        string
	Timestamp     string
	Identical     bool
	TotalAdded    int
	TotalModified int
	TotalRemoved  int
	Sections      []HTMLSection
}

HTMLData represents the data passed to HTML templates.

type HTMLFormatter

type HTMLFormatter struct {
	// contains filtered or unexported fields
}

HTMLFormatter formats comparison results as HTML.

func NewHTMLFormatter

func NewHTMLFormatter(w io.Writer, simple bool) *HTMLFormatter

NewHTMLFormatter creates a new HTML formatter.

func (*HTMLFormatter) Format

func (f *HTMLFormatter) Format(result *CompareResult) error

Format outputs the comparison result as HTML.

type HTMLSection

type HTMLSection struct {
	Name          string
	Added         int
	Modified      int
	Removed       int
	HasChanges    bool
	AddedItems    []ResourceChange
	ModifiedItems []ResourceChange
	RemovedItems  []ResourceChange
}

HTMLSection represents a section in the HTML report.

type JSONFieldDiff

type JSONFieldDiff struct {
	Path        string      `json:"path"`
	SourceValue interface{} `json:"source_value"`
	TargetValue interface{} `json:"target_value"`
}

JSONFieldDiff represents a field-level diff in JSON.

type JSONFormatter

type JSONFormatter struct {
	// contains filtered or unexported fields
}

JSONFormatter formats comparison results as JSON.

func NewJSONFormatter

func NewJSONFormatter(w io.Writer) *JSONFormatter

NewJSONFormatter creates a new JSON formatter.

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(result *CompareResult) error

Format outputs the comparison result as JSON.

type JSONOutput

type JSONOutput struct {
	Source    string                      `json:"source"`
	Target    string                      `json:"target"`
	Timestamp string                      `json:"timestamp"`
	Summary   JSONSummary                 `json:"summary"`
	Identical bool                        `json:"identical"`
	Diffs     map[string]JSONResourceDiff `json:"differences"`
}

JSONOutput represents the JSON output structure.

type JSONResourceChange

type JSONResourceChange struct {
	Identifier string                 `json:"identifier"`
	Data       map[string]interface{} `json:"data,omitempty"`
	SourceData map[string]interface{} `json:"source,omitempty"`
	TargetData map[string]interface{} `json:"target,omitempty"`
	Changes    []JSONFieldDiff        `json:"changes,omitempty"`
}

JSONResourceChange represents a single changed resource in JSON.

type JSONResourceDiff

type JSONResourceDiff struct {
	Added    []JSONResourceChange `json:"added,omitempty"`
	Modified []JSONResourceChange `json:"modified,omitempty"`
	Removed  []JSONResourceChange `json:"removed,omitempty"`
}

JSONResourceDiff represents differences for a resource type in JSON.

type JSONSummary

type JSONSummary struct {
	TotalAdded    int `json:"total_added"`
	TotalModified int `json:"total_modified"`
	TotalRemoved  int `json:"total_removed"`
}

JSONSummary represents the overall summary.

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module handles organization comparison operations.

func NewModule

func NewModule(configManager *config.ConfigManager) *Module

NewModule creates a new compare module.

func (*Module) Execute

func (m *Module) Execute(ctx context.Context, opts Options) (*CompareResult, error)

Execute runs the comparison and returns results.

func (*Module) FormatOutput

func (m *Module) FormatOutput(result *CompareResult, opts Options) error

FormatOutput formats the result based on options.

type Options

type Options struct {
	SourceOrg        string   // Source org name from config
	TargetOrg        string   // Target org name from config
	SourceFile       string   // Source export file path (alternative to org)
	TargetFile       string   // Target export file path (alternative to org)
	SourceClientID   string   // Override source client ID
	SourceSecret     string   // Override source client secret
	TargetClientID   string   // Override target client ID
	TargetSecret     string   // Override target client secret
	OutputFormat     string   // text, json, html
	HTMLFile         string   // Output path for HTML report
	HTMLSimple       bool     // Use simple HTML template
	Verbose          bool     // Show identifiers
	Full             bool     // Show full diff
	IncludeResources []string // Filter resource types
	FailOnDiff       bool     // Exit 1 if differences found
}

Options represents compare options.

type OrgData

type OrgData struct {
	Name string
	Data *export.Data
}

OrgData wraps export.Data for comparison.

type ResourceChange

type ResourceChange struct {
	Identifier string
	SourceData map[string]interface{}
	TargetData map[string]interface{}
	FieldDiffs []FieldDiff
}

ResourceChange represents a single changed resource.

type ResourceDiff

type ResourceDiff struct {
	Summary  DiffSummary
	Added    []ResourceChange
	Modified []ResourceChange
	Removed  []ResourceChange
}

ResourceDiff represents differences for a single resource type.

type TextFormatter

type TextFormatter struct {
	// contains filtered or unexported fields
}

TextFormatter formats comparison results as text.

func NewTextFormatter

func NewTextFormatter(w io.Writer, verbose, full bool, includeResources []string) *TextFormatter

NewTextFormatter creates a new text formatter.

func (*TextFormatter) Format

func (f *TextFormatter) Format(result *CompareResult) error

Format outputs the comparison result as text.

Jump to

Keyboard shortcuts

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