Skip to content

Commit 5340643

Browse files
private repo
1 parent 8dd5d1d commit 5340643

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

cmd/nodecmd/load_test_start.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ func GetLoadTestScript(app *application.Avalanche) error {
502502
var err error
503503
if loadTestRepoURL != "" {
504504
ux.Logger.PrintToUser("Checking source code repository URL %s", loadTestRepoURL)
505-
if err := prompts.ValidateURL(loadTestRepoURL); err != nil {
505+
if err := validateRepositoryURL(loadTestRepoURL); err != nil {
506506
ux.Logger.PrintToUser("Invalid repository url %s: %s", loadTestRepoURL, err)
507507
loadTestRepoURL = ""
508508
}
@@ -551,3 +551,23 @@ func getExistingLoadTestInstance(clusterName, loadTestName string) (string, erro
551551
}
552552
return "", nil
553553
}
554+
555+
// validateRepositoryURL validates both HTTP and SSH repository URLs
556+
func validateRepositoryURL(url string) error {
557+
// Check if it's an SSH URL (git@host:path format)
558+
if strings.HasPrefix(url, "git@") && strings.Contains(url, ":") {
559+
// Basic SSH URL validation
560+
parts := strings.Split(url, ":")
561+
if len(parts) != 2 {
562+
return fmt.Errorf("invalid SSH URL format")
563+
}
564+
hostPart := strings.TrimPrefix(parts[0], "git@")
565+
if hostPart == "" || parts[1] == "" {
566+
return fmt.Errorf("invalid SSH URL format")
567+
}
568+
return nil
569+
}
570+
571+
// For HTTP/HTTPS URLs, use the existing validation
572+
return prompts.ValidateURL(url)
573+
}

pkg/ssh/shell/setupDeployKey.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ chmod 700 ~/.ssh
1111
# The key should already be at ~/.ssh/avalanche-deploy-key
1212

1313
# Set proper permissions for the deploy key
14-
chmod 600 ~/.ssh/avalanche-deploy-key
14+
chmod 600 /home/ubuntu/.ssh/avalanche-deploy-key
1515

1616
# Configure SSH to use the deploy key
1717
cat >> ~/.ssh/config <<'EOF'
1818
Host github.com-avalanche
1919
HostName github.com
2020
User git
21-
IdentityFile ~/.ssh/avalanche-deploy-key
21+
IdentityFile /home/ubuntu/.ssh/avalanche-deploy-key
2222
IdentitiesOnly yes
2323
StrictHostKeyChecking accept-new
2424
EOF

pkg/ssh/ssh.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,8 @@ func RunSSHSetupDeployKey(host *models.Host, deployKeyPath string) error {
834834
}
835835

836836
// Upload the deploy key first
837-
remoteDeployKeyPath := "~/.ssh/avalanche-deploy-key"
837+
remoteDeployKeyPath := "/home/ubuntu/.ssh/avalanche-deploy-key"
838+
838839
if err := host.Upload(expandedPath, remoteDeployKeyPath, constants.SSHFileOpsTimeout); err != nil {
839840
return fmt.Errorf("failed to upload deploy key: %w", err)
840841
}
@@ -851,12 +852,16 @@ func RunSSHSetupDeployKey(host *models.Host, deployKeyPath string) error {
851852

852853
// expandTilde expands ~ to the user's home directory
853854
func expandTilde(path string) (string, error) {
854-
if strings.HasPrefix(path, "~/") {
855+
if strings.HasPrefix(path, "~") {
855856
homeDir, err := os.UserHomeDir()
856857
if err != nil {
857858
return "", err
858859
}
859-
return filepath.Join(homeDir, path[2:]), nil
860+
// Handle both ~/ and ~ cases
861+
if len(path) == 1 {
862+
return homeDir, nil
863+
}
864+
return filepath.Join(homeDir, path[1:]), nil
860865
}
861866
return path, nil
862867
}

pkg/utils/common.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,19 @@ func GetIndexInSlice[T comparable](list []T, element T) (int, error) {
270270
// Example: https://github.com/ava-labs/hypersdk/pull/772/commits/b88acfb370f5aeb83a000aece2d72f28154410a5
271271
// Should return https://github.com/ava-labs/hypersdk
272272
func GetRepoFromCommitURL(gitRepoURL string) (string, string) {
273+
// Handle SSH URLs (git@host:path format)
274+
if strings.HasPrefix(gitRepoURL, "git@") && strings.Contains(gitRepoURL, ":") {
275+
parts := strings.Split(gitRepoURL, ":")
276+
if len(parts) == 2 {
277+
// Extract repo name from path (remove .git suffix if present)
278+
// For git@github.com:owner/repo.git, we want just "repo"
279+
pathParts := strings.Split(parts[1], "/")
280+
repoName := strings.TrimSuffix(pathParts[len(pathParts)-1], ".git")
281+
return gitRepoURL, repoName
282+
}
283+
}
284+
285+
// Handle HTTP/HTTPS URLs
273286
splitURL := strings.Split(gitRepoURL, "/")
274287
if len(splitURL) > 4 {
275288
// get first five members of splitURL because it will be [ https, ' ', github.com, ava-labs, hypersdk]

0 commit comments

Comments
 (0)