forked from kubernetes-sigs/aws-load-balancer-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
37 lines (31 loc) · 1.33 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
package targetgroupbinding
import (
"fmt"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
elbv2api "github.com/sonal-chauhan/aws-load-balancer-controller/apis/elbv2/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
const (
// Prefix for TargetHealth pod condition type.
TargetHealthPodConditionTypePrefix = "target-health.elbv2.k8s.aws"
// Legacy Prefix for TargetHealth pod condition type(used by AWS ALB Ingress Controller)
TargetHealthPodConditionTypePrefixLegacy = "target-health.alb.ingress.k8s.aws"
// Index Key for "ServiceReference" index.
IndexKeyServiceRefName = "spec.serviceRef.name"
)
// BuildTargetHealthPodConditionType constructs the condition type for TargetHealth pod condition.
func BuildTargetHealthPodConditionType(tgb *elbv2api.TargetGroupBinding) corev1.PodConditionType {
return corev1.PodConditionType(fmt.Sprintf("%s/%s", TargetHealthPodConditionTypePrefix, tgb.Name))
}
// IndexFuncServiceRefName is IndexFunc for "ServiceReference" index.
func IndexFuncServiceRefName(obj client.Object) []string {
tgb := obj.(*elbv2api.TargetGroupBinding)
return []string{tgb.Spec.ServiceRef.Name}
}
func buildServiceReferenceKey(tgb *elbv2api.TargetGroupBinding, svcRef elbv2api.ServiceReference) types.NamespacedName {
return types.NamespacedName{
Namespace: tgb.Namespace,
Name: svcRef.Name,
}
}