From a02f35e9e6bd01e1c75404be59f451a8381a6fca Mon Sep 17 00:00:00 2001 From: Yuan Tang Date: Fri, 25 Feb 2022 12:27:05 -0500 Subject: [PATCH] feat: Add identifiable user agents in various Argo commands (#8566) Signed-off-by: Yuan Tang --- .../commands/argocd_application_controller.go | 3 ++- cmd/argocd-dex/commands/argocd_dex.go | 5 +++++ cmd/argocd-notification/commands/controller.go | 6 +++++- cmd/argocd-server/commands/argocd_server.go | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cmd/argocd-application-controller/commands/argocd_application_controller.go b/cmd/argocd-application-controller/commands/argocd_application_controller.go index d453ed0480daa..b72e2327037c6 100644 --- a/cmd/argocd-application-controller/commands/argocd_application_controller.go +++ b/cmd/argocd-application-controller/commands/argocd_application_controller.go @@ -69,6 +69,8 @@ func NewCommand() *cobra.Command { config, err := clientConfig.ClientConfig() errors.CheckError(err) errors.CheckError(v1alpha1.SetK8SConfigDefaults(config)) + vers := common.GetVersion() + config.UserAgent = fmt.Sprintf("argocd-application-controller/%s (%s)", vers.Version, vers.Platform) kubeClient := kubernetes.NewForConfigOrDie(config) appClient := appclientset.NewForConfigOrDie(config) @@ -136,7 +138,6 @@ func NewCommand() *cobra.Command { errors.CheckError(err) cacheutil.CollectMetrics(redisClient, appController.GetMetricsServer()) - vers := common.GetVersion() log.Infof("Application Controller (version: %s, built: %s) starting (namespace: %s)", vers.Version, vers.BuildDate, namespace) stats.RegisterStackDumper() stats.StartStatsTicker(10 * time.Minute) diff --git a/cmd/argocd-dex/commands/argocd_dex.go b/cmd/argocd-dex/commands/argocd_dex.go index f52b59e8b54e3..e7dac63e16f98 100644 --- a/cmd/argocd-dex/commands/argocd_dex.go +++ b/cmd/argocd-dex/commands/argocd_dex.go @@ -8,6 +8,8 @@ import ( "os/exec" "syscall" + "github.com/argoproj/argo-cd/v2/common" + "github.com/ghodss/yaml" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -56,9 +58,12 @@ func NewRunDexCommand() *cobra.Command { errors.CheckError(err) config, err := clientConfig.ClientConfig() errors.CheckError(err) + vers := common.GetVersion() + config.UserAgent = fmt.Sprintf("argocd-dex/%s (%s)", vers.Version, vers.Platform) namespace, _, err := clientConfig.Namespace() errors.CheckError(err) kubeClientset := kubernetes.NewForConfigOrDie(config) + settingsMgr := settings.NewSettingsManager(context.Background(), kubeClientset, namespace) prevSettings, err := settingsMgr.GetSettings() errors.CheckError(err) diff --git a/cmd/argocd-notification/commands/controller.go b/cmd/argocd-notification/commands/controller.go index 4df2f3c6bc671..d5bd041cef6a7 100644 --- a/cmd/argocd-notification/commands/controller.go +++ b/cmd/argocd-notification/commands/controller.go @@ -7,11 +7,13 @@ import ( "os" "strings" + "github.com/argoproj/argo-cd/v2/common" + service "github.com/argoproj/argo-cd/v2/util/notification/argocd" notificationscontroller "github.com/argoproj/argo-cd/v2/notification_controller/controller" - controller "github.com/argoproj/notifications-engine/pkg/controller" + "github.com/argoproj/notifications-engine/pkg/controller" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" log "github.com/sirupsen/logrus" @@ -59,6 +61,8 @@ func NewCommand() *cobra.Command { if err != nil { return err } + vers := common.GetVersion() + restConfig.UserAgent = fmt.Sprintf("argocd-notifications-controller/%s (%s)", vers.Version, vers.Platform) dynamicClient, err := dynamic.NewForConfig(restConfig) if err != nil { return err diff --git a/cmd/argocd-server/commands/argocd_server.go b/cmd/argocd-server/commands/argocd_server.go index e02816688f0d9..c590d29068609 100644 --- a/cmd/argocd-server/commands/argocd_server.go +++ b/cmd/argocd-server/commands/argocd_server.go @@ -92,6 +92,8 @@ func NewCommand() *cobra.Command { appclientsetConfig, err := clientConfig.ClientConfig() errors.CheckError(err) errors.CheckError(v1alpha1.SetK8SConfigDefaults(appclientsetConfig)) + vers := common.GetVersion() + config.UserAgent = fmt.Sprintf("argocd-server/%s (%s)", vers.Version, vers.Platform) if failureRetryCount > 0 { appclientsetConfig = kube.AddFailureRetryWrapper(appclientsetConfig, failureRetryCount, failureRetryPeriodMilliSeconds)