Documentation
¶
Overview ¶
Package utils implements the util functions
Index ¶
- Constants
- func CalculateSecretKeyMd5(secret *corev1.Secret, key string) (string, error)
- func ConvertJSONToMapStringInterface(raw *apiextensionsv1.JSON) (map[string]interface{}, error)
- func ConvertMap(input map[string]string) map[string]interface{}
- func CreateOrUpdatePrivateKeySecret(ctx context.Context, c client.Client, owner metav1.Object, ...) error
- func CreateOrUpdateServiceAccountCredentialsSecret(ctx context.Context, c client.Client, owner metav1.Object, ...) error
- func CreateOrUpdateTokenSecret(ctx context.Context, c client.Client, owner metav1.Object, ...) error
- func GetPrivateKeyFromSecret(ctx context.Context, c client.Client, namespace, name string) (string, error)
- func IsManaged(object metav1.Object) bool
- type ClientCredentials
- type Duration
- type Event
- type EventSource
- type ReconcileRetryer
Constants ¶
const ( // PrivateKeySecretSuffix is the suffix for private key secrets PrivateKeySecretSuffix = "-private-key" // TokenSecretSuffix is the suffix for token secrets TokenSecretSuffix = "-token" // PrivateKeyField is the key for the private key in the secret PrivateKeyField = "private-key" // TokenField is the key for the token in the secret TokenField = "token" // ServiceAccountCredentialsSecretSuffix is the suffix for service account credentials secrets ServiceAccountCredentialsSecretSuffix = "-credentials" // ServiceAccountCredentialsField is the key for the service account credentials in the secret ServiceAccountCredentialsField = "credentials.json" // ServiceAccountCredentialsType is the type for service account credentials //nolint:gosec ServiceAccountCredentialsType = "TYPE_SN_CREDENTIALS_FILE" )
const (
// ManagedAnnotation indicates the object is managed by the controller
ManagedAnnotation = "cloud.streamnative.io/managed"
)
Variables ¶
This section is empty.
Functions ¶
func CalculateSecretKeyMd5 ¶ added in v0.4.5
CalculateSecretKeyMd5 calculates the hash of the secret key.
func ConvertJSONToMapStringInterface ¶ added in v0.5.0
func ConvertJSONToMapStringInterface(raw *apiextensionsv1.JSON) (map[string]interface{}, error)
ConvertJSONToMapStringInterface converts a JSON object to a map[string]interface{}
func ConvertMap ¶ added in v0.5.0
ConvertMap converts a map[string]string to a map[string]interface{}
func CreateOrUpdatePrivateKeySecret ¶ added in v0.10.0
func CreateOrUpdatePrivateKeySecret(ctx context.Context, c client.Client, owner metav1.Object, namespace, name, privateKey string) error
CreateOrUpdatePrivateKeySecret creates or updates a secret containing a private key
func CreateOrUpdateServiceAccountCredentialsSecret ¶ added in v0.10.0
func CreateOrUpdateServiceAccountCredentialsSecret(ctx context.Context, c client.Client, owner metav1.Object, namespace, name, credentials string) error
CreateOrUpdateServiceAccountCredentialsSecret creates or updates a secret containing service account credentials
func CreateOrUpdateTokenSecret ¶ added in v0.10.0
func CreateOrUpdateTokenSecret(ctx context.Context, c client.Client, owner metav1.Object, namespace, name, token, keyID string) error
CreateOrUpdateTokenSecret creates or updates a secret containing a token
Types ¶
type ClientCredentials ¶ added in v0.5.5
type ClientCredentials struct { IssuerURL string `json:"issuerUrl,omitempty"` Audience string `json:"audience,omitempty"` Scope string `json:"scope,omitempty"` PrivateKey string `json:"privateKey,omitempty"` ClientID string `json:"clientId,omitempty"` }
ClientCredentials represents the client credentials for OAuth2
type EventSource ¶ added in v0.5.5
type EventSource struct { Log logr.Logger Events chan event.GenericEvent // contains filtered or unexported fields }
EventSource is a custom event source that can be used to trigger reconcile
func NewEventSource ¶ added in v0.5.5
func NewEventSource(log logr.Logger) *EventSource
NewEventSource creates a new EventSource
func (*EventSource) Close ¶ added in v0.5.5
func (s *EventSource) Close()
Close closes the EventSource
func (*EventSource) Contains ¶ added in v0.5.5
func (s *EventSource) Contains(key string) bool
Contains checks if the key exists in the event source
func (*EventSource) CreateIfAbsent ¶ added in v0.5.5
CreateIfAbsent triggers reconcile after delay, idempotent operation for the same key
func (*EventSource) Remove ¶ added in v0.5.5
func (s *EventSource) Remove(key string)
Remove removes the reconcile event
type ReconcileRetryer ¶ added in v0.5.5
type ReconcileRetryer struct {
// contains filtered or unexported fields
}
ReconcileRetryer is a helper to trigger reconcile with retry
func NewReconcileRetryer ¶ added in v0.5.5
func NewReconcileRetryer(maxRetries int, source *EventSource) *ReconcileRetryer
NewReconcileRetryer creates a new ReconcileRetryer
func (*ReconcileRetryer) Close ¶ added in v0.5.5
func (r *ReconcileRetryer) Close()
Close closes the ReconcileRetryer
func (*ReconcileRetryer) Contains ¶ added in v0.5.5
func (r *ReconcileRetryer) Contains(obj client.Object) bool
func (*ReconcileRetryer) CreateIfAbsent ¶ added in v0.5.5
func (r *ReconcileRetryer) CreateIfAbsent(obj client.Object)
CreateIfAbsent creates a new task if not exist
func (*ReconcileRetryer) Remove ¶ added in v0.5.5
func (r *ReconcileRetryer) Remove(obj client.Object)
Remove removes the task
func (*ReconcileRetryer) Source ¶ added in v0.5.5
func (r *ReconcileRetryer) Source() <-chan event.GenericEvent
Source returns the event source