generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 10
/
annotations.go
50 lines (40 loc) · 1.43 KB
/
annotations.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
46
47
48
49
50
package extender
import (
gardener "github.com/gardener/gardener/pkg/apis/core/v1beta1"
imv1 "github.com/kyma-project/infrastructure-manager/api/v1"
)
// Provisioner was setting the following annotations:
//- kcp.provisioner.kyma-project.io/licence-type
//- kcp.provisioner.kyma-project.io/runtime-id
//- support.gardener.cloud/eu-access-for-cluster-nodes
const (
ShootRuntimeIDAnnotation = "infrastructuremanager.kyma-project.io/runtime-id"
ShootLicenceTypeAnnotation = "infrastructuremanager.kyma-project.io/licence-type"
RuntimeIDLabel = "kyma-project.io/runtime-id"
ShootRestrictedEUAccessAnnotation = "support.gardener.cloud/eu-access-for-cluster-nodes"
)
func ExtendWithAnnotations(runtime imv1.Runtime, shoot *gardener.Shoot) error {
shoot.Annotations = getAnnotations(runtime)
return nil
}
func getAnnotations(runtime imv1.Runtime) map[string]string {
annotations := map[string]string{
ShootRuntimeIDAnnotation: runtime.Labels[RuntimeIDLabel],
}
if runtime.Spec.Shoot.LicenceType != nil && *runtime.Spec.Shoot.LicenceType != "" {
annotations[ShootLicenceTypeAnnotation] = *runtime.Spec.Shoot.LicenceType
}
if isEuAccess(runtime.Spec.Shoot.PlatformRegion) {
annotations[ShootRestrictedEUAccessAnnotation] = "true"
}
return annotations
}
func isEuAccess(platformRegion string) bool {
switch platformRegion {
case "cf-eu11":
return true
case "cf-ch20":
return true
}
return false
}