Files
katenary/helm/service.go

46 lines
931 B
Go
Raw Normal View History

2021-11-30 12:04:28 +01:00
package helm
type Service struct {
*K8sBase `yaml:",inline"`
Spec *ServiceSpec `yaml:"spec"`
}
2021-12-01 15:17:34 +01:00
func NewService(name string) *Service {
2021-11-30 12:04:28 +01:00
s := &Service{
K8sBase: NewBase(),
Spec: NewServiceSpec(),
}
2021-12-01 15:17:34 +01:00
s.K8sBase.Metadata.Name = "{{ .Release.Name }}-" + name
2021-11-30 12:04:28 +01:00
s.K8sBase.Kind = "Service"
s.K8sBase.ApiVersion = "v1"
2021-12-01 15:17:34 +01:00
s.K8sBase.Metadata.Labels[K+"/component"] = name
2021-11-30 12:04:28 +01:00
return s
}
type ServicePort struct {
Protocol string `yaml:"protocol"`
Port int `yaml:"port"`
TargetPort int `yaml:"targetPort"`
}
func NewServicePort(port, target int) *ServicePort {
return &ServicePort{
Protocol: "TCP",
Port: port,
TargetPort: port,
}
}
type ServiceSpec struct {
Selector map[string]string
Ports []*ServicePort
Type string `yaml:"type,omitempty"`
2021-11-30 12:04:28 +01:00
}
func NewServiceSpec() *ServiceSpec {
return &ServiceSpec{
Selector: make(map[string]string),
Ports: make([]*ServicePort, 0),
}
}