File tree 3 files changed +40
-0
lines changed
3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ func NewIngress(service types.ServiceConfig, Chart *HelmChart) *Ingress {
55
55
Host : mapping .Hostname ,
56
56
Class : mapping .Class ,
57
57
Annotations : mapping .Annotations ,
58
+ TLS : TLS {Enabled : mapping .TLS .Enabled },
58
59
}
59
60
60
61
// ingressClassName := `{{ .Values.` + service.Name + `.ingress.class }}`
@@ -131,6 +132,34 @@ func (ingress *Ingress) Yaml() ([]byte, error) {
131
132
ret = UnWrapTPL (ret )
132
133
133
134
lines := strings .Split (string (ret ), "\n " )
135
+
136
+ // first pass, wrap the tls part with `{{- if .Values.serviceName.ingress.tlsEnabled -}}`
137
+ // and `{{- end -}}`
138
+
139
+ from := - 1
140
+ to := - 1
141
+ spaces := - 1
142
+ for i , line := range lines {
143
+ if strings .Contains (line , "tls:" ) {
144
+ from = i
145
+ spaces = utils .CountStartingSpaces (line )
146
+ continue
147
+ }
148
+ if from > - 1 {
149
+ if utils .CountStartingSpaces (line ) >= spaces {
150
+ to = i
151
+ continue
152
+ }
153
+ }
154
+ }
155
+ if from > - 1 && to > - 1 {
156
+ lines [from ] = strings .Repeat (" " , spaces ) +
157
+ `{{- if .Values.` + serviceName + `.ingress.tls.enabled }}` +
158
+ "\n " +
159
+ lines [from ]
160
+ lines [to ] = strings .Repeat (" " , spaces ) + `{{ end -}}`
161
+ }
162
+
134
163
out := []string {
135
164
`{{- if .Values.` + serviceName + `.ingress.enabled -}}` ,
136
165
}
Original file line number Diff line number Diff line change @@ -2,13 +2,18 @@ package labelStructs
2
2
3
3
import "gopkg.in/yaml.v3"
4
4
5
+ type TLS struct {
6
+ Enabled bool `yaml:"enabled"`
7
+ }
8
+
5
9
type Ingress struct {
6
10
Port * int32 `yaml:"port,omitempty"`
7
11
Annotations map [string ]string `yaml:"annotations,omitempty"`
8
12
Hostname string `yaml:"hostname"`
9
13
Path string `yaml:"path"`
10
14
Class string `yaml:"class"`
11
15
Enabled bool `yaml:"enabled"`
16
+ TLS TLS `yaml:"tls"`
12
17
}
13
18
14
19
// IngressFrom creates a new Ingress from a compose service.
@@ -19,6 +24,7 @@ func IngressFrom(data string) (*Ingress, error) {
19
24
Enabled : false ,
20
25
Class : "-" ,
21
26
Port : nil ,
27
+ TLS : TLS {Enabled : true },
22
28
}
23
29
if err := yaml .Unmarshal ([]byte (data ), & mapping ); err != nil {
24
30
return nil , err
Original file line number Diff line number Diff line change @@ -20,13 +20,18 @@ type PersistenceValue struct {
20
20
Enabled bool `yaml:"enabled"`
21
21
}
22
22
23
+ type TLS struct {
24
+ Enabled bool `yaml:"enabled"`
25
+ }
26
+
23
27
// IngressValue is a ingress configuration that will be saved in values.yaml.
24
28
type IngressValue struct {
25
29
Annotations map [string ]string `yaml:"annotations"`
26
30
Host string `yaml:"host"`
27
31
Path string `yaml:"path"`
28
32
Class string `yaml:"class"`
29
33
Enabled bool `yaml:"enabled"`
34
+ TLS TLS `yaml:"tls"`
30
35
}
31
36
32
37
// Value will be saved in values.yaml. It contains configuraiton for all deployment and services.
You can’t perform that action at this time.
0 commit comments