utils

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfiguredPlatforms = make(map[string]Platform)

Functions

func BuildPlatforms added in v0.5.2

func BuildPlatforms()

func CleanForLog added in v0.5.6

func CleanForLog(str string) string

func ColorString added in v0.5.6

func ColorString(str string) string

func ExecCmd added in v0.6.0

func ExecCmd(cmd string, gf entity.GitFolder) entity.CmdInfo

func GetPlatformType added in v0.5.2

func GetPlatformType(host string) string

func GetPublicKey added in v0.5.4

func GetPublicKey(host string, spinner *tea.Program) string

func GetPublicKeyPassword added in v0.5.4

func GetPublicKeyPassword(host string, spinner *tea.Program) string

func GetRootDir added in v0.6.0

func GetRootDir() string

func GetToken added in v0.5.2

func GetToken(host string, spinner *tea.Program) string

func HasInputConfig added in v0.5.2

func HasInputConfig() bool

func IsComplete added in v0.8.0

func IsComplete(host string) bool

IsComplete tells whether a platform has both the type and the token Heimdall needs to use it. A platform missing one of them is still listed, so that it can be fixed, but it cannot be used.

func ListGitDirectories added in v0.6.0

func ListGitDirectories(searchDepth int) []entity.GitFolder

func LiteralToken added in v0.8.0

func LiteralToken(host string) (string, bool)

LiteralToken returns the token of a platform when it is written in the configuration file itself, which is what the migration into the keyring needs to read. It is deliberately the only way to get a secret out of the configuration without resolving it, and deliberately easy to grep for.

func OverrideLogFile

func OverrideLogFile()

func PrintBanner

func PrintBanner()

func PrintBannerWithColor added in v0.5.6

func PrintBannerWithColor()

func PrintBannerWithoutColor added in v0.5.6

func PrintBannerWithoutColor()

func PrintMorningTable added in v0.6.0

func PrintMorningTable(gitFolders []entity.GitFolderWithCmdInfos)

func PrintSeparation

func PrintSeparation()

func PrintSimpleTable added in v0.6.0

func PrintSimpleTable(gitFolders []entity.GitFolder)

func PrintTable

func PrintTable(gitFolders []entity.GitFolder)

func ReloadConfig added in v0.8.0

func ReloadConfig() error

ReloadConfig reads the configuration file again and builds the platforms from it, so that a credential updated while Heimdall is running is taken into account without restarting it. It writes nothing on stdout, which the TUI forbids.

func SetWorkDir added in v0.6.0

func SetWorkDir()

func TokenQuietly added in v0.8.0

func TokenQuietly(host string) (string, bool)

TokenQuietly resolves the token of a platform without reporting anything. It is what the credential check uses, because it reports the outcome of every platform itself.

func Trace

func Trace(msg string, isDebug bool)

func TraceWarn

func TraceWarn(msg string)

func UseConfig added in v0.5.2

func UseConfig()

func VisualDisplayRepo added in v0.6.0

func VisualDisplayRepo(repo string) string

Types

type LineWriter added in v0.8.0

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

LineWriter turns a byte stream into whole lines handed to emit.

It splits on \r as well as on \n, because the progress of git is a sideband which redraws itself in place : "Counting objects: 43%\rCounting objects: 57%\r…". Feeding that raw to a line based output would wreck it.

It is not safe for concurrent use : one clone at a time writes to it.

func NewLineWriter added in v0.8.0

func NewLineWriter(emit func(string)) *LineWriter

NewLineWriter returns a writer handing each line it reads to emit

func (*LineWriter) Close added in v0.8.0

func (w *LineWriter) Close() error

Close hands over what was written without a line ending, as the last line of a clone often is

func (*LineWriter) Write added in v0.8.0

func (w *LineWriter) Write(p []byte) (int, error)

Write always reports every byte written : a writer refusing bytes would abort the clone, and a line of progress is not worth that.

type MorningRoutine added in v0.6.0

type MorningRoutine struct {
	Cmds  []string
	Shell string
	// contains filtered or unexported fields
}
var MorningRoutineConfig MorningRoutine

func BuildMorningRoutine added in v0.6.0

func BuildMorningRoutine() MorningRoutine

func GetMorningRoutine added in v0.6.0

func GetMorningRoutine() MorningRoutine

type Platform added in v0.5.2

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

type PlatformInfo added in v0.8.0

type PlatformInfo struct {
	Host string
	Type string
	// TokenRef is the name of the keyring entry or of the environment variable the token is read
	// from. It is empty when the token is written in the configuration file, because that value is
	// the token itself : use TokenLocation to display where the token comes from.
	TokenRef         string
	TokenSource      Source
	PublicKey        string
	PassphraseRef    string
	PassphraseSource Source
}

PlatformInfo describes how a platform is configured. It never holds a secret : when the value is written in the configuration file, the reference is left empty and only the source says there is one, so that a PlatformInfo can be displayed and logged freely.

func Platforms added in v0.8.0

func Platforms() []PlatformInfo

Platforms lists the configured platforms, sorted by host, without exposing any secret

func (PlatformInfo) Complete added in v0.8.0

func (p PlatformInfo) Complete() bool

Complete tells whether the platform has the type and the token Heimdall needs to use it

func (PlatformInfo) PassphraseLocation added in v0.8.0

func (p PlatformInfo) PassphraseLocation() string

PassphraseLocation names where the passphrase of the ssh key is read from, safe to display

func (PlatformInfo) TokenLocation added in v0.8.0

func (p PlatformInfo) TokenLocation() string

TokenLocation names where the token is read from, in a form which is always safe to display

type Source added in v0.8.0

type Source int

Source tells where the value of a credential is read from

const (
	// SourceNone : the credential is not configured at all
	SourceNone Source = iota
	// SourceLiteral : the value is written in the configuration file
	SourceLiteral
	// SourceEnv : the configuration file references an environment variable
	SourceEnv
	// SourceKeyring : the configuration file references an entry of the keyring
	SourceKeyring
)

func SourceOf added in v0.8.0

func SourceOf(rawValue string) Source

SourceOf tells where a raw value of the configuration file reads its secret from

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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