Documentation
¶
Overview ¶
Copyright © 2025 Stackaroo Contributors SPDX-License-Identifier: BSD-3-Clause
Copyright © 2025 Stackaroo Contributors SPDX-License-Identifier: BSD-3-Clause
Copyright © 2025 Stackaroo Contributors SPDX-License-Identifier: BSD-3-Clause
Copyright © 2025 Stackaroo Contributors SPDX-License-Identifier: BSD-3-Clause
Copyright © 2025 Stackaroo Contributors SPDX-License-Identifier: BSD-3-Clause
Copyright © 2025 Stackaroo Contributors SPDX-License-Identifier: BSD-3-Clause
Copyright © 2025 Stackaroo Contributors SPDX-License-Identifier: BSD-3-Clause
Copyright © 2025 Stackaroo Contributors SPDX-License-Identifier: BSD-3-Clause
Copyright © 2025 Stackaroo Contributors SPDX-License-Identifier: BSD-3-Clause
Index ¶
- Constants
- func ColorizeUnifiedDiff(diff string, styles *Styles) string
- func GetResourceTypeURL(resourceType string) string
- func Highlight(text string) string
- func Hyperlink(url, text string) string
- func HyperlinkResourceType(resourceType string) string
- func ShouldUseColour() bool
- type ChangeType
- type DefaultParameterComparator
- type DefaultTagComparator
- type Differ
- type MockDiffer
- type MockParameterComparator
- type MockTagComparator
- type MockTemplateComparator
- type Options
- type ParameterComparator
- type ParameterDiff
- type Result
- type StackDiffer
- type Styles
- type TagComparator
- type TagDiff
- type TemplateChange
- type TemplateComparator
- type YAMLTemplateComparator
Constants ¶
const CloudFormationDocsBaseURL = "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/"
CloudFormationDocsBaseURL is the base URL for CloudFormation resource documentation
Variables ¶
This section is empty.
Functions ¶
func ColorizeUnifiedDiff ¶
ColorizeUnifiedDiff applies color formatting to unified diff output
func GetResourceTypeURL ¶
GetResourceTypeURL returns the CloudFormation documentation URL for a given resource type.
CloudFormation resource types follow the pattern: AWS::Service::ResourceType Documentation URLs follow the pattern: aws-resource-service-resourcetype.html
Parameters:
- resourceType: A CloudFormation resource type (e.g., "AWS::S3::Bucket")
Returns the full documentation URL, or an empty string if the resource type is invalid or doesn't match the expected format.
Examples:
GetResourceTypeURL("AWS::S3::Bucket")
// Returns: "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-s3-bucket.html"
GetResourceTypeURL("AWS::EC2::Instance")
// Returns: "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-instance.html"
GetResourceTypeURL("InvalidFormat")
// Returns: ""
func Hyperlink ¶
Hyperlink wraps text with terminal hyperlink escape codes (OSC 8). This allows terminals that support it to display clickable links.
The OSC 8 format is: ESC ]8;;URL ESC \ TEXT ESC ]8;; ESC \ Where ESC is the escape character (\033).
Supported terminals include:
- iTerm2 (3.1+)
- Terminal.app (macOS 10.15+)
- GNOME Terminal (3.26+)
- Konsole
- VS Code integrated terminal
- Windows Terminal
Terminals without hyperlink support will display the text normally without any visual artifacts.
Parameters:
- url: The target URL for the hyperlink
- text: The visible text to display
Returns the text wrapped with hyperlink escape codes, or just the text if either url or text is empty.
Example:
link := Hyperlink("https://example.com", "Example")
fmt.Println(link) // Displays "Example" as a clickable link
func HyperlinkResourceType ¶
HyperlinkResourceType creates a clickable hyperlink for a CloudFormation resource type.
This is a convenience function that combines GetResourceTypeURL with Hyperlink to create a terminal hyperlink pointing to the CloudFormation documentation for the given resource type.
Parameters:
- resourceType: A CloudFormation resource type (e.g., "AWS::S3::Bucket")
Returns the resource type text wrapped with hyperlink escape codes, or just the original text if the resource type is invalid or empty.
Example:
link := HyperlinkResourceType("AWS::S3::Bucket")
// In supported terminals, displays "AWS::S3::Bucket" as a clickable link
// to the S3 Bucket CloudFormation documentation
func ShouldUseColour ¶
func ShouldUseColour() bool
ShouldUseColour determines if colour output should be used
Types ¶
type ChangeType ¶
type ChangeType string
ChangeType indicates the type of change detected
const ( ChangeTypeAdd ChangeType = "ADD" ChangeTypeModify ChangeType = "MODIFY" ChangeTypeRemove ChangeType = "REMOVE" )
type DefaultParameterComparator ¶
type DefaultParameterComparator struct{}
DefaultParameterComparator implements ParameterComparator interface
func (*DefaultParameterComparator) Compare ¶
func (c *DefaultParameterComparator) Compare(currentParams, proposedParams map[string]string) ([]ParameterDiff, error)
Compare compares current and proposed parameters, returning differences
type DefaultTagComparator ¶
type DefaultTagComparator struct{}
DefaultTagComparator implements TagComparator interface
type Differ ¶
type Differ interface {
// DiffStack compares a resolved stack configuration with the deployed stack
DiffStack(ctx context.Context, stack *model.Stack, options Options) (*Result, error)
}
Differ defines the interface for performing stack diffs
type MockDiffer ¶
MockDiffer implements Differ for testing
type MockParameterComparator ¶
MockParameterComparator implements ParameterComparator for testing
func (*MockParameterComparator) Compare ¶
func (m *MockParameterComparator) Compare(currentParams, proposedParams map[string]string) ([]ParameterDiff, error)
type MockTagComparator ¶
MockTagComparator implements TagComparator for testing
type MockTemplateComparator ¶
MockTemplateComparator implements TemplateComparator for testing
func (*MockTemplateComparator) Compare ¶
func (m *MockTemplateComparator) Compare(ctx context.Context, currentTemplate, proposedTemplate string) (*TemplateChange, error)
type Options ¶
type Options struct {
// Filter options - if all are false, compare everything
TemplateOnly bool // Only compare templates
ParametersOnly bool // Only compare parameters
TagsOnly bool // Only compare tags
// Changeset lifecycle control
KeepChangeSet bool // Keep changeset alive after diff (for deployment use)
}
Options configures what aspects of the stack to compare
type ParameterComparator ¶
type ParameterComparator interface {
Compare(currentParams, proposedParams map[string]string) ([]ParameterDiff, error)
}
ParameterComparator handles parameter comparisons
func NewParameterComparator ¶
func NewParameterComparator() ParameterComparator
NewParameterComparator creates a new parameter comparator
type ParameterDiff ¶
type ParameterDiff struct {
Key string
CurrentValue string
ProposedValue string
ChangeType ChangeType
}
ParameterDiff represents a difference in stack parameters
type Result ¶
type Result struct {
StackName string
Context string
StackExists bool // Whether the stack exists in AWS
TemplateChange *TemplateChange
ParameterDiffs []ParameterDiff
TagDiffs []TagDiff
ChangeSet *aws.ChangeSetInfo // AWS changeset information when available
ChangeSetError error // Error encountered during changeset generation (if any)
Options Options // Options used for this diff
}
Result contains the results of a stack diff operation
func (*Result) HasChanges ¶
HasChanges returns true if any changes were detected
type StackDiffer ¶
type StackDiffer struct {
// contains filtered or unexported fields
}
StackDiffer implements the Differ interface using AWS CloudFormation
func NewStackDiffer ¶
func NewStackDiffer(clientFactory aws.ClientFactory) *StackDiffer
NewStackDiffer creates a new StackDiffer with provided client factory
type Styles ¶
type Styles struct {
// Change type styles (with background - for template diffs only)
Added lipgloss.Style
Removed lipgloss.Style
Modified lipgloss.Style
DiffContext lipgloss.Style
DiffHunk lipgloss.Style
// Change type styles (text only - for parameters, tags, plan)
AddedText lipgloss.Style
RemovedText lipgloss.Style
ModifiedText lipgloss.Style
// Status styles
StatusNew lipgloss.Style
StatusChanges lipgloss.Style
StatusNoChange lipgloss.Style
// Header styles
Header lipgloss.Style
HeaderTitle lipgloss.Style
HeaderValue lipgloss.Style
// Section styles
SectionHeader lipgloss.Style
SectionHeaderInactive lipgloss.Style
SectionActive lipgloss.Style
SectionInactive lipgloss.Style
SubSection lipgloss.Style
// Content styles
Key lipgloss.Style
Value lipgloss.Style
Arrow lipgloss.Style
Subtle lipgloss.Style
Bold lipgloss.Style
// Semantic styles
Success lipgloss.Style
Warning lipgloss.Style
Error lipgloss.Style
// Risk level styles
RiskLow lipgloss.Style
RiskMedium lipgloss.Style
RiskHigh lipgloss.Style
// Layout styles
Separator lipgloss.Style
// Whether colours are enabled
UseColour bool
}
Styles contains all the styles for rendering diff output
func (*Styles) GetChangeSetSymbol ¶
GetChangeSetSymbol returns the appropriate symbol for a changeset action
func (*Styles) GetChangeSymbol ¶
func (s *Styles) GetChangeSymbol(changeType ChangeType) string
GetChangeSymbol returns the appropriate symbol for a change type
type TagComparator ¶
type TagComparator interface {
Compare(currentTags, proposedTags map[string]string) ([]TagDiff, error)
}
TagComparator handles tag comparisons
func NewTagComparator ¶
func NewTagComparator() TagComparator
NewTagComparator creates a new tag comparator
type TagDiff ¶
type TagDiff struct {
Key string
CurrentValue string
ProposedValue string
ChangeType ChangeType
}
TagDiff represents a difference in stack tags
type TemplateChange ¶
type TemplateChange struct {
HasChanges bool
CurrentHash string // Hash of currently deployed template
ProposedHash string // Hash of proposed template
Diff string // Human-readable diff output
ResourceCount struct {
Added int
Modified int
Removed int
}
}
TemplateChange represents differences in CloudFormation templates
type TemplateComparator ¶
type TemplateComparator interface {
Compare(ctx context.Context, currentTemplate, proposedTemplate string) (*TemplateChange, error)
}
TemplateComparator handles CloudFormation template comparisons
func NewYAMLTemplateComparator ¶
func NewYAMLTemplateComparator() TemplateComparator
NewYAMLTemplateComparator creates a new YAML template comparator
type YAMLTemplateComparator ¶
type YAMLTemplateComparator struct{}
YAMLTemplateComparator implements TemplateComparator for YAML CloudFormation templates
func (*YAMLTemplateComparator) Compare ¶
func (c *YAMLTemplateComparator) Compare(ctx context.Context, currentTemplate, proposedTemplate string) (*TemplateChange, error)
Compare compares two CloudFormation templates and returns the differences