-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(compute): add metadata
subcommand
#1013
Merged
Merged
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
492021f
feat(telemetry): add telemetry command
Integralist a3868f1
refactor(telemetry): enable by default
Integralist 38d64bc
doc(DEVELOP): clarify the app config flows
Integralist ac7293e
doc(config): annotate File fields
Integralist e241978
feat: display telemetry to user on first run after install or update
Integralist 3c632e1
fix(ci): add /dev/null equivalent for Windows
Integralist c0586e0
refactor: rename telemetry wasm-metadata
Integralist 8d6673f
refactor: move `telemetry` command to `compute metadata`
Integralist 58c96f4
refactor(compute/metadata): display updated config settings
Integralist 849e7db
fix(metadata): machine info must be opt-in
Integralist cc4d645
fix(compute/metadata): reference correct error type
Integralist 7551b2d
remove(telemetry): command moved to compute metadata.
Integralist 9f5b4dd
fix(compute/build): remove unused arg
Integralist 265cc0f
fix(app): update commandCollectsData() list
Integralist fc49e5b
feat: only record metadata for items marked as enabled
Integralist 4afd2ee
fix(app): hide metadata message unless the user has opted into data c…
Integralist 3705675
refactor: messaging to include additional links
Integralist 00feb73
refactor(compute/metadata): make a hidden command for now
Integralist e35ebba
refactor: move sdk data into package_info
Integralist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package compute | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
|
||
"github.com/fastly/cli/pkg/cmd" | ||
"github.com/fastly/cli/pkg/config" | ||
fsterr "github.com/fastly/cli/pkg/errors" | ||
"github.com/fastly/cli/pkg/global" | ||
"github.com/fastly/cli/pkg/text" | ||
) | ||
|
||
// MetadataCommand controls what metadata is collected for a Wasm binary. | ||
type MetadataCommand struct { | ||
cmd.Base | ||
|
||
disable bool | ||
disableBuild bool | ||
disableMachine bool | ||
disablePackage bool | ||
enable bool | ||
enableBuild bool | ||
enableMachine bool | ||
enablePackage bool | ||
} | ||
|
||
// NewMetadataCommand returns a new command registered in the parent. | ||
func NewMetadataCommand(parent cmd.Registerer, g *global.Data) *MetadataCommand { | ||
var c MetadataCommand | ||
c.Globals = g | ||
c.CmdClause = parent.Command("metadata", "Control what metadata is collected") | ||
c.CmdClause.Flag("disable", "Disable all metadata").BoolVar(&c.disable) | ||
c.CmdClause.Flag("disable-build", "Disable metadata for information regarding the time taken for builds and compilation processes").BoolVar(&c.disableBuild) | ||
c.CmdClause.Flag("disable-machine", "Disable metadata for general, non-identifying system specifications (CPU, RAM, operating system)").BoolVar(&c.disableMachine) | ||
c.CmdClause.Flag("disable-package", "Disable metadata for packages and libraries utilized in your source code").BoolVar(&c.disablePackage) | ||
c.CmdClause.Flag("enable", "Enable all metadata").BoolVar(&c.enable) | ||
c.CmdClause.Flag("enable-build", "Enable metadata for information regarding the time taken for builds and compilation processes").BoolVar(&c.enableBuild) | ||
c.CmdClause.Flag("enable-machine", "Enable metadata for general, non-identifying system specifications (CPU, RAM, operating system)").BoolVar(&c.enableMachine) | ||
c.CmdClause.Flag("enable-package", "Enable metadata for packages and libraries utilized in your source code").BoolVar(&c.enablePackage) | ||
return &c | ||
} | ||
|
||
// Exec implements the command interface. | ||
func (c *MetadataCommand) Exec(_ io.Reader, out io.Writer) error { | ||
if c.disable && c.enable { | ||
return fsterr.ErrInvalidEnableDisableFlagCombo | ||
} | ||
if c.disable { | ||
c.Globals.Config.WasmMetadata = toggleAll("disable") | ||
} | ||
if c.enable { | ||
c.Globals.Config.WasmMetadata = toggleAll("enable") | ||
} | ||
if c.disable && (c.enableBuild || c.enableMachine || c.enablePackage) { | ||
text.Info(out, "We will disable all metadata except for the specified `--enable-*` flags") | ||
text.Break(out) | ||
} | ||
if c.enable && (c.disableBuild || c.disableMachine || c.disablePackage) { | ||
text.Info(out, "We will enable all metadata except for the specified `--disable-*` flags") | ||
text.Break(out) | ||
} | ||
if c.enableBuild { | ||
c.Globals.Config.WasmMetadata.BuildInfo = "enable" | ||
} | ||
if c.enableMachine { | ||
c.Globals.Config.WasmMetadata.MachineInfo = "enable" | ||
} | ||
if c.enablePackage { | ||
c.Globals.Config.WasmMetadata.PackageInfo = "enable" | ||
} | ||
if c.disableBuild { | ||
c.Globals.Config.WasmMetadata.BuildInfo = "disable" | ||
} | ||
if c.disableMachine { | ||
c.Globals.Config.WasmMetadata.MachineInfo = "disable" | ||
} | ||
if c.disablePackage { | ||
c.Globals.Config.WasmMetadata.PackageInfo = "disable" | ||
} | ||
err := c.Globals.Config.Write(c.Globals.ConfigPath) | ||
if err != nil { | ||
return fmt.Errorf("failed to persist metadata choices to disk: %w", err) | ||
} | ||
text.Success(out, "configuration updated (see: `fastly config`)") | ||
Integralist marked this conversation as resolved.
Show resolved
Hide resolved
|
||
text.Break(out) | ||
text.Output(out, "Build Information: %s", c.Globals.Config.WasmMetadata.BuildInfo) | ||
text.Output(out, "Machine Information: %s", c.Globals.Config.WasmMetadata.MachineInfo) | ||
text.Output(out, "Package Information: %s", c.Globals.Config.WasmMetadata.PackageInfo) | ||
return nil | ||
} | ||
|
||
func toggleAll(state string) config.WasmMetadata { | ||
var t config.WasmMetadata | ||
t.BuildInfo = state | ||
t.MachineInfo = state | ||
t.PackageInfo = state | ||
return t | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaskiratr we'll need an actual URL here (or should this be https://bit.ly/wasm-metadata which points to our community forum thread on the topic)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll update the CLI reference page with the information about what data is being collected, why, and how to disable it