Skip to content

Commit

Permalink
refactor: rename telemetry wasm-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Sep 26, 2023
1 parent a57c12f commit db01ef9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
20 changes: 10 additions & 10 deletions pkg/commands/telemetry/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ func (c *RootCommand) Exec(_ io.Reader, out io.Writer) error {
return fsterr.ErrInvalidTelemetryEnableDisableCombo
}
if c.disable {
c.Globals.Config.Telemetry = toggleAll("disable")
c.Globals.Config.WasmMetadata = toggleAll("disable")
}
if c.enable {
c.Globals.Config.Telemetry = toggleAll("enable")
c.Globals.Config.WasmMetadata = toggleAll("enable")
}
if c.disable && (c.enableBuild || c.enableMachine || c.enablePackage) {
text.Info(out, "We will disable all telemetry except for the specified `--enable-*` flags")
Expand All @@ -62,22 +62,22 @@ func (c *RootCommand) Exec(_ io.Reader, out io.Writer) error {
text.Break(out)
}
if c.enableBuild {
c.Globals.Config.Telemetry.BuildInfo = "enable"
c.Globals.Config.WasmMetadata.BuildInfo = "enable"
}
if c.enableMachine {
c.Globals.Config.Telemetry.MachineInfo = "enable"
c.Globals.Config.WasmMetadata.MachineInfo = "enable"
}
if c.enablePackage {
c.Globals.Config.Telemetry.PackageInfo = "enable"
c.Globals.Config.WasmMetadata.PackageInfo = "enable"
}
if c.disableBuild {
c.Globals.Config.Telemetry.BuildInfo = "disable"
c.Globals.Config.WasmMetadata.BuildInfo = "disable"
}
if c.disableMachine {
c.Globals.Config.Telemetry.MachineInfo = "disable"
c.Globals.Config.WasmMetadata.MachineInfo = "disable"
}
if c.disablePackage {
c.Globals.Config.Telemetry.PackageInfo = "disable"
c.Globals.Config.WasmMetadata.PackageInfo = "disable"
}
err := c.Globals.Config.Write(c.Globals.ConfigPath)
if err != nil {
Expand All @@ -87,8 +87,8 @@ func (c *RootCommand) Exec(_ io.Reader, out io.Writer) error {
return nil
}

func toggleAll(state string) config.Telemetry {
var t config.Telemetry
func toggleAll(state string) config.WasmMetadata {
var t config.WasmMetadata
t.BuildInfo = state
t.MachineInfo = state
t.PackageInfo = state
Expand Down
22 changes: 11 additions & 11 deletions pkg/commands/telemetry/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
type Scenario struct {
testutil.TestScenario

ExpectedConfig config.Telemetry
ExpectedConfig config.WasmMetadata
}

func TestTelemetry(t *testing.T) {
Expand Down Expand Up @@ -69,7 +69,7 @@ func TestTelemetry(t *testing.T) {
Args: args("telemetry --enable"),
WantOutput: "SUCCESS: configuration updated (see: `fastly config`)",
},
ExpectedConfig: config.Telemetry{
ExpectedConfig: config.WasmMetadata{
BuildInfo: "enable",
MachineInfo: "enable",
PackageInfo: "enable",
Expand All @@ -80,7 +80,7 @@ func TestTelemetry(t *testing.T) {
Args: args("telemetry --disable"),
WantOutput: "SUCCESS: configuration updated (see: `fastly config`)",
},
ExpectedConfig: config.Telemetry{
ExpectedConfig: config.WasmMetadata{
BuildInfo: "disable",
MachineInfo: "disable",
PackageInfo: "disable",
Expand All @@ -94,7 +94,7 @@ func TestTelemetry(t *testing.T) {
"SUCCESS: configuration updated (see: `fastly config`)",
},
},
ExpectedConfig: config.Telemetry{
ExpectedConfig: config.WasmMetadata{
BuildInfo: "disable",
MachineInfo: "enable",
PackageInfo: "enable",
Expand All @@ -108,7 +108,7 @@ func TestTelemetry(t *testing.T) {
"SUCCESS: configuration updated (see: `fastly config`)",
},
},
ExpectedConfig: config.Telemetry{
ExpectedConfig: config.WasmMetadata{
BuildInfo: "disable",
MachineInfo: "enable",
PackageInfo: "disable",
Expand Down Expand Up @@ -162,14 +162,14 @@ func TestTelemetry(t *testing.T) {
t.Error(err)
}

if opts.ConfigFile.Telemetry.BuildInfo != testcase.ExpectedConfig.BuildInfo {
t.Errorf("want: %s, got: %s", testcase.ExpectedConfig.BuildInfo, opts.ConfigFile.Telemetry.BuildInfo)
if opts.ConfigFile.WasmMetadata.BuildInfo != testcase.ExpectedConfig.BuildInfo {
t.Errorf("want: %s, got: %s", testcase.ExpectedConfig.BuildInfo, opts.ConfigFile.WasmMetadata.BuildInfo)
}
if opts.ConfigFile.Telemetry.MachineInfo != testcase.ExpectedConfig.MachineInfo {
t.Errorf("want: %s, got: %s", testcase.ExpectedConfig.MachineInfo, opts.ConfigFile.Telemetry.MachineInfo)
if opts.ConfigFile.WasmMetadata.MachineInfo != testcase.ExpectedConfig.MachineInfo {
t.Errorf("want: %s, got: %s", testcase.ExpectedConfig.MachineInfo, opts.ConfigFile.WasmMetadata.MachineInfo)
}
if opts.ConfigFile.Telemetry.PackageInfo != testcase.ExpectedConfig.PackageInfo {
t.Errorf("want: %s, got: %s", testcase.ExpectedConfig.PackageInfo, opts.ConfigFile.Telemetry.PackageInfo)
if opts.ConfigFile.WasmMetadata.PackageInfo != testcase.ExpectedConfig.PackageInfo {
t.Errorf("want: %s, got: %s", testcase.ExpectedConfig.PackageInfo, opts.ConfigFile.WasmMetadata.PackageInfo)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/telemetry/testdata/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[telemetry]
[wasm-metadata]
build_info = "disable"
machine_info = "disable"
package_info = "disable"
8 changes: 4 additions & 4 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ type Fastly struct {
APIEndpoint string `toml:"api_endpoint"`
}

// Telemetry represents what telemetry data will be recorded.
type Telemetry struct {
// WasmMetadata represents what telemetry data will be recorded.
type WasmMetadata struct {
// BuildInfo represents information regarding the time taken for builds and
// compilation processes, helping us identify bottlenecks and optimize
// performance (enable/disable).
Expand Down Expand Up @@ -175,8 +175,6 @@ type File struct {
ConfigVersion int `toml:"config_version"`
// Fastly represents fastly specific configuration.
Fastly Fastly `toml:"fastly"`
// Telemetry represents what telemetry data will be recorded.
Telemetry Telemetry `toml:"telemetry"`
// Language represents C@E language specific configuration.
Language Language `toml:"language"`
// Profiles represents multiple profile accounts.
Expand All @@ -185,6 +183,8 @@ type File struct {
StarterKits StarterKitLanguages `toml:"starter-kits"`
// Viceroy represents viceroy specific configuration.
Viceroy Viceroy `toml:"viceroy"`
// WasmMetadata represents what metadata will be collected.
WasmMetadata WasmMetadata `toml:"wasm-metadata"`

// We store off a possible legacy configuration so that we can later extract
// the relevant email and token values that may pre-exist.
Expand Down

0 comments on commit db01ef9

Please sign in to comment.