From 70dfc4adc31d4cfca72ab81c57043789e28c22f9 Mon Sep 17 00:00:00 2001 From: Allen Zhong Date: Thu, 6 May 2021 14:26:38 +0800 Subject: [PATCH] cleanup --- cmd/root.go | 2 +- components/cluster/command/root.go | 6 +++--- pkg/telemetry/report.go | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 1e700371ad..894ce70779 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -218,7 +218,7 @@ func Execute() { teleReport.InstallationUUID = teleMeta.UUID } // default to false on errors } - fmt.Println(reportEnabled) + if reportEnabled { teleReport.EventUUID = eventUUID teleReport.EventUnixTimestamp = start.Unix() diff --git a/components/cluster/command/root.go b/components/cluster/command/root.go index dbd3a0ab47..56dcef7e0e 100644 --- a/components/cluster/command/root.go +++ b/components/cluster/command/root.go @@ -57,7 +57,7 @@ var cm *manager.Manager func scrubClusterName(n string) string { // prepend the telemetry secret to cluster name, so that two installations // of tiup with the same cluster name produce different hashes - cls := telemetry.GetTelemetrySecret() + ":" + n + cls := telemetry.GetSecret() + ":" + n return "cluster_" + telemetry.HashReport(cls) } @@ -249,7 +249,7 @@ func Execute() { if eventUUID == "" { eventUUID = uuid.New().String() } - teleReport.InstallationUUID = telemetry.GetTelemetryUUID() + teleReport.InstallationUUID = telemetry.GetUUID() teleReport.EventUUID = eventUUID teleReport.EventUnixTimestamp = time.Now().Unix() teleReport.Version = telemetry.TiUPMeta() @@ -292,7 +292,7 @@ func Execute() { "config": {}, "server_configs": {}, }, // fields to omit - telemetry.GetTelemetrySecret(), + telemetry.GetSecret(), ); err == nil { clusterReport.Topology = (string(data)) } diff --git a/pkg/telemetry/report.go b/pkg/telemetry/report.go index 8ecc601de3..440ceae827 100644 --- a/pkg/telemetry/report.go +++ b/pkg/telemetry/report.go @@ -30,13 +30,13 @@ func Enabled() bool { return status == EnableStatus } -// GetTelemetryUUID return telemetry uuid. -func GetTelemetryUUID() string { +// GetUUID return telemetry uuid. +func GetUUID() string { return os.Getenv(localdata.EnvNameTelemetryUUID) } -// GetTelemetrySecret return telemetry uuid. -func GetTelemetrySecret() string { +// GetSecret return telemetry encrypt secret. +func GetSecret() string { return os.Getenv(localdata.EnvNameTelemetrySecret) }