-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
858 additions
and
3 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,6 @@ go.work.sum | |
|
||
# env file | ||
.env | ||
|
||
# binary | ||
/roc |
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 |
---|---|---|
@@ -1,2 +1,69 @@ | ||
# cli | ||
CLI for RunsOn | ||
# roc | ||
|
||
RunsOn CLI (`roc`) is a command line tool to manage and troubleshoot your [RunsOn](https://runs-on.com) installation. | ||
|
||
## Features | ||
|
||
### `roc connect` | ||
|
||
Connect to the instance running a specific job via SSM, by just pasting the GitHub Actions job URL or ID. | ||
|
||
This feature requires the [AWS Session Manager plugin](https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html) to be installed on your local machine. | ||
|
||
``` | ||
Usage: | ||
roc connect JOB_ID|JOB_URL [flags] | ||
Flags: | ||
--debug Enable debug output | ||
-h, --help help for connect | ||
--watch Wait for instance ID if not found | ||
Global Flags: | ||
--stack string CloudFormation stack name (default "runs-on") | ||
``` | ||
|
||
Example: | ||
|
||
```bash | ||
roc connect https://github.com/runs-on/runs-on/actions/runs/12415485296/job/34661958899 | ||
``` | ||
|
||
## `roc logs` | ||
|
||
Fetch RunsOn server and instance logs for a specific job ID or URL. | ||
|
||
``` | ||
Usage: | ||
roc logs JOB_ID|JOB_URL [flags] | ||
Flags: | ||
-d, --debug Enable debug output | ||
-h, --help help for logs | ||
-s, --since string Show logs since duration (e.g. 30m, 2h) (default "2h") | ||
-w, --watch string[="5s"] Watch for new logs with optional interval (e.g. --watch 2s) | ||
Global Flags: | ||
--stack string CloudFormation stack name (default "runs-on") | ||
``` | ||
|
||
Example: | ||
|
||
```bash | ||
roc logs https://github.com/runs-on/runs-on/actions/runs/12415485296/job/34661958899 --watch | ||
``` | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! Ideas of future improvements: | ||
|
||
* Make the CloudFormation stack create an IAM role for the CLI to use, so that the CLI automatically assumes it when launched with an admin role? | ||
* `roc stack doctor` - check RunsOn stack and make sure everything is healthy (AppRunner endpoint health check, GitHub App webhook deliveries, etc.). | ||
* `roc stack pause|resume` - set RunsOn in maintenance mode (queue incoming jobs, but don't start them), to perform an upgrade. | ||
* `roc stack upgrade` - upgrade RunsOn stack to the latest version. | ||
* `roc stack logs` - fetch RunsOn server logs. | ||
* `roc cache [list|clear]` - list or clear cached data for a specific repository. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
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,36 @@ | ||
module roc | ||
|
||
go 1.23.4 | ||
|
||
require ( | ||
github.com/aws/aws-sdk-go-v2 v1.32.8 | ||
github.com/aws/aws-sdk-go-v2/config v1.28.10 | ||
github.com/aws/aws-sdk-go-v2/service/cloudformation v1.56.4 | ||
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.45.3 | ||
github.com/aws/aws-sdk-go-v2/service/s3 v1.72.2 | ||
github.com/aws/aws-sdk-go-v2/service/ssm v1.56.4 | ||
github.com/google/go-github/v66 v66.0.0 | ||
github.com/spf13/cobra v1.8.1 | ||
) | ||
|
||
require ( | ||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 // indirect | ||
github.com/aws/aws-sdk-go-v2/credentials v1.17.51 // indirect | ||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.23 // indirect | ||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.27 // indirect | ||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.27 // indirect | ||
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect | ||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.27 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.8 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.8 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.8 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/sso v1.24.9 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.8 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/sts v1.33.6 // indirect | ||
github.com/aws/smithy-go v1.22.1 // indirect | ||
github.com/google/go-querystring v1.1.0 // indirect | ||
github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||
github.com/jmespath/go-jmespath v0.4.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
) |
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,71 @@ | ||
github.com/aws/aws-sdk-go-v2 v1.32.8 h1:cZV+NUS/eGxKXMtmyhtYPJ7Z4YLoI/V8bkTdRZfYhGo= | ||
github.com/aws/aws-sdk-go-v2 v1.32.8/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U= | ||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 h1:lL7IfaFzngfx0ZwUGOZdsFFnQ5uLvR0hWqqhyE7Q9M8= | ||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7/go.mod h1:QraP0UcVlQJsmHfioCrveWOC1nbiWUl3ej08h4mXWoc= | ||
github.com/aws/aws-sdk-go-v2/config v1.28.10 h1:fKODZHfqQu06pCzR69KJ3GuttraRJkhlC8g80RZ0Dfg= | ||
github.com/aws/aws-sdk-go-v2/config v1.28.10/go.mod h1:PvdxRYZ5Um9QMq9PQ0zHHNdtKK+he2NHtFCUFMXWXeg= | ||
github.com/aws/aws-sdk-go-v2/credentials v1.17.51 h1:F/9Sm6Y6k4LqDesZDPJCLxQGXNNHd/ZtJiWd0lCZKRk= | ||
github.com/aws/aws-sdk-go-v2/credentials v1.17.51/go.mod h1:TKbzCHm43AoPyA+iLGGcruXd4AFhF8tOmLex2R9jWNQ= | ||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.23 h1:IBAoD/1d8A8/1aA8g4MBVtTRHhXRiNAgwdbo/xRM2DI= | ||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.23/go.mod h1:vfENuCM7dofkgKpYzuzf1VT1UKkA/YL3qanfBn7HCaA= | ||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.27 h1:jSJjSBzw8VDIbWv+mmvBSP8ezsztMYJGH+eKqi9AmNs= | ||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.27/go.mod h1:/DAhLbFRgwhmvJdOfSm+WwikZrCuUJiA4WgJG0fTNSw= | ||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.27 h1:l+X4K77Dui85pIj5foXDhPlnqcNRG2QUyvca300lXh8= | ||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.27/go.mod h1:KvZXSFEXm6x84yE8qffKvT3x8J5clWnVFXphpohhzJ8= | ||
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= | ||
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= | ||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.27 h1:AmB5QxnD+fBFrg9LcqzkgF/CaYvMyU/BTlejG4t1S7Q= | ||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.27/go.mod h1:Sai7P3xTiyv9ZUYO3IFxMnmiIP759/67iQbU4kdmkyU= | ||
github.com/aws/aws-sdk-go-v2/service/cloudformation v1.56.4 h1:uH6So7Ee+2JQf+TKbfifXKUDNN0JfaJ6CgJ6Bh/u1sc= | ||
github.com/aws/aws-sdk-go-v2/service/cloudformation v1.56.4/go.mod h1:GdDLBO8SzD4wvQ6fhqU1QCmvG1waj1MPHL4cBtuSgdQ= | ||
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.45.3 h1:va7zt8/kkg5zR0TX2r7wCXssdZ4+blRxbsA6IS9XXYI= | ||
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.45.3/go.mod h1:CijDCaRp5sH8QM0LqImyzy5roG8cOtgp2Abj0V/4luk= | ||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 h1:iXtILhvDxB6kPvEXgsDhGaZCSC6LQET5ZHSdJozeI0Y= | ||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1/go.mod h1:9nu0fVANtYiAePIBh2/pFUSwtJ402hLnp854CNoDOeE= | ||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.8 h1:iwYS40JnrBeA9e9aI5S6KKN4EB2zR4iUVYN0nwVivz4= | ||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.8/go.mod h1:Fm9Mi+ApqmFiknZtGpohVcBGvpTu542VC4XO9YudRi0= | ||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.8 h1:cWno7lefSH6Pp+mSznagKCgfDGeZRin66UvYUqAkyeA= | ||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.8/go.mod h1:tPD+VjU3ABTBoEJ3nctu5Nyg4P4yjqSH5bJGGkY4+XE= | ||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.8 h1:/Mn7gTedG86nbpjT4QEKsN1D/fThiYe1qvq7WsBGNHg= | ||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.8/go.mod h1:Ae3va9LPmvjj231ukHB6UeT8nS7wTPfC3tMZSZMwNYg= | ||
github.com/aws/aws-sdk-go-v2/service/s3 v1.72.2 h1:a7aQ3RW+ug4IbhoQp29NZdc7vqrzKZZfWZSaQAXOZvQ= | ||
github.com/aws/aws-sdk-go-v2/service/s3 v1.72.2/go.mod h1:xMekrnhmJ5aqmyxtmALs7mlvXw5xRh+eYjOjvrIIFJ4= | ||
github.com/aws/aws-sdk-go-v2/service/ssm v1.56.4 h1:oXh/PjaKtStu7RkaUtuKX6+h/OxXriMa9WyQQhylKG0= | ||
github.com/aws/aws-sdk-go-v2/service/ssm v1.56.4/go.mod h1:IiHGbiFg4wVdEKrvFi/zxVZbjfEpgSe21N9RwyQFXCU= | ||
github.com/aws/aws-sdk-go-v2/service/sso v1.24.9 h1:YqtxripbjWb2QLyzRK9pByfEDvgg95gpC2AyDq4hFE8= | ||
github.com/aws/aws-sdk-go-v2/service/sso v1.24.9/go.mod h1:lV8iQpg6OLOfBnqbGMBKYjilBlf633qwHnBEiMSPoHY= | ||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.8 h1:6dBT1Lz8fK11m22R+AqfRsFn8320K0T5DTGxxOQBSMw= | ||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.8/go.mod h1:/kiBvRQXBc6xeJTYzhSdGvJ5vm1tjaDEjH+MSeRJnlY= | ||
github.com/aws/aws-sdk-go-v2/service/sts v1.33.6 h1:VwhTrsTuVn52an4mXx29PqRzs2Dvu921NpGk7y43tAM= | ||
github.com/aws/aws-sdk-go-v2/service/sts v1.33.6/go.mod h1:+8h7PZb3yY5ftmVLD7ocEoE98hdc8PoKS0H3wfx1dlc= | ||
github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro= | ||
github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= | ||
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= | ||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | ||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= | ||
github.com/google/go-github/v66 v66.0.0 h1:ADJsaXj9UotwdgK8/iFZtv7MLc8E8WBl62WLd/D/9+M= | ||
github.com/google/go-github/v66 v66.0.0/go.mod h1:+4SO9Zkuyf8ytMj0csN1NR/5OTR+MfqPp8P8dVlcvY4= | ||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= | ||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= | ||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= | ||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= | ||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= | ||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= | ||
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= | ||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= | ||
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= | ||
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= | ||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= | ||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= | ||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
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,120 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"log" | ||
"os" | ||
"os/exec" | ||
"syscall" | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/service/s3" | ||
"github.com/aws/aws-sdk-go-v2/service/ssm" | ||
"github.com/aws/aws-sdk-go-v2/service/ssm/types" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewConnectCmd() *cobra.Command { | ||
var debug bool | ||
var watch bool | ||
|
||
cmd := &cobra.Command{ | ||
Use: "connect JOB_ID|JOB_URL", | ||
Short: "Connect to the instance running a specific job via SSM", | ||
Args: cobra.ExactArgs(1), | ||
SilenceUsage: true, | ||
SilenceErrors: true, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
config, err := getStackOutputs(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
jobID := extractJobID(args[0]) | ||
ctx := cmd.Context() | ||
|
||
logger := log.New(io.Discard, "", 0) | ||
if debug { | ||
logger.SetOutput(cmd.OutOrStderr()) | ||
} | ||
|
||
s3Client := s3.NewFromConfig(config.AWSConfig) | ||
ssmClient := ssm.NewFromConfig(config.AWSConfig) | ||
|
||
// Get instance ID from S3 | ||
key := fmt.Sprintf("runs-on/db/jobs/%s/instance-id", jobID) | ||
var instanceID string | ||
|
||
for { | ||
out, err := s3Client.GetObject(ctx, &s3.GetObjectInput{ | ||
Bucket: &config.BucketConfig, | ||
Key: &key, | ||
}) | ||
if err != nil { | ||
if !watch { | ||
return fmt.Errorf("instance ID not found for job %s", jobID) | ||
} | ||
logger.Printf("Waiting for instance ID for job %s...\n", jobID) | ||
time.Sleep(5 * time.Second) | ||
continue | ||
} | ||
defer out.Body.Close() | ||
|
||
data, err := io.ReadAll(out.Body) | ||
if err != nil { | ||
return err | ||
} | ||
instanceID = string(data) | ||
break | ||
} | ||
|
||
// Check if instance is running | ||
describeInput := &ssm.DescribeInstanceInformationInput{ | ||
Filters: []types.InstanceInformationStringFilter{ | ||
{ | ||
Key: aws.String("InstanceIds"), | ||
Values: []string{instanceID}, | ||
}, | ||
}, | ||
} | ||
describeOutput, err := ssmClient.DescribeInstanceInformation(ctx, describeInput) | ||
if err != nil { | ||
return fmt.Errorf("failed to check instance status: %w", err) | ||
} | ||
if len(describeOutput.InstanceInformationList) == 0 { | ||
return fmt.Errorf("instance %s is not running or not registered with SSM", instanceID) | ||
} | ||
|
||
fmt.Printf("Connecting to instance %s...\n", instanceID) | ||
|
||
// Create session input for plugin | ||
region := config.AWSConfig.Region | ||
|
||
// Start session-manager-plugin | ||
awsPath, err := exec.LookPath("aws") | ||
if err != nil { | ||
return fmt.Errorf("aws CLI not found: %w", err) | ||
} | ||
|
||
// Check if SSM plugin is installed | ||
cmdSsm := exec.Command(awsPath, "ssm", "start-session", "help") | ||
if err := cmdSsm.Run(); err != nil { | ||
return fmt.Errorf("AWS Session Manager plugin not installed. Please install from https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html") | ||
} | ||
|
||
return syscall.Exec(awsPath, []string{ | ||
"aws", "ssm", "start-session", | ||
"--target", instanceID, | ||
"--region", region, | ||
"--document-name", "AWS-StartInteractiveCommand", | ||
"--parameters", "command='cd /home/runner && bash'", | ||
}, os.Environ()) | ||
}, | ||
} | ||
|
||
cmd.Flags().BoolVar(&debug, "debug", false, "Enable debug output") | ||
cmd.Flags().BoolVar(&watch, "watch", false, "Wait for instance ID if not found") | ||
return cmd | ||
} |
Oops, something went wrong.