trigger

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Trigger

type Trigger interface {
	// Validate checks tag triggers for conflicts across all configured
	// tags. Returns error if any triggers conflict within same type
	// (same IP, hostname, or overlapping times in multiple tags).
	// Should be called at application startup before using other methods.
	Validate() error

	// FindMatchingTag returns the tag ID that matches current environment
	// triggers. Returns empty string if no triggers match.
	//
	// When multiple tags match due to cross-type triggers, uses precedence:
	// IP > hostname > time. Returns error if multiple tags match at the
	// same precedence level (normally such errors should be caught by
	// validation).
	FindMatchingTag() (string, error)
}

Trigger defines the interface for tag trigger evaluation and validation. Implementations determine which tag should be active based on current environment conditions (hostname, IP address, time of day).

Trigger Matching Logic

Within a single tag, triggers use OR logic:

  • Any IP matches OR hostname matches OR any time matches → tag active

Conflict Detection

Validate() detects conflicts within the same trigger type:

  • Same IP in multiple tags → error
  • Same hostname in multiple tags → error
  • Overlapping time ranges in multiple tags → error

However, cross-type conflicts can still occur:

  • Tag "home": IP=192.168.0.100
  • Tag "work": hostname="work-laptop" Both can match simultaneously if conditions overlap.

Precedence for Multiple Matches

When multiple tags match (cross-type conflict), precedence:

  1. IP address (most location-specific, changes with network)
  2. Hostname (machine-specific, but same across locations)
  3. Time range (least specific, varies by timezone/travel)

This order makes sense for traveling laptops: IP identifies current network (home vs office), hostname stays constant.

If multiple tags match at the same precedence level, returns error.

Jump to

Keyboard shortcuts

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