utils

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFinalizer added in v0.5.0

func AddFinalizer(kubeClient client.Client, resource Bridge) func(context.Context, ctrl.Request) (*ctrl.Result, error)

AddFinalizer returns a function of type subreconciler.FnWithRequest

func BoolAddr

func BoolAddr(b bool) *bool

Helper function for struct construction requiring a boolean pointer

func BoolToString

func BoolToString(b bool) string

func BoolToYesNo

func BoolToYesNo(report_stats bool) string

func CheckResourcePresenceFunc

func CheckResourcePresenceFunc(
	k8sClient client.Client,
	ctx context.Context,
	timeout time.Duration,
	interval time.Duration,
) func(client.Object, types.NamespacedName, metav1.OwnerReference)

func CheckStatusFunc

func CheckStatusFunc(
	k8sClient client.Client,
	ctx context.Context,
	timeout time.Duration,
	interval time.Duration,
) func(string, string, types.NamespacedName, client.Object)

func CheckSubresourceAbsenceFunc

func CheckSubresourceAbsenceFunc(
	k8sClient client.Client,
	ctx context.Context,
	timeout time.Duration,
	interval time.Duration,
) func(types.NamespacedName, ...client.Object)

func ComputeFQDN

func ComputeFQDN(name string, namespace string) string

func ComputeNamespace

func ComputeNamespace(defaultNamespace string, newNamespace string) string

ConfigMap that are created by the user could be living in a different namespace as Synapse. getConfigMapNamespace provides a way to default to the Synapse namespace if none is provided.

func Convert

func Convert(i interface{}) interface{}

func ConvertStructToMap

func ConvertStructToMap(in interface{}) (map[string]interface{}, error)

func CopyInputConfigMap added in v0.5.0

func CopyInputConfigMap(kubeClient client.Client, runtimeScheme *runtime.Scheme, resource client.Object) func(context.Context, ctrl.Request) (*ctrl.Result, error)

CopyInputConfigMap returns a function of type FnWithRequest, to be called in the main reconciliation loop.

It creates a copy of the user-provided ConfigMap.

func DeleteResourceFunc

func DeleteResourceFunc(
	k8sClient client.Client,
	ctx context.Context,
	timeout time.Duration,
	interval time.Duration,
) func(client.Object, types.NamespacedName, bool)

func FetchSynapseInstance added in v0.5.0

func FetchSynapseInstance(
	ctx context.Context,
	kubeClient client.Client,
	resource Bridge,
	s *synapsev1alpha1.Synapse,
) error

func GetConfigMapCopy

func GetConfigMapCopy(
	client client.Client,
	sourceConfigMapName string,
	sourceConfigMapNamespace string,
	copyConfigMapObjectMeta metav1.ObjectMeta,
) (*corev1.ConfigMap, error)

getConfigMapCopy is a generic function which creates a copy of a given source ConfigMap. The resulting copy is a ConfigMap with similar data, and with metadata set by the 'copyConfigMapObjectMeta' argument.

func GetResource added in v0.5.0

func GetResource(
	ctx context.Context,
	kubeClient client.Client,
	req ctrl.Request,
	resource client.Object,
) (*ctrl.Result, error)

func GetSynapseServerName

func GetSynapseServerName(s synapsev1alpha1.Synapse) (string, error)

func HandleDelete added in v0.5.0

func HandleDelete(kubeClient client.Client, resource Bridge) func(context.Context, ctrl.Request) (*ctrl.Result, error)

HandleDelete returns a function of type subreconciler.FnWithRequest

Bridges need to trigger the reconciliation of their associated Synapse homeserver so that Synapse can remove the bridge from the list of application services in its configuration.

func LoadYAMLFileFromConfigMapData

func LoadYAMLFileFromConfigMapData(
	configMap corev1.ConfigMap,
	filename string,
) (map[string]interface{}, error)

func SetFailedState added in v0.5.0

func SetFailedState(ctx context.Context, kubeClient client.Client, resource client.Object, reason string)

func TriggerSynapseReconciliation added in v0.5.0

func TriggerSynapseReconciliation(kubeClient client.Client, resource Bridge) func(context.Context, ctrl.Request) (*ctrl.Result, error)

TriggerSynapseReconciliation returns a function of type subreconciler.FnWithRequest Bridges should trigger the reconciliation of their associated Synapse server so that Synapse can add the bridge as an application service in its configuration.

func UpdateConfigMap

func UpdateConfigMap(
	ctx context.Context,
	client client.Client,
	key types.NamespacedName,
	obj client.Object,
	updateData updateDataFunc,
	filename string,
) error

A generic function to update an existing ConfigMap. It takes as arguments: * The context * The key (name and namespace) of the ConfigMap to update * The Synapse object being reconciled * The function to be called to actually update the ConfigMap's content * The name of the file to update in the ConfigMap

func UpdateConfigMapData

func UpdateConfigMapData(
	cm *corev1.ConfigMap,
	obj client.Object,
	updateData updateDataFunc,
	filename string,
) error

func UpdateResourceStatus added in v0.5.0

func UpdateResourceStatus(ctx context.Context, kubeClient client.Client, resource client.Object, current client.Object) error

func UpdateSynapseStatus added in v0.5.0

func UpdateSynapseStatus(ctx context.Context, kubeClient client.Client, s *synapsev1alpha1.Synapse) error

Types

type Bridge added in v0.5.0

type Bridge interface {
	client.Object // *synapsev1alpha1.Heisenbridge | *synapsev1alpha1.MautrixSignal
	GetSynapseName() string
	GetSynapseNamespace() string
}

Matrix Bridges should implement the Bridge interface

Jump to

Keyboard shortcuts

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