Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLoginByEnvVar ¶
GetLoginByEnvVar returns a login based on environment variables, or nil if no login can be created
func MatchLogins ¶
MatchLogins matches the given remoteURL against the provided logins and returns the first matching login remoteURL could be like:
https://github.com/owner/repo.git http://github.com/owner/repo.git ssh://github.com/owner/repo.git git@github.com:owner/repo.git
Types ¶
type CtxRequirement ¶
type CtxRequirement struct {
// ensures a local git repo is available & ctx.LocalRepo is set. Implies .RemoteRepo
LocalRepo bool
// ensures ctx.RepoSlug, .Owner, .Repo are set
RemoteRepo bool
}
CtxRequirement specifies context needed for operation
type KmupContext ¶
type KmupContext struct {
*cobra.Command
Login *auth.Login // config data & client for selected login
RepoSlug string // <owner>/<repo>, optional
Owner string // repo owner as derived from context or provided in flag, optional
Repo string // repo name as derived from context or provided in flag, optional
Output string // value of output flag
LocalRepo *git.KmdoRepo // is set if flags specified a local repo via --repo, or if $PWD is a git repo
}
KmupContext contains all context derived during command initialization and wraps cli.Context
func InitCommand ¶
func InitCommand(cmd *cobra.Command) *KmupContext
InitCommand resolves the application context, and returns the active login, and if available the repo slug. It does this by reading the config file for logins, parsing the remotes of the .git repo specified in repoFlag or $PWD, and using overrides from command flags. If a local git repo can't be found, repo slug values are unset.
func (*KmupContext) Ensure ¶
func (ctx *KmupContext) Ensure(req CtxRequirement)
Ensure checks if requirements on the context are set, and terminates otherwise.
func (*KmupContext) GetRemoteRepoHTMLURL ¶
func (ctx *KmupContext) GetRemoteRepoHTMLURL() string
GetRemoteRepoHTMLURL returns the web-ui url of the remote repo, after ensuring a remote repo is present in the context.