Skip to content

Commit c62354a

Browse files
committed
fix
1 parent 22e22ae commit c62354a

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

pkg/telemetry/meta.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ const (
3737
DisableStatus Status = "disable"
3838
)
3939

40-
const defaultStatus = ""
41-
4240
// Meta data of telemetry.
4341
type Meta struct {
4442
UUID string `yaml:"uuid,omitempty"`
@@ -88,11 +86,11 @@ func LoadFrom(fname string) (meta *Meta, err error) {
8886

8987
// populate UUID and secret if not set
9088
var updated bool
91-
if meta.UUID == "" {
89+
if meta.UUID == "" && meta.Status == EnableStatus {
9290
meta.UUID = NewUUID()
9391
updated = true
9492
}
95-
if meta.Secret == "" {
93+
if meta.Secret == "" && meta.Status == EnableStatus {
9694
meta.Secret = NewSecret()
9795
updated = true
9896
}

pkg/telemetry/meta_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (s *teleSuite) TestTelemetry(c *check.C) {
2323
// Should no error and get a default meta.
2424
meta, err := LoadFrom(fname)
2525
c.Assert(err, check.IsNil)
26-
c.Assert(meta.Status, check.Equals, defaultStatus)
26+
c.Assert(meta.Status, check.Equals, Status(""))
2727
c.Assert(len(meta.UUID), check.Equals, 0)
2828

2929
// Save and load back

0 commit comments

Comments
 (0)