Skip to content

Commit

Permalink
disable telemetry by default (#2119)
Browse files Browse the repository at this point in the history
  • Loading branch information
nexustar committed Feb 14, 2023
1 parent 4c2debc commit e0aeda1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions pkg/telemetry/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ const (
DisableStatus Status = "disable"
)

const defaultStatus = EnableStatus

// Meta data of telemetry.
type Meta struct {
UUID string `yaml:"uuid,omitempty"`
Expand Down Expand Up @@ -78,8 +76,7 @@ func LoadFrom(fname string) (meta *Meta, err error) {

if err != nil {
if os.IsNotExist(err) {
meta = NewMeta()
return meta, meta.SaveTo(fname)
return &Meta{}, nil
}
return
}
Expand All @@ -89,11 +86,11 @@ func LoadFrom(fname string) (meta *Meta, err error) {

// populate UUID and secret if not set
var updated bool
if meta.UUID == "" {
if meta.UUID == "" && meta.Status == EnableStatus {
meta.UUID = NewUUID()
updated = true
}
if meta.Secret == "" {
if meta.Secret == "" && meta.Status == EnableStatus {
meta.Secret = NewSecret()
updated = true
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/telemetry/meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func (s *teleSuite) TestTelemetry(c *check.C) {
// Should no error and get a default meta.
meta, err := LoadFrom(fname)
c.Assert(err, check.IsNil)
c.Assert(meta.Status, check.Equals, defaultStatus)
c.Assert(len(meta.UUID), check.Greater, 0)
c.Assert(meta.Status, check.Equals, Status(""))
c.Assert(len(meta.UUID), check.Equals, 0)

// Save and load back
err = meta.SaveTo(fname)
Expand Down

0 comments on commit e0aeda1

Please sign in to comment.