8000 feat(telemetry): add wasm-tools wasm binary annotations by Integralist · Pull Request #1016 · fastly/cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(telemetry): add wasm-tools wasm binary annotations #1016

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

Merged
merged 60 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
4403980
refactor(main): simplify/clean-up flow
Integralist Sep 19, 2023
a37fd6b
refactor: pass wasmtools versioner throughout codebase
Integralist Sep 19, 2023
d0ff38b
refactor(version): clarify versioner used
Integralist Sep 19, 2023
e98f808
refactor(compute/init): sort flags
Integralist Sep 19, 2023
c61fe49
refactor: move InstallDir to github package
Integralist Sep 19, 2023
68d117c
refactor: move setBinPerms to github package
Integralist Sep 19, 2023
c8055f4
remove(compute/init): wasm-tools
Integralist Sep 19, 2023
589a289
feat: add wasm-tools versioner
Integralist Sep 19, 2023
d51b4e9
feat: add skeleton wasm-tools annotation
Integralist Sep 20, 2023
241c267
feat: add more data to wasm-tools annotation
Integralist Sep 20, 2023
b5cff86
feat: support data collection for all languages
Integralist Sep 20, 2023
8f66512
remove(config): don't increment version
Integralist Sep 20, 2023
5777ce5
fix(telemetry): disable unless hidden flag is set
Integralist Sep 20, 2023
6ecb888
fix(compute/test): ignore enable-telemetry flag
Integralist Sep 20, 2023
7bb89e7
feat(telemetry): disable telemetry via env var
Integralist Sep 20, 2023
0ac476a
debugging
Integralist Sep 20, 2023
bfbddb8
fix(compute/build): fix broken ci test
Integralist Sep 21, 2023
7939982
debugging
Integralist Sep 21, 2023
dfc8cd8
fix(compute/build): fix broken ci test
Integralist Sep 21, 2023
66e23e4
Revert "debugging"
Integralist Sep 21, 2023
b825e0a
Revert "debugging"
Integralist Sep 21, 2023
3832fd3
feat(telemetry): track starter kit
Integralist Sep 22, 2023
aa77a7e
feat(telemetry): capture imports for Go/Rust from source files
Integralist Sep 22, 2023
6fdce44
feat(telemetry): add --show-metadata to compute build
Integralist Sep 22, 2023
9613524
fix: remove temporary path
Integralist Sep 22, 2023
713759c
refactor(env): replace SplitN with Cut
Integralist Sep 22, 2023
c971741
feat(telemetry): parse JavaScript imports
Integralist Sep 22, 2023
c44f76f
refactor(compute/build): namespace metadata
Integralist Sep 22, 2023
a1b5299
remove: Imports()
Integralist Sep 26, 2023
39fa5cc
refactor: rename env var to disable wasm metadata collection
Integralist Sep 26, 2023
0032563
fix(compute/build): switch metadata from go.sum to go.mod
Integralist Sep 26, 2023
944ec5f
feat: set only CLI version in metadata when metadata disabled
Integralist Sep 26, 2023
847530f
fix: move placement of wasmtools install
Integralist Sep 26, 2023
0fafb8b
fix: compute tests
Integralist Sep 26, 2023
a5de50c
fix: Windows test
Integralist Sep 26, 2023
b966c72
debugging windows
Integralist Sep 27, 2023
d9cc287
refactor: annotate public methods
Integralist Sep 28, 2023
f38ecc9
refactor(compute/build): use gomod parser
Integralist Oct 2, 2023
b71aae0
refactor(compute/build): use processed-by flag for CLI version
Integralist Oct 2, 2023
4dc42e1
refactor(compute/build): replace individual flags with single json data
Integralist Oct 2, 2023
a354830
fix(compute/build): record only current memory allocation
Integralist Oct 3, 2023
7b1d175
fix(compute/build): invert conditional and move show-metadata
Integralist Oct 3, 2023
4bfedd5
fix(compute/build): don't hide show-metadata flag
Integralist Oct 3, 2023
d4d2133
feat(compute/build): display IMPORTANT message related to wasm-tools
Integralist Oct 6, 2023
1c21f6e
feat(compute/build): filter specified env vars
Integralist Oct 9, 2023
52f543d
fix(compute/build): add new flag to test suite
Integralist Oct 9, 2023
1698c51
fix(compute/build): fix formatting line breaks + use correct CPU value
Integralist Oct 10, 2023
23a4be1
temp
Integralist Oct 10, 2023
a0759aa
refactor(compute/build): clean-up debug log
Integralist Oct 13, 2023
d55dde6
fix(compute/build): trufflehog
Integralist Oct 13, 2023
4015fa9
fix(compute/build): only display secrets result once
Integralist Oct 16, 2023
e4de2fd
doc(compute/build): annotate Result type
Integralist Oct 17, 2023
9293a10
fix(compute/init): prevent runtime panic by removing duplicate flag
Integralist Oct 17, 2023
8a06635
fix(compute): add ignore rules for new build flag to existing tests
Integralist Oct 18, 2023
f4be458
refactor(compute/build): clean-up annotation logic
Integralist Oct 25, 2023
53db118
feat(compute/build): better secret scrubbing
Integralist Oct 25, 2023
ccb0ee3
fix: add missing metadata flags to composite commands
Integralist Oct 25, 2023
1099ab1
fix(compute/hashsum): pass correct variable
Integralist Oct 25, 2023
16095fe
fix: correct main package after bad rebase
Integralist Oct 31, 2023
64c2230
fix(compute/build): avoid empty config value
Integralist Oct 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .fastly/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ toolchain_constraint_tinygo = ">= 1.18" # Go toolchain constraint for use wit
toolchain_constraint = ">= 1.56.1"
wasm_wasi_target = "wasm32-wasi"

