Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import (
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/registry"

"github.com/argoproj/argo-cd/v3/util/askpass"
argocdlog "github.com/argoproj/argo-cd/v3/util/log"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"golang.org/x/sync/semaphore"
Expand All @@ -47,6 +49,14 @@ func newRunCommand() *cobra.Command {
Use: "run",
Short: "Runs the argocd-image-updater with a set of options",
RunE: func(cmd *cobra.Command, args []string) error {
// Configure the global logger for vendored argo-cd utilities
logLvl, err := logrus.ParseLevel(cfg.LogLevel)
if err != nil {
return fmt.Errorf("could not parse log level: %w", err)
}
logrus.SetLevel(logLvl)
logrus.SetFormatter(argocdlog.CreateFormatter(cfg.LogFormat))

if err := log.SetLogLevel(cfg.LogLevel); err != nil {
return err
}
Expand Down Expand Up @@ -126,7 +136,6 @@ func newRunCommand() *cobra.Command {
log.Warnf("Check interval is very low - it is not recommended to run below 1m0s")
}

var err error
if !disableKubernetes {
ctx := context.Background()
cfg.KubeClient, err = getKubeConfig(ctx, cfg.ArgocdNamespace, kubeConfig)
Expand Down
5 changes: 3 additions & 2 deletions ext/git/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
githttp "github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/knownhosts"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -35,6 +34,8 @@ import (
"github.com/argoproj/argo-cd/v3/util/env"
executil "github.com/argoproj/argo-cd/v3/util/exec"
"github.com/argoproj/argo-cd/v3/util/proxy"

"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/log"
)

var ErrInvalidRepoURL = fmt.Errorf("repo URL is invalid")
Expand Down Expand Up @@ -489,7 +490,7 @@ func (m *nativeGitClient) getRefs() ([]*plumbing.Reference, error) {
myLockUUID, err := uuid.NewRandom()
myLockId := ""
if err != nil {
log.Debug("Error generating git references cache lock id: ", err)
log.Debugf("Error generating git references cache lock id: %v", err)
} else {
myLockId = myLockUUID.String()
}
Expand Down
13 changes: 7 additions & 6 deletions ext/git/creds.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ import (
argoio "github.com/argoproj/gitops-engine/pkg/utils/io"
"github.com/argoproj/gitops-engine/pkg/utils/text"
"github.com/bradleyfalzon/ghinstallation/v2"
log "github.com/sirupsen/logrus"

"github.com/argoproj/argo-cd/v3/common"
certutil "github.com/argoproj/argo-cd/v3/util/cert"
argoioutils "github.com/argoproj/argo-cd/v3/util/io"

"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/log"
)

var (
Expand Down Expand Up @@ -286,10 +287,10 @@ func (c SSHCreds) Environ() (io.Closer, []string, error) {
}
defer func() {
if err = file.Close(); err != nil {
log.WithFields(log.Fields{
common.SecurityField: common.SecurityMedium,
common.SecurityCWEField: common.SecurityCWEMissingReleaseOfFileDescriptor,
}).Errorf("error closing file %q: %v", file.Name(), err)
log.WithContext().
AddField(common.SecurityField, common.SecurityMedium).
AddField(common.SecurityCWEField, common.SecurityCWEMissingReleaseOfFileDescriptor).
Errorf("error closing file %q: %v", file.Name(), err)
}
}()

Expand All @@ -304,7 +305,7 @@ func (c SSHCreds) Environ() (io.Closer, []string, error) {
env = append(env, fmt.Sprintf("GIT_SSL_CAINFO=%s", c.caPath))
}
if c.insecure {
log.Warn("temporarily disabling strict host key checking (i.e. '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'), please don't use in production")
log.Warnf("temporarily disabling strict host key checking (i.e. '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'), please don't use in production")
// StrictHostKeyChecking will add the host to the knownhosts file, we don't want that - a security issue really,
// UserKnownHostsFile=/dev/null is therefore used so we write the new insecure host to /dev/null
args = append(args, "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null")
Expand Down