66 "fmt"
77 "os"
88 "path/filepath"
9+ "strings"
910
1011 "github.com/ava-labs/avalanche-cli/pkg/ansible"
1112 "github.com/ava-labs/avalanche-cli/pkg/application"
@@ -29,13 +30,14 @@ import (
2930)
3031
3132var (
32- loadTestRepoURL string
33- loadTestBuildCmd string
34- loadTestCmd string
35- loadTestRepoCommit string
36- repoDirName string
37- loadTestHostRegion string
38- loadTestBranch string
33+ loadTestRepoURL string
34+ loadTestBuildCmd string
35+ loadTestCmd string
36+ loadTestRepoCommit string
37+ repoDirName string
38+ loadTestHostRegion string
39+ loadTestBranch string
40+ loadTestDeployKeyPath string
3941)
4042
4143type clusterInfo struct {
@@ -80,6 +82,7 @@ The command will then run the load test binary based on the provided load test r
8082 cmd .Flags ().StringVar (& loadTestCmd , "load-test-cmd" , "" , "command to run load test" )
8183 cmd .Flags ().StringVar (& loadTestHostRegion , "region" , "" , "create load test node in a given region" )
8284 cmd .Flags ().StringVar (& loadTestBranch , "load-test-branch" , "" , "load test branch or commit" )
85+ cmd .Flags ().StringVar (& loadTestDeployKeyPath , "load-test-deploy-key" , "" , "path to SSH deploy key for private repository access" )
8386 return cmd
8487}
8588
@@ -357,6 +360,20 @@ func startLoadTest(_ *cobra.Command, args []string) error {
357360 }
358361
359362 ux .Logger .GreenCheckmarkToUser ("Load test environment is ready!" )
363+
364+ // Setup deploy key for private repository access if provided
365+ if loadTestDeployKeyPath != "" {
366+ ux .Logger .PrintToUser ("%s Setting up deploy key for private repository" , logging .Green .Wrap (">" ))
367+ if err := ssh .RunSSHSetupDeployKey (currentLoadTestHost [0 ], loadTestDeployKeyPath ); err != nil {
368+ return fmt .Errorf ("failed to setup deploy key for private repository: %w" , err )
369+ }
370+
371+ // Update repository URL to use SSH config if it's a GitHub SSH URL
372+ if strings .HasPrefix (loadTestRepoURL , "git@github.com:" ) {
373+ loadTestRepoURL = strings .Replace (loadTestRepoURL , "git@github.com:" , "git@github.com-avalanche:" , 1 )
374+ }
375+ }
376+
360377 ux .Logger .PrintToUser ("%s Building load test code" , logging .Green .Wrap (">" ))
361378 if err := ssh .RunSSHBuildLoadTestCode (currentLoadTestHost [0 ], loadTestRepoURL , loadTestBuildCmd , loadTestRepoCommit , repoDirName , loadTestBranch , checkoutCommit ); err != nil {
362379 return err
0 commit comments