Skip to content

Commit

Permalink
fix(helm): Fix UI DisruptionBudget and ServiceAccount templates (#606)
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Jogeleit <frank.jogeleit@web.de>
  • Loading branch information
fjogeleit authored Nov 28, 2024
1 parent 20d11dc commit 0119e1d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
8 changes: 8 additions & 0 deletions charts/policy-reporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ config:
certificate: {{ .certificate | quote }}
skipTLS: {{ .skipTLS }}
path: {{ .path | quote }}
{{- with .headers }}
headers:
{{- toYaml . | nindent 4 }}
{{- end }}
{{ include "target" . }}
{{- end }}

Expand All @@ -170,6 +174,10 @@ config:
index: {{ .index| quote }}
rotation: {{ .rotation | quote }}
typelessApi: {{ .typelessApi | quote }}
{{- with .headers }}
headers:
{{- toYaml . | nindent 4 }}
{{- end }}
{{ include "target" . }}
{{- end }}

Expand Down
16 changes: 8 additions & 8 deletions charts/policy-reporter/templates/ui/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ app.kubernetes.io/instance: {{ .Release.Name }}
Create the name of the service account to use
*/}}
{{- define "ui.serviceAccountName" -}}
{{- if .Values.plugin.kyverno.serviceAccount.create }}
{{- default (include "ui.fullname" .) .Values.plugin.kyverno.serviceAccount.name }}
{{- if .Values.ui.serviceAccount.create }}
{{- default (include "ui.fullname" .) .Values.ui.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.plugin.kyverno.serviceAccount.name }}
{{- default "default" .Values.ui.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "ui.podDisruptionBudget" -}}
{{- if and .Values.plugin.kyverno.ui.podDisruptionBudget.minAvailable .Values.plugin.kyverno.ui.podDisruptionBudget.maxUnavailable }}
{{- if and .Values.ui.podDisruptionBudget.minAvailable .Values.ui.podDisruptionBudget.maxUnavailable }}
{{- fail "Cannot set both" -}}
{{- end }}
{{- if not .Values.plugin.kyverno.ui.podDisruptionBudget.maxUnavailable }}
minAvailable: {{ default 1 .Values.plugin.kyverno.ui.podDisruptionBudget.minAvailable }}
{{- if not .Values.ui.podDisruptionBudget.maxUnavailable }}
minAvailable: {{ default 1 .Values.ui.podDisruptionBudget.minAvailable }}
{{- end }}
{{- if .Values.plugin.kyverno.ui.podDisruptionBudget.maxUnavailable }}
maxUnavailable: {{ .Values.plugin.kyverno.ui.podDisruptionBudget.maxUnavailable }}
{{- if .Values.ui.podDisruptionBudget.maxUnavailable }}
maxUnavailable: {{ .Values.ui.podDisruptionBudget.maxUnavailable }}
{{- end }}
{{- end }}
7 changes: 7 additions & 0 deletions pkg/target/elasticsearch/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Options struct {
Index string
Rotation string
CustomFields map[string]string
Headers map[string]string
HTTPClient http.Client
// https://www.elastic.co/blog/moving-from-types-to-typeless-apis-in-elasticsearch-7-0
TypelessApi bool
Expand All @@ -43,6 +44,7 @@ type client struct {
apiKey string
rotation Rotation
customFields map[string]string
headers map[string]string
client http.Client
// https://www.elastic.co/blog/moving-from-types-to-typeless-apis-in-elasticsearch-7-0
typelessApi bool
Expand Down Expand Up @@ -87,6 +89,10 @@ func (e *client) Send(result v1alpha2.PolicyReportResult) {
return
}

for k, v := range e.headers {
req.Header.Set(k, v)
}

if e.username != "" {
req.SetBasicAuth(e.username, e.password)
} else if e.apiKey != "" {
Expand All @@ -112,6 +118,7 @@ func NewClient(options Options) target.Client {
options.ApiKey,
options.Rotation,
options.CustomFields,
options.Headers,
options.HTTPClient,
options.TypelessApi,
}
Expand Down
1 change: 1 addition & 0 deletions pkg/target/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ func (f *TargetFactory) CreateElasticsearchTarget(config, parent *target.Config[
Index: config.Config.Index,
TypelessApi: config.Config.TypelessAPI,
CustomFields: config.CustomFields,
Headers: config.Config.Headers,
HTTPClient: http.NewClient(config.Config.Certificate, config.Config.SkipTLS),
}),
}
Expand Down

0 comments on commit 0119e1d

Please sign in to comment.