-
Notifications
You must be signed in to change notification settings - Fork 23
/
utils.go
45 lines (39 loc) · 1.25 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* SPDX-FileCopyrightText: 2019 SAP SE or an SAP affiliate company and Gardener contributors
*
* SPDX-License-Identifier: Apache-2.0
*/
package source
import (
"strings"
"github.com/gardener/controller-manager-library/pkg/resources"
)
func requireFinalizer(src resources.Object, cluster resources.Cluster) bool {
return src.GetCluster() != cluster
}
// ExtractSecretLabels extracts label key value map from annotation.
func ExtractSecretLabels(objData resources.ObjectData) (secretLabels map[string]string) {
if labels, ok := resources.GetAnnotation(objData, AnnotCertSecretLabels); ok {
secretLabels = map[string]string{}
for _, pair := range strings.Split(labels, ",") {
pair = strings.TrimSpace(pair)
items := strings.SplitN(pair, "=", 2)
if len(items) == 2 {
secretLabels[items[0]] = items[1]
}
}
}
return
}
// CopyDNSRecordsAnnotations extracts DNSRecord related annotations.
func CopyDNSRecordsAnnotations(data resources.ObjectData) (annotations map[string]string) {
for _, annotKey := range []string{AnnotDNSRecordProviderType, AnnotDNSRecordSecretRef} {
if value := data.GetAnnotations()[annotKey]; value != "" {
if annotations == nil {
annotations = map[string]string{}
}
annotations[annotKey] = value
}
}
return
}