-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprovision.go
43 lines (34 loc) · 963 Bytes
/
provision.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package k6exec
import (
"context"
"log/slog"
"strings"
"github.com/grafana/k6deps"
"github.com/grafana/k6provider"
)
func provision(ctx context.Context, deps k6deps.Dependencies, opts *Options) (string, error) {
config := k6provider.Config{}
if opts != nil {
config.BuildServiceURL = opts.BuildServiceURL
config.BuildServiceAuth = opts.BuildServiceToken
}
provider, err := k6provider.NewProvider(config)
if err != nil {
return "", err
}
slog.Debug("fetching binary", "build service URL: ", opts.BuildServiceURL)
binary, err := provider.GetBinary(ctx, deps)
if err != nil {
return "", err
}
// Cut the query string from the download URL to reduce noise in the logs
downloadURL, _, _ := strings.Cut(binary.DownloadURL, "?")
slog.Debug("binary fetched",
"Path: ", binary.Path,
"dependencies", deps.String(),
"checksum", binary.Checksum,
"cached", binary.Cached,
"download URL", downloadURL,
)
return binary.Path, nil
}