config

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvBuildURL            = "BUILD_URL"
	EnvBuildPropertiesFile = "TEAMCITY_BUILD_PROPERTIES_FILE"
)
View Source
const (
	EnvServerURL = "TEAMCITY_URL"
	EnvToken     = "TEAMCITY_TOKEN"
	EnvGuestAuth = "TEAMCITY_GUEST"
	EnvReadOnly  = "TEAMCITY_RO"
	EnvDSLDir    = "TEAMCITY_DSL_DIR"

	DefaultDSLDirTeamCity = ".teamcity"
	DefaultDSLDirTC       = ".tc"
)

Variables

This section is empty.

Functions

func AddAlias added in v0.6.0

func AddAlias(name, expansion string) error

func ConfigPath

func ConfigPath() string

func DeleteAlias added in v0.6.0

func DeleteAlias(name string) error

func DetectServerFromDSL added in v0.4.0

func DetectServerFromDSL() string

func DetectTeamCityDir added in v0.4.0

func DetectTeamCityDir() string

func GetAlias added in v0.6.0

func GetAlias(name string) (string, bool)

func GetAllAliases added in v0.6.0

func GetAllAliases() map[string]string

func GetCurrentUser

func GetCurrentUser() string

GetCurrentUser returns the current user from config

func GetServerURL

func GetServerURL() string

func GetToken

func GetToken() string

func GetTokenExpiry added in v0.8.0

func GetTokenExpiry() string

func GetTokenForServer added in v0.7.2

func GetTokenForServer(serverURL string) (token, source string, keyringErr error)

GetTokenForServer retrieves the token for a specific server URL. Unlike GetTokenWithSource, it does not use GetServerURL() — the caller provides the server URL directly. Returns the token and its source ("keyring" or "config"), or empty strings if none found.

func GetTokenWithSource added in v0.6.0

func GetTokenWithSource() (token, source string, keyringErr error)

func Init

func Init() error

func IsBuildEnvironment added in v0.3.0

func IsBuildEnvironment() bool

func IsConfigured

func IsConfigured() bool

IsConfigured returns true if server URL and token are set, or guest auth is active

func IsGuestAuth added in v0.7.0

func IsGuestAuth() bool

IsGuestAuth returns true if guest authentication is enabled via env var or server config

func IsReadOnly added in v0.7.0

func IsReadOnly() bool

IsReadOnly returns true if read-only mode is enabled via env var or server config. When enabled, all non-GET API requests are blocked.

func IsShellAlias added in v0.6.0

func IsShellAlias(name string) bool

func NormalizeURL added in v0.7.0

func NormalizeURL(u string) string

NormalizeURL trims trailing slashes and ensures an http(s) scheme prefix.

func ParseExpansion added in v0.6.0

func ParseExpansion(expansion string) (string, bool)

ParseExpansion strips the "!" shell prefix from an alias expansion. Returns the clean expansion string and whether it is a shell alias.

func RemoveServer

func RemoveServer(serverURL string) error

func ResetDSLCache added in v0.4.0

func ResetDSLCache()

ResetDSLCache resets the cached DSL detection results. Used by tests.

func ResetForTest added in v0.6.0

func ResetForTest()

func SetConfigPathForTest added in v0.6.0

func SetConfigPathForTest(path string)

func SetGuestServer added in v0.7.0

func SetGuestServer(serverURL string) error

SetGuestServer saves a server with guest auth enabled and no token

func SetServer

func SetServer(serverURL, token, user string) error

func SetServerWithKeyring added in v0.6.0

func SetServerWithKeyring(serverURL, token, user, tokenExpiry string, insecureStorage bool) (insecureFallback bool, err error)

func SetUserForServer

func SetUserForServer(serverURL, user string)

SetUserForServer sets the user for a server URL in memory (does not persist to disk). This is useful for tests that need to set the user without modifying the config file.

Types

type BuildAuth added in v0.3.0

type BuildAuth struct {
	ServerURL string
	Username  string
	Password  string
}

func GetBuildAuth added in v0.3.0

func GetBuildAuth() (*BuildAuth, bool)

GetBuildAuth returns build-level credentials if running inside a TeamCity build. Server URL priority: TEAMCITY_URL > BUILD_URL > teamcity.serverUrl property

type Config

type Config struct {
	DefaultServer string                  `mapstructure:"default_server"`
	Servers       map[string]ServerConfig `mapstructure:"servers"`
	Aliases       map[string]string       `mapstructure:"aliases"`
}

func Get

func Get() *Config

Get returns the current config

type ServerConfig

type ServerConfig struct {
	Token       string `mapstructure:"token"`
	User        string `mapstructure:"user"`
	Guest       bool   `mapstructure:"guest,omitempty"`
	RO          bool   `mapstructure:"ro,omitempty"`
	TokenExpiry string `mapstructure:"token_expiry,omitempty"`
}

Jump to

Keyboard shortcuts

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