util

package
v0.0.0-...-37b8e2e Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JSON is used as a constant of word "json" for out flag
	JSON = "json"
	// YAML is used as a constant of word "yaml" for out flag
	YAML = "yaml"
)
View Source
const (
	// DefaultErrorExitCode defines the default exit code.
	DefaultErrorExitCode = 1
)

Variables

View Source
var ErrExit = fmt.Errorf("exit")

ErrExit may be passed to CheckError to instruct it to output nothing but exit with status code 1.

Functions

func AddDescriptionFlag

func AddDescriptionFlag(cmd *cobra.Command)

func AddDescriptionVarFlag

func AddDescriptionVarFlag(cmd *cobra.Command, p *string)

func AddFromGroupVarPFlag

func AddFromGroupVarPFlag(cmd *cobra.Command, p *string)

func AddFromProjectVarFlag

func AddFromProjectVarFlag(cmd *cobra.Command, p *string)

func AddLFSenabledFlag

func AddLFSenabledFlag(cmd *cobra.Command, value bool)

func AddLFSenabledVarPFlag

func AddLFSenabledVarPFlag(cmd *cobra.Command, p *bool)

func AddOutFlag

func AddOutFlag(cmd *cobra.Command, p *string)

func AddOwnedVarFlag

func AddOwnedVarFlag(cmd *cobra.Command, p *bool)

func AddPaginationVarFlags

func AddPaginationVarFlags(cmd *cobra.Command, page *gitlab.ListOptions)

func AddProjectOrderByVarFlag

func AddProjectOrderByVarFlag(cmd *cobra.Command, p *string)

func AddProjectVarPFlag

func AddProjectVarPFlag(cmd *cobra.Command, p *string)

func AddRequestAccessEnabledFlag

func AddRequestAccessEnabledFlag(cmd *cobra.Command, value bool)

func AddRequestAccessEnabledVarFlag

func AddRequestAccessEnabledVarFlag(cmd *cobra.Command, p *bool)

func AddSearchVarFlag

func AddSearchVarFlag(cmd *cobra.Command, p *string)

func AddSortVarFlag

func AddSortVarFlag(cmd *cobra.Command, p *string)

func AddStatisticsVarFlag

func AddStatisticsVarFlag(cmd *cobra.Command, p *bool)

func AddVisibilityFlag

func AddVisibilityFlag(cmd *cobra.Command)

func AddVisibilityVarFlag

func AddVisibilityVarFlag(cmd *cobra.Command, p *string)

func CheckErr

func CheckErr(err error)

CheckErr prints a user-friendly error to STDERR and exits with a non-zero exit code. Unrecognized errors will be printed with an "error: " prefix.

This method is generic to the command in use and may be used by non-IAM commands.

func DefaultSubCommandRun

func DefaultSubCommandRun(out io.Writer) func(c *cobra.Command, args []string)

DefaultSubCommandRun prints a command's help string to the specified output if no arguments (sub-commands) are provided, or a usage error otherwise.

func Error

func Error(w io.Writer, msg interface{})

func GetFlagBool

func GetFlagBool(cmd *cobra.Command, flag string) bool

func GetFlagInt

func GetFlagInt(cmd *cobra.Command, flag string) int

func GetFlagString

func GetFlagString(cmd *cobra.Command, flag string) string

func GetFlagStringSlice

func GetFlagStringSlice(cmd *cobra.Command, flag string) []string

func GetFlagVisibility

func GetFlagVisibility(cmd *cobra.Command) *gitlab.VisibilityValue

GetFlagVisibility converts the string flag visiblity to gitlab.VisibilityValue.

func Load

func Load(data []byte) (*types.Config, error)

Load takes a byte slice and deserializes the contents into Config object. Encapsulates deserialization without assuming the source is a file.

func LoadOathWithEnvConfig

func LoadOathWithEnvConfig() (*types.GitLabOathFormEnv, error)

func LoadOathWithInfoConfig

func LoadOathWithInfoConfig() (*types.GitLabOauthInfo, error)

func NewForConfig

func NewForConfig(config *types.Config) (*gitlab.Client, error)

func PrintBranchOut

func PrintBranchOut(format string, w io.Writer, branches ...*gitlab.Branch)

