Develop #79

Merged
metal3d merged 2 commits from develop into master 2024-11-09 12:57:35 +00:00
3 changed files with 38 additions and 0 deletions
Showing only changes of commit 9358076a36 - Show all commits

View File

@@ -55,6 +55,7 @@ func NewIngress(service types.ServiceConfig, Chart *HelmChart) *Ingress {
Host: mapping.Hostname,
Class: mapping.Class,
Annotations: mapping.Annotations,
TLS: mapping.TLS,
}
// ingressClassName := `{{ .Values.` + service.Name + `.ingress.class }}`
@@ -131,6 +132,34 @@ func (ingress *Ingress) Yaml() ([]byte, error) {
ret = UnWrapTPL(ret)
lines := strings.Split(string(ret), "\n")
// first pass, wrap the tls part with `{{- if .Values.serviceName.ingress.tlsEnabled -}}`
// and `{{- end -}}`
from := -1
to := -1
spaces := -1
for i, line := range lines {
if strings.Contains(line, "tls:") {
from = i
spaces = utils.CountStartingSpaces(line)
continue
}
if from > -1 {
if utils.CountStartingSpaces(line) >= spaces {
to = i
continue
}
}
}
if from > -1 && to > -1 {
lines[from] = strings.Repeat(" ", spaces) +
`{{- if .Values.` + serviceName + `.ingress.tls.enabled }}` +
"\n" +
lines[from]
lines[to] = strings.Repeat(" ", spaces) + `{{ end -}}`
}
out := []string{
`{{- if .Values.` + serviceName + `.ingress.enabled -}}`,
}

View File

@@ -2,6 +2,10 @@ package labelStructs
import "gopkg.in/yaml.v3"
type TLS struct {
Enabled bool `yaml:"enabled"`
}
type Ingress struct {
Port *int32 `yaml:"port,omitempty"`
Annotations map[string]string `yaml:"annotations,omitempty"`
@@ -9,6 +13,7 @@ type Ingress struct {
Path string `yaml:"path"`
Class string `yaml:"class"`
Enabled bool `yaml:"enabled"`
TLS TLS `yaml:"tls"`
}
// IngressFrom creates a new Ingress from a compose service.
@@ -19,6 +24,7 @@ func IngressFrom(data string) (*Ingress, error) {
Enabled: false,
Class: "-",
Port: nil,
TLS: TLS{Enabled: true},
}
if err := yaml.Unmarshal([]byte(data), &mapping); err != nil {
return nil, err

View File

@@ -27,6 +27,9 @@ type IngressValue struct {
Path string `yaml:"path"`
Class string `yaml:"class"`
Enabled bool `yaml:"enabled"`
TLS struct {
Enabled bool `yaml:"enabled"`
} `yaml:"tls"`
}
// Value will be saved in values.yaml. It contains configuraiton for all deployment and services.