forked from giantswarm/aws-operator
/
desired.go
45 lines (39 loc) · 1.03 KB
/
desired.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
package service
import (
"context"
"github.com/giantswarm/microerror"
"k8s.io/api/core/v1"
apismetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"github.com/giantswarm/aws-operator/service/awsconfig/v6/key"
)
func (r *Resource) GetDesiredState(ctx context.Context, obj interface{}) (interface{}, error) {
customObject, err := key.ToCustomObject(obj)
if err != nil {
return nil, microerror.Mask(err)
}
service := &v1.Service{
ObjectMeta: apismetav1.ObjectMeta{
Name: "master",
Namespace: key.ClusterID(customObject),
Labels: map[string]string{
"app": "master",
"cluster": key.ClusterID(customObject),
"customer": key.CustomerID(customObject),
},
Annotations: map[string]string{
"giantswarm.io/prometheus-cluster": key.ClusterID(customObject),
},
},
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Protocol: v1.ProtocolTCP,
Port: httpsPort,
TargetPort: intstr.FromInt(httpsPort),
},
},
},
}
return service, nil
}