tools

package
v0.124.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHelmVersion          = "3.14.4" // Deprecated: Use "latest" instead
	DefaultPreflightVersion     = "latest"
	DefaultSupportBundleVersion = "latest"
)

Default tool versions - kept for backward compatibility in tests In production, "latest" is used to fetch the most recent stable version from GitHub

View Source
const (
	ToolHelm          = "helm"
	ToolPreflight     = "preflight"
	ToolSupportBundle = "support-bundle"
)

Supported tool names

Variables

This section is empty.

Functions

func ConfigExists

func ConfigExists(startPath string) (bool, string, error)

ConfigExists checks if a .replicated config file exists in the current directory or parents

func GetCacheDir

func GetCacheDir() (string, error)

GetCacheDir returns the cache directory for tools Location: ~/.replicated/tools

func GetToolPath

func GetToolPath(name, version string) (string, error)

GetToolPath returns the cached path for a specific tool version Example: ~/.replicated/tools/helm/3.14.4/darwin-arm64/helm

func GetToolVersions

func GetToolVersions(config *Config) map[string]string

GetToolVersions extracts the tool versions from a config

func GetYAMLAPIVersion

func GetYAMLAPIVersion(path string) (string, error)

GetYAMLAPIVersion reads a YAML file and returns its apiVersion field

func IsCached

func IsCached(name, version string) (bool, error)

IsCached checks if a tool version is already cached

func IsNonInteractive

func IsNonInteractive() bool

IsNonInteractive checks if we're running in a non-interactive environment

func VerifyHelmChecksum

func VerifyHelmChecksum(data []byte, archiveURL string) error

VerifyHelmChecksum verifies a Helm binary against its .sha256sum file

func VerifyTroubleshootChecksum

func VerifyTroubleshootChecksum(data []byte, version, filename string) error

VerifyTroubleshootChecksum verifies preflight or support-bundle against checksums.txt

func WriteConfigFile

func WriteConfigFile(config *Config, path string) error

WriteConfigFile writes a config to a file using flow-style format

Types

type ChartConfig

type ChartConfig struct {
	Path         string `yaml:"path"`
	ChartVersion string `yaml:"chartVersion,omitempty"`
	AppVersion   string `yaml:"appVersion,omitempty"`
}

ChartConfig represents a chart entry in the config

type Config

type Config struct {
	AppId                 string            `yaml:"appId,omitempty"`
	AppSlug               string            `yaml:"appSlug,omitempty"`
	PromoteToChannelIds   []string          `yaml:"promoteToChannelIds,omitempty"`
	PromoteToChannelNames []string          `yaml:"promoteToChannelNames,omitempty"`
	Charts                []ChartConfig     `yaml:"charts,omitempty"`
	Preflights            []PreflightConfig `yaml:"preflights,omitempty"`
	ReleaseLabel          string            `yaml:"releaseLabel,omitempty"`
	Manifests             []string          `yaml:"manifests,omitempty"`
	ReplLint              *ReplLintConfig   `yaml:"repl-lint,omitempty"`
}

Config represents the parsed .replicated configuration file

type ConfigParser

type ConfigParser struct{}

ConfigParser handles parsing of .replicated config files

func NewConfigParser

func NewConfigParser() *ConfigParser

NewConfigParser creates a new config parser

func (*ConfigParser) ApplyDefaults

func (p *ConfigParser) ApplyDefaults(config *Config)

ApplyDefaults fills in default values for missing fields

func (*ConfigParser) DefaultConfig

func (p *ConfigParser) DefaultConfig() *Config

DefaultConfig returns a config with default values

func (*ConfigParser) FindAndParseConfig

func (p *ConfigParser) FindAndParseConfig(startPath string) (*Config, error)

FindAndParseConfig searches for a .replicated config file starting from the given path and walking up the directory tree. If path is empty, starts from current directory. Returns the parsed config or a default config if not found.

func (*ConfigParser) ParseConfig

func (p *ConfigParser) ParseConfig(data []byte) (*Config, error)

ParseConfig parses config data from YAML Does NOT apply defaults - caller should do that after merging

func (*ConfigParser) ParseConfigFile

func (p *ConfigParser) ParseConfigFile(path string) (*Config, error)

ParseConfigFile parses a .replicated config file (supports YAML)

type DetectedResources

type DetectedResources struct {
	Charts         []string
	Preflights     []string
	SupportBundles []string
	Manifests      []string
	ValuesFiles    []string
}

DetectedResources holds resources found during auto-detection

func AutoDetectResources

func AutoDetectResources(startPath string) (*DetectedResources, error)

AutoDetectResources searches the directory tree for Helm charts and preflight specs

type Downloader

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

Downloader handles downloading tool binaries

func NewDownloader

func NewDownloader() *Downloader

NewDownloader creates a new downloader with timeout

func (*Downloader) Download

func (d *Downloader) Download(ctx context.Context, name, version string) (string, error)

Download downloads a tool to the cache directory with checksum verification If the requested version fails, it will automatically fallback to latest stable Returns the actual version that was downloaded (may differ from requested version due to fallback)

func (*Downloader) DownloadWithFallback

func (d *Downloader) DownloadWithFallback(ctx context.Context, name, version string) (string, error)

DownloadWithFallback attempts to download the specified version, falling back to latest stable if it fails

type LinterConfig

type LinterConfig struct {
	Disabled *bool `yaml:"disabled,omitempty"` // pointer allows nil = not set
}

LinterConfig represents the configuration for a single linter

func (LinterConfig) IsEnabled

func (c LinterConfig) IsEnabled() bool

IsEnabled returns true if the linter is not disabled nil Disabled means not set, defaults to enabled (false = not disabled)

type LintersConfig

type LintersConfig struct {
	Helm            LinterConfig `yaml:"helm"`
	Preflight       LinterConfig `yaml:"preflight"`
	SupportBundle   LinterConfig `yaml:"support-bundle"`
	EmbeddedCluster LinterConfig `yaml:"embedded-cluster"`
	Kots            LinterConfig `yaml:"kots"`
}

LintersConfig contains configuration for each linter

type PreflightConfig

type PreflightConfig struct {
	Path         string `yaml:"path"`
	ChartName    string `yaml:"chartName,omitempty"`    // Optional: explicit chart reference (must provide chartVersion if set)
	ChartVersion string `yaml:"chartVersion,omitempty"` // Optional: explicit chart version (must provide chartName if set)
}

PreflightConfig represents a preflight entry in the config Path is required. ChartName and ChartVersion are optional but must be provided together.

type ReplLintConfig

type ReplLintConfig struct {
	Version int               `yaml:"version"`
	Linters LintersConfig     `yaml:"linters"`
	Tools   map[string]string `yaml:"tools,omitempty"`
}

ReplLintConfig is the lint configuration section

type Resolver

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

Resolver resolves tool binaries, downloading and caching as needed

func NewResolver

func NewResolver() *Resolver

NewResolver creates a new tool resolver

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, name, version string) (string, error)

Resolve returns the path to a tool binary, downloading if not cached

func (*Resolver) ResolveLatestVersion

func (r *Resolver) ResolveLatestVersion(ctx context.Context, name string) (string, error)

ResolveLatestVersion fetches the latest stable version for a tool from replicated.app/ping without downloading it. Useful for displaying version information.

Directories

Path Synopsis
cmd
download command

Jump to

Keyboard shortcuts

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