-
Notifications
You must be signed in to change notification settings - Fork 308
/
dns.go
49 lines (41 loc) · 1.07 KB
/
dns.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
package globalconfig
import (
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
configv1 "github.com/openshift/api/config/v1"
hyperv1 "github.com/openshift/hypershift/api/v1beta1"
)
func DNSConfig() *configv1.DNS {
return &configv1.DNS{
ObjectMeta: metav1.ObjectMeta{
Name: "cluster",
},
}
}
func ReconcileDNSConfig(dns *configv1.DNS, hcp *hyperv1.HostedControlPlane) {
if hcp.Spec.Platform.Type == hyperv1.IBMCloudPlatform {
dns.Spec.BaseDomain = hcp.Spec.DNS.BaseDomain
} else {
dns.Spec.BaseDomain = BaseDomain(hcp)
}
if len(hcp.Spec.DNS.PublicZoneID) > 0 {
dns.Spec.PublicZone = &configv1.DNSZone{
ID: hcp.Spec.DNS.PublicZoneID,
}
}
if len(hcp.Spec.DNS.PrivateZoneID) > 0 {
dns.Spec.PrivateZone = &configv1.DNSZone{
ID: hcp.Spec.DNS.PrivateZoneID,
}
}
}
func BaseDomain(hcp *hyperv1.HostedControlPlane) string {
prefix := hcp.Name
if hcp.Spec.DNS.BaseDomainPrefix != nil {
prefix = *hcp.Spec.DNS.BaseDomainPrefix
}
if prefix == "" {
return hcp.Spec.DNS.BaseDomain
}
return fmt.Sprintf("%s.%s", prefix, hcp.Spec.DNS.BaseDomain)
}