-
Notifications
You must be signed in to change notification settings - Fork 99
/
shared_utils.go
29 lines (22 loc) · 1.02 KB
/
shared_utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
package utils
import (
"fmt"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// ShouldReturn returns if we should stop the reconcile loop based on result
func ShouldReturn(result reconcile.Result, err error) bool {
return err != nil || result.Requeue || result.RequeueAfter > 0
}
// GetDatadogLeaderElectionResourceName return the nome of the Resource managing the leader election token info.
func GetDatadogLeaderElectionResourceName(dda metav1.Object) string {
return fmt.Sprintf("%s-leader-election", dda.GetName())
}
// GetDatadogTokenResourceName returns the name of the ConfigMap used by the cluster agent to store token
func GetDatadogTokenResourceName(dda metav1.Object) string {
return fmt.Sprintf("%stoken", dda.GetName())
}