Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit acac8b9

Browse files
committed
Add detection of k6 cloud run
LaunchOptions will ignore some options while running on the cloud. CloudRun function is in the k6ext/cloud.go; in the future, we can add more cloud related functionalities in the file. I didn't want to put it in a generic file like helpers.go (anti-pattern).
1 parent 2781551 commit acac8b9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

chromium/browser_type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (b *BrowserType) Launch(opts goja.Value) api.Browser {
132132
k6ext.Panic(ctx, "setting up logger: %w", err)
133133
}
134134

135-
launchOpts := common.NewLaunchOptions(false)
135+
launchOpts := common.NewLaunchOptions(k6ext.OnCloud())
136136
if err := launchOpts.Parse(ctx, opts, b.logger); err != nil {
137137
k6ext.Panic(ctx, "parsing launch options: %w", err)
138138
}

k6ext/cloud.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package k6ext
2+
3+
import "os"
4+
5+
// OnCloud returns true if xk6-browser runs in the cloud.
6+
func OnCloud() bool {
7+
_, ok := os.LookupEnv("K6_CLOUDRUN_INSTANCE_ID")
8+
return ok
9+
}

0 commit comments

Comments
 (0)