Skip to content

Commit

Permalink
fix: ensure input CAbundle always end with a newline
Browse files Browse the repository at this point in the history
- 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 |

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

"github.com/go-logr/logr"
"github.com/hashicorp/go-multierror"
Expand Down Expand Up @@ -47,6 +48,10 @@ 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
if !strings.HasSuffix(customCAData, "\n") {
customCAData += "\n"
}
// Expected configmap for the given namespace
desiredConfigMap := &corev1.ConfigMap{
TypeMeta: metav1.TypeMeta{
Expand Down

0 comments on commit 952776f

Please sign in to comment.