Documentation
¶
Index ¶
- Constants
- func AddMRStateRecorder(mgr ctrl.Manager, o ControllerOptions, list resource.ManagedList) error
- func AvatarUpload(image []byte, avatarURL string) (*gitlab.UserAvatar, error)
- func ComputeNextRotation(createdAt *time.Time, expiresAt *gitlab.ISOTime, renewBeforeDays *int) *metav1.Time
- func DeployTokenRenewAt(renewalPeriodDays, renewBeforeDays *int, expiresAt *time.Time) *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 IsAvatarUpToDate(image []byte, avatarURL string) bool
- func IsSecretRenewalDue(renewalPeriodDays *int64, annotationKey string, annotations map[string]string) bool
- func NewClient(c Config) *gitlab.Client
- func NewReconciler(mgr ctrl.Manager, o ControllerOptions, name string, of resource.ManagedKind, ...) *managed.Reconciler
- func NextSecretRenewalTime(periodDays int64) time.Time
- 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 ShouldRenewDeployToken(renewalPeriodDays, renewBeforeDays *int, dt *gitlab.DeployToken, now time.Time) bool
- func ShouldRotateToken(active bool, createdAt *time.Time, actualExpiresAt *gitlab.ISOTime, ...) bool
- func TestCreateLocalSecretKeySelector(name, key string) *v2.LocalSecretKeySelector
- func TestCreateLocalSecretReference(name string) *v2.LocalSecretReference
- func TestCreateSecretKeySelector(name, key string) *v2.SecretKeySelector
- func TestCreateSecretReference(name string) *v2.SecretReference
- func TimeToMetaTime(t *time.Time) *metav1.Time
- func ValidateExternalName(externalName string, policies v2.ManagementPolicies) error
- 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 ControllerOptions
- type RequestParameters
Constants ¶
const ( ErrSecretNotFound = "Cannot find referenced secret" ErrSecretKeyNotFound = "Cannot find key in referenced secret" ErrSecretSelectorNil = "Secret selector is nil" ErrPathExternalNameNotObserveOnly = "a full path external-name requires the management policies [Observe] or [Observe, LateInitialize]" )
Variables ¶
This section is empty.
Functions ¶
func AddMRStateRecorder ¶ added in v0.22.0
func AddMRStateRecorder(mgr ctrl.Manager, o ControllerOptions, list resource.ManagedList) error
AddMRStateRecorder adds a runnable to mgr that records the exists, ready and synced metrics of the managed resources in list. It adds nothing when the options carry no MRStateMetrics.
func AvatarUpload ¶ added in v0.22.0
func AvatarUpload(image []byte, avatarURL string) (*gitlab.UserAvatar, error)
AvatarUpload returns the upload that makes avatarURL show image, or nil when avatarURL already shows it, matching the nil-means-unchanged contract of gitlab.ModifyUserOptions.Avatar.
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 DeployTokenRenewAt ¶ added in v0.22.0
DeployTokenRenewAt returns the time at which a renewal-managed deploy token is due for replacement, or nil when renewalPeriodDays is unset or the token never expires. GitLab does not report when a deploy token was created, so its lifetime is taken to be renewalPeriodDays, the lifetime the provider gives every renewal-managed token it creates.
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 *v2.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 IsAvatarUpToDate ¶ added in v0.22.0
IsAvatarUpToDate reports whether avatarURL shows image. An empty image means the avatar is not managed, which is always up to date.
func IsSecretRenewalDue ¶ added in v0.21.1
func IsSecretRenewalDue(renewalPeriodDays *int64, annotationKey string, annotations map[string]string) bool
IsSecretRenewalDue returns true when renewalPeriodDays is set and the renewal date stored in annotations[annotationKey] has been reached, is absent, or is malformed.
func NewClient ¶
NewClient creates new Gitlab Client with provided Gitlab Configurations/Credentials.
func NewReconciler ¶ added in v0.22.0
func NewReconciler(mgr ctrl.Manager, o ControllerOptions, name string, of resource.ManagedKind, opts ...managed.ReconcilerOption) *managed.Reconciler
NewReconciler returns a managed resource reconciler for the supplied kind that uses the provider-wide poll intervals, logger, event recorder, metric recorder and feature flags. The supplied options are applied after these.
func NextSecretRenewalTime ¶ added in v0.21.1
NextSecretRenewalTime returns the UTC time that is periodDays days from now.
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 ShouldRenewDeployToken ¶ added in v0.22.0
func ShouldRenewDeployToken(renewalPeriodDays, renewBeforeDays *int, dt *gitlab.DeployToken, now time.Time) bool
ShouldRenewDeployToken reports whether a renewal-managed deploy token must be replaced because it is revoked, expired, never expires, or has reached its renewal time.
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) *v2.LocalSecretKeySelector
CreateLocalSecretKeySelector creates a LocalSecretKeySelector for testing
func TestCreateLocalSecretReference ¶
func TestCreateLocalSecretReference(name string) *v2.LocalSecretReference
CreateLocalSecretKeySelector creates a LocalSecretKeySelector for testing
func TestCreateSecretKeySelector ¶
func TestCreateSecretKeySelector(name, key string) *v2.SecretKeySelector
CreateSecretKeySelector creates a SecretKeySelector for testing
func TestCreateSecretReference ¶
func TestCreateSecretReference(name string) *v2.SecretReference
CreateSecretKeySelector creates a SecretKeySelector for testing
func TimeToMetaTime ¶ added in v0.18.0
TimeToMetaTime returns nil if parameter is nil, otherwise metav1.Time value.
func ValidateExternalName ¶ added in v0.22.0
func ValidateExternalName(externalName string, policies v2.ManagementPolicies) error
ValidateExternalName allows a full path external-name only with observe-only management policies, since a write through a moved path hits the wrong resource.
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 ¶
type Config struct {
Token string
BaseURL string
InsecureSkipVerify bool
AuthMethod auth.AuthType
// CredentialsSecretRef is the secret key selector the ProviderConfig used to
// source the token (only set when the credentials source is a Secret). It is
// used to detect self-referential setups, where a managed resource writes its
// token to the very secret its ProviderConfig authenticates with.
CredentialsSecretRef *v2.SecretKeySelector
}
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 ControllerOptions ¶ added in v0.22.0
type ControllerOptions struct {
controller.Options
// MinPollInterval is the shortest poll interval a managed resource may
// request with the crossplane.io/poll-interval annotation. Shorter
// requests are raised to this value.
MinPollInterval time.Duration
}
ControllerOptions configure every controller this provider sets up.
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