Refacto to split types

This commit is contained in:
2022-05-05 09:43:52 +02:00
parent 8ce0d64e62
commit b6f2e480ba
10 changed files with 196 additions and 150 deletions

View File

@@ -1,10 +1,12 @@
package helm
// Service is a Kubernetes service.
type Service struct {
*K8sBase `yaml:",inline"`
Spec *ServiceSpec `yaml:"spec"`
}
// NewService creates a new initialized service.
func NewService(name string) *Service {
s := &Service{
K8sBase: NewBase(),
@@ -17,12 +19,14 @@ func NewService(name string) *Service {
return s
}
// ServicePort is a port on a service.
type ServicePort struct {
Protocol string `yaml:"protocol"`
Port int `yaml:"port"`
TargetPort int `yaml:"targetPort"`
}
// NewServicePort creates a new initialized service port.
func NewServicePort(port, target int) *ServicePort {
return &ServicePort{
Protocol: "TCP",
@@ -31,12 +35,14 @@ func NewServicePort(port, target int) *ServicePort {
}
}
// ServiceSpec is the spec for a service.
type ServiceSpec struct {
Selector map[string]string
Ports []*ServicePort
Type string `yaml:"type,omitempty"`
}
// NewServiceSpec creates a new initialized service spec.
func NewServiceSpec() *ServiceSpec {
return &ServiceSpec{
Selector: make(map[string]string),