Documentation
¶
Index ¶
- Constants
- func ComputeNextRotation(createdAt *time.Time, expiresAt *gitlab.ISOTime, renewBeforeDays *int) *metav1.Time
- func FetchFromEndpoint(ctx context.Context, params RequestParameters) (string, error)
- func GenerateCommonIntegrationObservation(integration *gitlab.Service) v1alpha1.CommonIntegrationObservation
- func GenerateRenewalExpiration(days int) *gitlab.ISOTime
- func GetTokenValueFromLocalSecret(ctx context.Context, client client.Client, m resource.Managed, ...) (*string, error)
- func GetTokenValueFromSecret(ctx context.Context, client client.Client, m resource.Managed, ...) (*string, error)
- func HasReachedRenewalTime(createdAt, expiresAt, now time.Time, renewBeforeDays *int) bool
- func NewClient(c Config) *gitlab.Client
- func ResolvePublicJobsSetting(publicBuilds, publicJobs *bool) (*bool, bool)
- func RotationTime(createdAt, expiresAt time.Time, renewBeforeDays *int) (time.Time, bool)
- func SameDay(a, b time.Time) bool
- func ShouldRotateToken(active bool, createdAt *time.Time, actualExpiresAt *gitlab.ISOTime, ...) bool
- func TestCreateLocalSecretKeySelector(name, key string) *xpv1.LocalSecretKeySelector
- func TestCreateLocalSecretReference(name string) *xpv1.LocalSecretReference
- func TestCreateSecretKeySelector(name, key string) *xpv1.SecretKeySelector
- func TestCreateSecretReference(name string) *xpv1.SecretReference
- func TimeToMetaTime(t *time.Time) *metav1.Time
- type AuthParameters
- type BasicAuth
- type Config
- func GetConfig(ctx context.Context, c client.Client, mg resource.Managed) (*Config, error)
- func UseLegacyProviderConfig(ctx context.Context, c client.Client, mg resource.LegacyManaged) (*Config, error)
- func UseProvicerConfig(ctx context.Context, c client.Client, mg resource.ModernManaged) (*Config, error)
- type RequestParameters
Constants ¶
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 ComputeNextRotation ¶ added in v0.18.1
func ComputeNextRotation(createdAt *time.Time, expiresAt *gitlab.ISOTime, renewBeforeDays *int) *metav1.Time
ComputeNextRotation returns the next rotation time for a renewal-managed token, or nil when it cannot be computed (e.g. explicit expiresAt mode or missing timestamps).
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 GenerateCommonIntegrationObservation ¶ added in v0.17.4
func GenerateCommonIntegrationObservation(integration *gitlab.Service) v1alpha1.CommonIntegrationObservation
GenerateCommonIntegrationObservation generates a CommonIntegrationObservation from a gitlab.Service
func GenerateRenewalExpiration ¶ added in v0.18.0
GenerateRenewalExpiration returns an ISOTime set to `days` days from now.
func GetTokenValueFromLocalSecret ¶
func GetTokenValueFromLocalSecret(ctx context.Context, client client.Client, m resource.Managed, l *xpv1.LocalSecretKeySelector) (*string, error)
GetTokenValueFromLocalSecret is a helper function that retrieves the value of a secret key specified by a LocalSecretKeySelector. It constructs a SecretKeySelector from the LocalSecretKeySelector and calls GetTokenValueFromSecret to fetch the value.
func GetTokenValueFromSecret ¶
func HasReachedRenewalTime ¶ added in v0.18.1
HasReachedRenewalTime returns true once the token is eligible for rotation. When renewBeforeDays is non-nil rotation is due once expiresAt minus that many days has been reached; otherwise the default 2/3-lifetime threshold applies.
func NewClient ¶
NewClient creates new Gitlab Client with provided Gitlab Configurations/Credentials.
func ResolvePublicJobsSetting ¶
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 RotationTime ¶ added in v0.18.1
RotationTime returns the time at which a renewal-managed token becomes eligible for rotation. When renewBeforeDays is non-nil the rotation time is expiresAt minus that many days; otherwise it is after 2/3 of the observed lifetime has elapsed.
func SameDay ¶ added in v0.18.0
SameDay returns true if two times fall on the same UTC calendar day.
func ShouldRotateToken ¶ added in v0.18.0
func ShouldRotateToken(active bool, createdAt *time.Time, actualExpiresAt *gitlab.ISOTime, desiredExpiresAt *time.Time, renewBeforeDays *int, now time.Time) bool
ShouldRotateToken returns true when a token must be rotated based on its active state, desired expiry drift, or a renewal-managed token lifetime. When renewBeforeDays is non-nil the provider rotates once fewer than that many days remain before expiry; otherwise the default 2/3-lifetime threshold applies.
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
AuthParameters holds authentication details for HTTP requests
type BasicAuth ¶
BasicAuth is the expected struct that can be passed in the Config.Token field to add support for BasicAuth AuthMethod
type Config ¶
Config provides gitlab configurations for the Gitlab client
func GetConfig ¶
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 ¶
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