tips

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package tips provides utilities for displaying helpful tips to users during specific workflows. Tips are informational messages that can help users troubleshoot issues or learn about features.

Tips can be disabled globally using --no-tips or individually using --no-tip <tip-name>.

Index

Constants

View Source
const (
	// DebuggingDocs is the tip that points users to the debugging documentation.
	DebuggingDocs = "debugging-docs"

	// WindowsSymlinkWarning is the tip that warns Windows users about symlinks.
	WindowsSymlinkWarning = "windows-symlink-warning"

	// StackTargetMissingTypeStack is the tip shown when a `--filter` path targets a
	// stack directory but the filter is not restricted to stacks via `| type=stack`.
	StackTargetMissingTypeStack = "stack-target-missing-type-stack"

	// StackTargetMissingTypeStackMessage is the default message for the
	// stack-target-missing-type-stack tip. The runtime message that is shown to the
	// user is assembled at evaluation time so it can list the offending filters and
	// the suggested rewrites.
	StackTargetMissingTypeStackMessage = "One or more --filter paths target a stack directory " +
		"but the filter is not restricted to stacks. Without `| type=stack`, " +
		"`stack generate` will ignore the filter and `run` will not generate just that stack. " +
		"See https://docs.terragrunt.com/features/filter/#stack-generate"

	// WindowsSymlinkWarningMessage is the default message for the Windows symlink warning tip.
	WindowsSymlinkWarningMessage = "Windows users may encounter silent fallback behavior to provider copying " +
		"instead of symlinking in OpenTofu/Terraform. " +
		"See https://github.com/gruntwork-io/terragrunt/issues/5061 for more information."

	// WindowsSymlinkWarningOpenTofuMessage is the OpenTofu-specific message for the Windows symlink warning tip,
	// shown when the user is running OpenTofu >= 1.12.0.
	WindowsSymlinkWarningOpenTofuMessage = "Windows users may encounter silent fallback from symlinking to " +
		"copying for provider plugins. " +
		"Set TF_LOG=warn to check if OpenTofu is falling back to copying. " +
		"See https://github.com/gruntwork-io/terragrunt/issues/5061 for more information."
)

Variables

This section is empty.

Functions

func GiveStackTargetTip added in v1.0.5

func GiveStackTargetTip(l log.Logger, fs vfs.FS, workingDir string, filters filter.Filters, allTips Tips)

GiveStackTargetTip emits the StackTargetMissingTypeStack tip when a filter has a literal path expression pointing at a directory that contains terragrunt.stack.hcl.

Filters that already mention a `type=` attribute are skipped, since the user has chosen explicitly. Glob path expressions are skipped so the suggested rewrite can be pasted verbatim.

func SuggestStackTargetRewrite added in v1.0.5

func SuggestStackTargetRewrite(originalQuery string) string

SuggestStackTargetRewrite returns the suggested replacement for a filter query that targets a stack directory but is missing `| type=stack`. It is exported so the contract test can pin its behavior from a `tips_test` black-box test.

The contract holds because `|` is the only infix operator in the filter grammar and `!` binds tighter, so appending `| type=stack` always produces an InfixExpression whose right side is the stack-type attribute filter.

Types

type InvalidTipNameError

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

InvalidTipNameError is an error that is returned when an invalid tip name is requested.

func NewInvalidTipNameError

func NewInvalidTipNameError(requestedName string, allowedNames []string) *InvalidTipNameError

func (InvalidTipNameError) Error

func (err InvalidTipNameError) Error() string

func (InvalidTipNameError) Is

func (err InvalidTipNameError) Is(target error) bool

type Tip

type Tip struct {
	// Name is a unique identifier for the tip
	Name string
	// Message is the message to display when the tip is triggered
	Message string
	// OnceShow is a sync.Once to ensure the tip is only shown once per session
	OnceShow sync.Once
	// contains filtered or unexported fields
}

Tip represents a helpful tip displayed to users.

func (*Tip) Disable

func (tip *Tip) Disable()

Disable disables this tip from being shown.

func (*Tip) Evaluate

func (tip *Tip) Evaluate(l log.Logger)

Evaluate displays the tip if not disabled and not already shown.

func (*Tip) EvaluateWith added in v1.0.5

func (tip *Tip) EvaluateWith(l log.Logger, msg string)

EvaluateWith displays the tip with the given message if not disabled and not already shown. Use this for tips whose message is computed at evaluation time, so the caller doesn't need to mutate the shared Tip.Message field. Mutation would be racy under concurrent evaluation (e.g. `run --all`).

type Tips

type Tips []*Tip

Tips is a collection of Tip pointers.

func NewTips

func NewTips() Tips

NewTips returns a new Tips collection with all available tips.

Never remove any of these tips, as removing them will cause a breaking change for users using an invocation of `--no-tip` pointing to a non-existent tip.

e.g. `terragrunt run --no-tip=debugging-docs`

If you want to programmatically document that a tip should no longer be used after removing it from the codebase, just set `disabled` to `1` here for that tip.

func (Tips) DisableAll

func (t Tips) DisableAll()

DisableAll disables all tips such that they aren't shown.

func (Tips) DisableTip

func (t Tips) DisableTip(name string) error

DisableTip validates that the specified tip name is valid and disables this tip.

func (Tips) Find

func (t Tips) Find(name string) *Tip

Find searches and returns the tip by the given `name`.

func (Tips) Names

func (t Tips) Names() []string

Names returns all tip names.

Jump to

Keyboard shortcuts

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