common

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrSecretNotFound    = "Cannot find referenced secret"
	ErrSecretKeyNotFound = "Cannot find key in referenced secret"
	ErrSecretSelectorNil = "Secret selector is nil"
)

Variables

This section is empty.

Functions

func FetchFromEndpoint added in v0.17.0

func FetchFromEndpoint(ctx context.Context, params RequestParameters) (string, error)

FetchFromEndpoint fetches content from the provided endpoint URL using the provided authentication details. It supports: - Unauthenticated requests (Auth nil or all auth params nil) - Basic authentication (username + password) - Bearer token authentication (token) Token authentication takes precedence over basic auth if both are provided.

func GetTokenValueFromLocalSecret

func GetTokenValueFromLocalSecret(ctx context.Context, client client.Client, m resource.Managed, l *xpv1.LocalSecretKeySelector) (*string, error)

func GetTokenValueFromSecret

func GetTokenValueFromSecret(ctx context.Context, client client.Client, m resource.Managed, selector *xpv1.SecretKeySelector) (*string, error)

func NewClient

func NewClient(c Config) *gitlab.Client

NewClient creates new Gitlab Client with provided Gitlab Configurations/Credentials.

func ResolvePublicJobsSetting

func ResolvePublicJobsSetting(publicBuilds, publicJobs *bool) (*bool, bool)

ResolvePublicJobsSetting determines the effective publicJobs value prioritizing publicJobs over the deprecated publicBuilds field. Returns the resolved value and whether the deprecated publicBuilds field was used.

func TestCreateLocalSecretKeySelector

func TestCreateLocalSecretKeySelector(name, key string) *xpv1.LocalSecretKeySelector

CreateLocalSecretKeySelector creates a LocalSecretKeySelector for testing

func TestCreateLocalSecretReference

func TestCreateLocalSecretReference(name string) *xpv1.LocalSecretReference

CreateLocalSecretKeySelector creates a LocalSecretKeySelector for testing

func TestCreateSecretKeySelector

func TestCreateSecretKeySelector(name, key string) *xpv1.SecretKeySelector

CreateSecretKeySelector creates a SecretKeySelector for testing

func TestCreateSecretReference

func TestCreateSecretReference(name string) *xpv1.SecretReference

CreateSecretKeySelector creates a SecretKeySelector for testing

Types

type AuthParameters added in v0.17.0

type AuthParameters struct {
	Username *string
	Password *string
	Token    *string
}

AuthParameters holds authentication details for HTTP requests

type BasicAuth

type BasicAuth struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

BasicAuth is the expected struct that can be passed in the Config.Token field to add support for BasicAuth AuthMethod

type Config

type Config struct {
	Token              string
	BaseURL            string
	InsecureSkipVerify bool
	AuthMethod         auth.AuthType
}

Config provides gitlab configurations for the Gitlab client

func GetConfig

func GetConfig(ctx context.Context, c client.Client, mg resource.Managed) (*Config, error)

GetConfig constructs a Config that can be used to authenticate to Gitlab API by the Gitlab Go client

func UseLegacyProviderConfig

func UseLegacyProviderConfig(ctx context.Context, c client.Client, mg resource.LegacyManaged) (*Config, error)

UseProviderConfig to produce a config that can be used to authenticate to Gitlab.

func UseProvicerConfig

func UseProvicerConfig(ctx context.Context, c client.Client, mg resource.ModernManaged) (*Config, error)

type RequestParameters added in v0.17.0

type RequestParameters struct {
	Auth        *AuthParameters
	EndpointURL string
	Timeout     *time.Duration
	MaxSize     *int64
	Retries     *int
}

RequestParameters holds parameters for making HTTP requests

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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