Skip to content

Commit

Permalink
Merge branch 'operator-redesign' of github.com:argoproj-labs/argocd-o…
Browse files Browse the repository at this point in the history
…perator into operator-redesign
  • Loading branch information
jaideepr97 committed Jan 25, 2024
2 parents d812697 + b06f1f9 commit b623adb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
1 change: 1 addition & 0 deletions common/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,5 @@ const (
// misc
const (
TLSSecretNameKey = "tls-secret-name"
WantAutoTLSKey = "wantAutoTLS"
)
27 changes: 18 additions & 9 deletions pkg/openshift/mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package openshift

import (
"fmt"
"strconv"

"golang.org/x/mod/semver"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -30,24 +31,32 @@ func AddAutoTLSAnnotationForOpenShift(cr *argoproj.ArgoCD, resource interface{},
}
switch obj := resource.(type) {
case *corev1.Service:
if cr == nil {
return nil
}
// return if autoTLS is not requested
if !cr.Spec.Redis.WantsAutoTLS() {
return nil
}

if obj.Annotations == nil {
obj.Annotations = make(map[string]string)
}

// Ensure that args carries only one argument, which is a map of type map[string]string
// containing the key "tls-secret-name". If this is the case, the associated value
// can be used within the service annotation
// containing the keys "wantAutoTLS" and "tls-secret-name". If this is the case, the associated value
// can be used within the service annotation if auto TLS is requested
if len(args) == 1 {
for _, arg := range args {
argMap := arg.(map[string]string)

if val, ok := argMap[common.WantAutoTLSKey]; !ok {
return nil
} else {
wantTLS, err := strconv.ParseBool(val)
if err != nil {
return errors.Wrapf(err, "AddAutoTLSAnnotationForOpenShift: failed to parse mutation args for resource")
}

// return if autoTLS is not requested
if !wantTLS {
return nil
}
}

if val, ok := argMap[common.TLSSecretNameKey]; ok {
obj.Annotations[common.ServiceBetaOpenshiftKeyCertSecret] = val
}
Expand Down
18 changes: 18 additions & 0 deletions pkg/util/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,27 @@ package util
import (
"strings"

"github.com/go-logr/logr"
"go.uber.org/zap/zapcore"
ctrl "sigs.k8s.io/controller-runtime"
)

type Logger struct {
logr.Logger
}

func NewLogger(name string, keysAndValues ...interface{}) *Logger {
return &Logger{
ctrl.Log.WithName(name).WithValues(keysAndValues...),
}
}

func (logger *Logger) Debug(msg string, keysAndValues ...interface{}) {
lvl := int(-1 * zapcore.DebugLevel)

logger.V(lvl).Info(msg, keysAndValues...)
}

func GetLogLevel(lvl string) zapcore.Level {
switch strings.ToLower(lvl) {
case "error":
Expand Down

0 comments on commit b623adb

Please sign in to comment.