[wasm-tools]
ttl = "24h"

[viceroy]
ttl = "24h"
2 changes: 1 addition & 1 deletion .github/workflows/pr_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
shell: bash
env:
# NOTE: The following lets us focus the test run while debugging.
# TEST_ARGS: "-run TestDeploy ./pkg/commands/compute/..."
# TEST_ARGS: "-run TestBuild ./pkg/commands/compute/..."
TEST_COMPUTE_INIT: true
TEST_COMPUTE_BUILD: true
TEST_COMPUTE_DEPLOY: true
Expand Down
104 changes: 51 additions & 53 deletions cmd/fastly/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import (
"io"
"net/http"
"os"
"strings"
"time"

"github.com/fastly/go-fastly/v8/fastly"
"github.com/fatih/color"

"github.com/fastly/cli/pkg/api"
"github.com/fastly/cli/pkg/app"
"github.com/fastly/cli/pkg/commands/compute"
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/env"
fsterr "github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/github"
"github.com/fastly/cli/pkg/manifest"
Expand All @@ -21,38 +24,34 @@ import (
)

func main() {
// Some configuration options can come from env vars.
var env config.Environment
env.Read(parseEnv(os.Environ()))
// Parse the arguments provided by the user via the command-line interface.
args := os.Args[1:]

// All of the work of building the set of commands and subcommands, wiring
// them together, picking which one to call, and executing it, occurs in a
// helper function, Run. We parameterize all of the dependencies so we can
// test it more easily. Here, we declare all of the dependencies, using
// the "real" versions that pull e.g. actual commandline arguments, the
// user's real environment, etc.
// Define a HTTP client that will be used for making arbitrary HTTP requests.
httpClient := &http.Client{Timeout: time.Minute * 2}

// Define the standard input/output streams.
var (
args = os.Args[1:]
clientFactory = app.FastlyAPIClient
httpClient = &http.Client{Timeout: time.Minute * 2}
in io.Reader = os.Stdin
out io.Writer = sync.NewWriter(color.Output)
in io.Reader = os.Stdin
out io.Writer = sync.NewWriter(color.Output)
)

// We have to manually handle the inclusion of the verbose flag here because
// Kingpin doesn't evaluate the provided arguments until app.Run which
// happens later in the file and yet we need to know if we should be printing
// output related to the application configuration file in this file.
// Read relevant configuration options from the user's environment.
var e config.Environment
e.Read(env.Parse(os.Environ()))

// Identify verbose flag early (before Kingpin parser has executed) so we can
// print additional output related to the CLI configuration.
var verboseOutput bool
for _, seg := range args {
if seg == "-v" || seg == "--verbose" {
verboseOutput = true
}
}

// Similarly for the --auto-yes/--non-interactive flags, we need access to
// these for handling interactive error prompts to the user, in case the CLI
// is being run in a CI environment.
// Identify auto-yes/non-interactive flag early (before Kingpin parser has
// executed) so we can handle the interactive prompts appropriately with
// regards to processing the CLI configuration.
var autoYes, nonInteractive bool
for _, seg := range args {
if seg == "-y" || seg == "--auto-yes" {
Expand All @@ -63,20 +62,19 @@ func main() {
}
}

// Extract a subset of configuration options from the local application directory.
// Extract a subset of configuration options from the local app directory.
var cfg config.File
cfg.SetAutoYes(autoYes)
cfg.SetNonInteractive(nonInteractive)

// The CLI relies on a valid configuration, otherwise we can't continue.
err := cfg.Read(config.FilePath, in, out, fsterr.Log, verboseOutput)
if err != nil {
fsterr.Deduce(err).Print(color.Error)

// WARNING: os.Exit will exit, and any `defer` calls will not be run.
os.Exit(1)
}

// Extract user's project configuration from the fastly.toml manifest.
var md manifest.Data
md.File.Args = args
md.File.SetErrLog(fsterr.Log)
Expand All @@ -85,18 +83,25 @@ func main() {
// NOTE: We skip handling the error because not all commands relate to Compute.
_ = md.File.Read(manifest.Filename)

// Main is basically just a shim to call Run, so we do that here.
opts := app.RunOpts{
APIClient: clientFactory,
Args: args,
ConfigFile: cfg,
ConfigPath: config.FilePath,
Env: env,
ErrLog: fsterr.Log,
HTTPClient: httpClient,
Manifest: &md,
Stdin: in,
Stdout: out,
// The `main` function is a shim for calling `app.Run()`.
err = app.Run(app.RunOpts{
APIClient: func(token, endpoint string, debugMode bool) (api.Interface, error) {
client, err := fastly.NewClientForEndpoint(token, endpoint)
if debugMode {
client.DebugMode = true
}
return client, err
},
Args: args,
ConfigFile: cfg,
ConfigPath: config.FilePath,
Env: e,
ErrLog: fsterr.Log,
ExecuteWasmTools: compute.ExecuteWasmTools,
HTTPClient: httpClient,
Manifest: &md,
Stdin: in,
Stdout: out,
Versioners: app.Versioners{
CLI: github.New(github.Opts{
HTTPClient: httpClient,
Expand All @@ -111,9 +116,16 @@ func main() {
Binary: "viceroy",
Version: md.File.LocalServer.ViceroyVersion,
}),
WasmTools: github.New(github.Opts{
HTTPClient: httpClient,
Org: "bytecodealliance",
Repo: "wasm-tools",
Binary: "wasm-tools",
External: true,
Nested: true,
}),
},
}
err = app.Run(opts)
})

// NOTE: We persist any error log entries to disk before attempting to handle
// a possible error response from app.Run as there could be errors recorded
Expand All @@ -124,7 +136,6 @@ func main() {
if logErr != nil {
fsterr.Deduce(logErr).Print(color.Error)
}

if err != nil {
text.Break(out)
fsterr.Deduce(err).Print(color.Error)
Expand All @@ -137,16 +148,3 @@ func main() {
os.Exit(1)
}
}

func parseEnv(environ []string) map[string]string {
env := map[string]string{}
for _, kv := range environ {
toks := strings.SplitN(kv, "=", 2)
if len(toks) != 2 {
continue
}
k, v := toks[0], toks[1]
env[k] = v
}
return env
}
Loading
0