func PrintFilesOut

func PrintFilesOut(format string, w io.Writer, trees ...*gitlab.TreeNode)

func PrintGroupsOut

func PrintGroupsOut(format string, w io.Writer, groups ...*gitlab.Group)

func PrintProjectsOut

func PrintProjectsOut(format string, w io.Writer, projects ...*gitlab.Project)

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile read file contents

func RequireNoArguments

func RequireNoArguments(c *cobra.Command, args []string)

RequireNoArguments exits with a usage error if extra arguments are provided.

func StandardErrorMessage

func StandardErrorMessage(err error) (string, bool)

StandardErrorMessage translates common errors into a human readable message, or returns false if the error is not one of the recognized types. It may also log extended information to klog.

This method is generic to the command in use and may be used by non-IAM commands.

func UsageErrorf

func UsageErrorf(cmd *cobra.Command, format string, args ...interface{}) error

UsageErrorf returns error with command path.

func VerifyMarkFlagRequired

func VerifyMarkFlagRequired(cmd *cobra.Command, fName string)

func WarnWordSepNormalizeFunc

func WarnWordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName

WarnWordSepNormalizeFunc changes and warns for flags that contain "_" separators.

func WordSepNormalizeFunc

func WordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName

WordSepNormalizeFunc changes all flags that contain "_" separators.

Types

type ClientConfig

type ClientConfig interface {
	// ClientConfig returns a complete client config
	ClientConfig() (*types.Config, error)
}

ClientConfig is used to make it easy to get an api server client.

func NewClientConfigFromBytes

func NewClientConfigFromBytes(configBytes []byte) (ClientConfig, error)

NewClientConfigFromBytes takes your glctl config and gives you back a ClientConfig.

func NewClientConfigFromConfig

func NewClientConfigFromConfig(oathInfo *types.GitLabOauthInfo, oathEnv *types.GitLabOathFormEnv) ClientConfig

NewClientConfigFromConfig takes your Config and gives you back a ClientConfig.

type ConfigFlags

type ConfigFlags struct {
	Env  *types.GitLabOathFormEnv
	Oath *types.GitLabOauthInfo
	// contains filtered or unexported fields
}

func NewConfigFlags

func NewConfigFlags(usePersistentConfig bool) *ConfigFlags

NewConfigFlags returns ConfigFlags with default values set.

func (*ConfigFlags) AddFlags

func (f *ConfigFlags) AddFlags(flags *pflag.FlagSet)

AddConfig binds client configuration flags to a given flagset.

func (*ConfigFlags) ToRESTConfig

func (f *ConfigFlags) ToRESTConfig() (*types.Config, error)

func (*ConfigFlags) ToRawGLConfigLoader

func (f *ConfigFlags) ToRawGLConfigLoader() ClientConfig

ToRawGLConfigLoader binds config flag values to config overrides Returns an interactive clientConfig if the password flag is enabled, or a non-interactive clientConfig otherwise.

type DirectClientConfig

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

DirectClientConfig wrap for Config.

func (*DirectClientConfig) ClientConfig

func (config *DirectClientConfig) ClientConfig() (*types.Config, error)

type Factory

type Factory interface {

	// GitlabClient gives you back an external gitlabClient
	GitlabClient() (*gitlab.Client, error)
}

func NewFactory

func NewFactory(clientGetter RESTClientGetter) Factory

type GitLabAuthorization

type GitLabAuthorization struct {
	*types.Config
}

func (*GitLabAuthorization) HasAuth

func (g *GitLabAuthorization) HasAuth() bool

func (*GitLabAuthorization) HasBasicAuth

func (g *GitLabAuthorization) HasBasicAuth() bool

func (*GitLabAuthorization) HasOathAuth

func (g *GitLabAuthorization) HasOathAuth() bool

func (*GitLabAuthorization) HasPasswordAuth

func (g *GitLabAuthorization) HasPasswordAuth() bool

type RESTClientGetter

type RESTClientGetter interface {
	// ToRESTConfig returns restconfig
	ToRESTConfig() (*types.Config, error)

	// ToRawGlConfigLoader return GLconfig loader as-is
	ToRawGLConfigLoader() ClientConfig
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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