glclient

package
v1.31.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidScheme is returned when GitLab URL doesn't use HTTPS.
	ErrInvalidScheme = errors.New("GITLAB_URL must use https scheme")
	// ErrConfig is returned when configuration is invalid.
	ErrConfig = errors.New("invalid OAuth configuration")
	// ErrFlagNotFound is returned when a flag is not found.
	ErrFlagNotFound = errors.New("flag not found")
)

Functions

func DefaultBaseURL added in v1.22.2

func DefaultBaseURL() string

DefaultBaseURL returns the default GitLab URL or the URL specified by the GITLAB_URL environment variable.

func New

func New(cfg *Config) (*gitlab.Client, error)

New creates a GitLab client with proper validation and security checks.

Types

type BaseURLFlag added in v1.22.2

type BaseURLFlag url.URL

BaseURLFlag wraps a string to implement the `pflag.Value` interface. This type provides an implementation to customize the behavior of `--base-url` in the `cobra.Command` command-line interface.

func (*BaseURLFlag) Set added in v1.22.2

func (f *BaseURLFlag) Set(s string) error

Set sets the value of the flag. The value is sanitized by removing any trailing slashes and the `/api/v4` path from the end of the string. If the string is empty, it is set to the default base URL.

func (*BaseURLFlag) String added in v1.22.2

func (f *BaseURLFlag) String() string

func (*BaseURLFlag) Type added in v1.22.2

func (*BaseURLFlag) Type() string

type Config

type Config struct {
	AuthSource gitlab.AuthSource
	BaseURL    string // Optional
	ClientID   string

	AuthOAuth bool
	AuthPAT   bool
}

func ConfigFromFlags added in v1.23.0

func ConfigFromFlags(ctx context.Context, fs *pflag.FlagSet) (*Config, error)

ConfigFromFlags creates a new configuration by based on the provided flag set. GitLab tokens are determined from the environment or file system.

func ConfigFromRequest added in v1.23.0

func ConfigFromRequest(r *http.Request, serverConfig ServerConfig) (*Config, error)

ConfigFromRequest reads configuration from an HTTP request. It looks for the 'Private-Token' headers to set the access token.

type ServerConfig added in v1.23.0

type ServerConfig struct {
	BaseURL string

	AuthOAuth bool
	AuthPAT   bool
}

ServerConfig represents the server-side configuration.

Jump to

Keyboard shortcuts

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