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 |
- fix lint

Signed-off-by: Wen Zhou <wenzhou@redhat.com>
  • Loading branch information
zdtsw committed Nov 5, 2024
1 parent 1f5af72 commit 65977fb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion controllers/dscinitialization/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestDataScienceClusterInitialization(t *testing.T) {

var testScheme = runtime.NewScheme()

//nolint:fatcontext
//nolint: fatcontext
var _ = BeforeSuite(func() {
// can't use suite's context as the manager should survive the function
gCtx, gCancel = context.WithCancel(context.Background())
Expand Down
2 changes: 1 addition & 1 deletion controllers/webhook/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestAPIs(t *testing.T) {
RunSpecs(t, "Webhook Suite")
}

//nolint:fatcontext
//nolint: fatcontext
var _ = BeforeSuite(func() {
// can't use suite's context as the manager should survive the function
gCtx, gCancel = context.WithCancel(context.Background())
Expand Down
5 changes: 5 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,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 65977fb

Please sign in to comment.