helpers

package
v0.0.0-...-a7db3d2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CtrlDir = "__ctrl__"
	WorkDir = "__work__"
)

Variables

This section is empty.

Functions

func AskForConfirmation

func AskForConfirmation(s string) bool

func Base64Decode

func Base64Decode(s string) (string, error)

func ConfigForTarget

func ConfigForTarget(target types.Target) (interface{}, error)

func GenerateRandomString

func GenerateRandomString(length int) string

func GenerateTemporarySSHKey

func GenerateTemporarySSHKey(ctx context.Context) (public string, private string, err error)

func GetTargetsConfigPath

func GetTargetsConfigPath() string

GetTargetsConfigPath returns the path to the infrastructure directory containing target configurations. Priority:

  1. Viper config key "targets_config_dir" (can be set via CLI flag, env var, or config file)
  2. Default: filepath.Join(TOP, "infra")

The path can be:

  • Absolute: used as-is
  • Relative: resolved relative to TOP

func GitTop

func GitTop() (string, error)

func KillProcess

func KillProcess(pid int) error

KillProcess sends SIGKILL to the process group led by pid, so any child processes forked by the target (e.g. the python subprocess spawned by the `az` bash wrapper) are reaped along with it. It expects pid to be the process group leader; callers should spawn with SysProcAttr{Setpgid: true}. If no process group with that leader exists (ESRCH), it falls back to a single-process kill.

func LoadPtdYaml

func LoadPtdYaml(filename string) (interface{}, error)

func OIDCThumbprint

func OIDCThumbprint(issuerURL string) (string, error)

func PortOpen

func PortOpen(host string, port string) bool

func ProcessRunning

func ProcessRunning(pid int) bool

func ReadStruct

func ReadStruct(filePath string, data interface{}) error

ReadStruct reads a struct from a file in JSON format.

func RsKeyGenerate

func RsKeyGenerate() string

func Sha256Hash

func Sha256Hash(s string, limit int) string

func SortedKeys

func SortedKeys[K ~string, V any](m map[K]V) []K

SortedKeys returns the keys of a map in sorted order.

func TitleCase

func TitleCase(s string) string

func ValidateTargetsConfigPath

func ValidateTargetsConfigPath() error

ValidateTargetsConfigPath checks that the targets configuration directory exists and contains the expected directory structure (__ctrl__ and/or __work__ directories). Returns an error with helpful messaging if validation fails.

func WriteStruct

func WriteStruct(filePath string, data interface{}) error

WriteStruct writes a struct to a file in JSON format.

func YamlPathForTarget

func YamlPathForTarget(target types.Target) string

Types

type BaseConfig

type BaseConfig struct {
	ApiVersion string    `yaml:"apiVersion"`
	Kind       string    `yaml:"kind"`
	Spec       yaml.Node `yaml:"spec"`
}

Jump to

Keyboard shortcuts

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