Skip to content

Commit

Permalink
fix: ensure input CAbundle always end with a newline (#1339)
Browse files Browse the repository at this point in the history
* fix: ensure input CAbundle always end with a newline

- missing newline will cause problem when inject data into configmap
- this happens when user use kustomize with their own CA for DSCI, it set to use |- not |
- fix lint

Signed-off-by: Wen Zhou <wenzhou@redhat.com>

* update: better way to add newline

Signed-off-by: Wen Zhou <wenzhou@redhat.com>

---------

Signed-off-by: Wen Zhou <wenzhou@redhat.com>
  • Loading branch information
zdtsw authored Nov 7, 2024
1 parent 1f5af72 commit 656d53e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/trustedcabundle/trustedcabundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"strconv"
"strings"
"time"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -47,6 +48,9 @@ func HasCABundleAnnotationDisabled(ns client.Object) bool {
// or update existing odh-trusted-ca-bundle configmap if already exists with new content of .data.odh-ca-bundle.crt
// this is certificates for the cluster trusted CA Cert Bundle.
func CreateOdhTrustedCABundleConfigMap(ctx context.Context, cli client.Client, namespace string, customCAData string) error {
// Adding newline breaker if user input does not have it
customCAData = strings.TrimSpace(customCAData) + "\n"

// Expected configmap for the given namespace
desiredConfigMap := &corev1.ConfigMap{
TypeMeta: metav1.TypeMeta{
Expand Down

0 comments on commit 656d53e

Please sign in to comment.