-
Notifications
You must be signed in to change notification settings - Fork 462
/
index.go
38 lines (31 loc) · 1.28 KB
/
index.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
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
package index
import (
"sigs.k8s.io/controller-runtime/pkg/client"
gardencorev1beta1 "github.com/gardener/gardener/pkg/apis/core/v1beta1"
)
// SecretRefNamespaceField is the field name for the index function that extracts the corresponding field from SecretBinding.
const SecretRefNamespaceField string = "secretRef.namespace"
// SecretRefNamespaceIndexerFunc extracts the secretRef.namespace field of a SecretBinding.
func SecretRefNamespaceIndexerFunc(rawObj client.Object) []string {
secretBinding, ok := rawObj.(*gardencorev1beta1.SecretBinding)
if !ok {
return []string{}
}
return []string{secretBinding.SecretRef.Namespace}
}
// SecretBindingNameField is the field name for the index function that extracts the corresponding field from Shoot.
const SecretBindingNameField string = "spec.secretBindingName"
// SecretBindingNameIndexerFunc extracts the spec.secretBindingName field of a Shoot.
func SecretBindingNameIndexerFunc(rawObj client.Object) []string {
shoot, ok := rawObj.(*gardencorev1beta1.Shoot)
if !ok {
return []string{}
}
if shoot.Spec.SecretBindingName == nil {
return []string{}
}
return []string{*shoot.Spec.SecretBindingName}
}