github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/boom/application/resources/service.go (about) 1 package resources 2 3 type ServiceConfig struct { 4 Name string 5 Namespace string 6 Labels map[string]string 7 PortName string 8 Port int 9 TargetPort int 10 Protocol string 11 Selector map[string]string 12 } 13 14 type Spec struct { 15 Selector map[string]string `yaml:"selector"` 16 Ports []*Port `yaml:"ports"` 17 } 18 19 type Port struct { 20 Name string `yaml:"name"` 21 Protocol string `yaml:"protocol"` 22 Port int `yaml:"port"` 23 TargetPort int `yaml:"targetPort"` 24 } 25 26 type Service struct { 27 APIVersion string `yaml:"apiVersion"` 28 Kind string `yaml:"kind"` 29 Metadata *Metadata `yaml:"metadata"` 30 Spec *Spec `yaml:"spec"` 31 } 32 33 func NewService(conf *ServiceConfig) *Service { 34 return &Service{ 35 APIVersion: "v1", 36 Kind: "Service", 37 Metadata: &Metadata{ 38 Name: conf.Name, 39 Namespace: conf.Namespace, 40 Labels: conf.Labels, 41 }, 42 Spec: &Spec{ 43 Selector: conf.Selector, 44 Ports: []*Port{{ 45 Name: conf.PortName, 46 Protocol: conf.Protocol, 47 Port: conf.Port, 48 TargetPort: conf.TargetPort, 49 }}, 50 }, 51 } 52 }