From 52b4f05709658770299331a71ca36faacebea560 Mon Sep 17 00:00:00 2001 From: j3ssie Date: Mon, 6 Apr 2026 23:09:01 +0800 Subject: [PATCH] feat: auto-install pulumi cli and adjust ssh retry configuration - Auto-install Pulumi CLI when not found instead of returning error - Add installed binary to PATH for immediate availability - Update SSH pool retry config to 5 attempts with 10s fixed delays - Improve user feedback with progress indicators --- internal/cloud/pulumi.go | 22 +++++++++++++++++++++- internal/runner/ssh_pool.go | 8 ++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/internal/cloud/pulumi.go b/internal/cloud/pulumi.go index 72c9cf4..0679f66 100644 --- a/internal/cloud/pulumi.go +++ b/internal/cloud/pulumi.go @@ -169,5 +169,25 @@ func ensurePulumiInstalled() error { } } - return fmt.Errorf("pulumi CLI not found - install via: curl -fsSL https://get.pulumi.com | sh") + // Auto-install Pulumi CLI + fmt.Println(" ▷ Pulumi CLI not found, installing automatically...") + installCmd := exec.Command("bash", "-c", "curl -fsSL https://get.pulumi.com | sh") + installCmd.Stdout = os.Stdout + installCmd.Stderr = os.Stderr + if err := installCmd.Run(); err != nil { + return fmt.Errorf("failed to install pulumi CLI: %w", err) + } + + // Add the installed pulumi to PATH + pulumiPath := filepath.Join(os.Getenv("HOME"), ".pulumi", "bin", "pulumi") + if _, err := os.Stat(pulumiPath); err == nil { + currentPath := os.Getenv("PATH") + if err := os.Setenv("PATH", filepath.Dir(pulumiPath)+":"+currentPath); err != nil { + return fmt.Errorf("failed to set PATH: %w", err) + } + fmt.Println(" ✓ Pulumi CLI installed successfully") + return nil + } + + return fmt.Errorf("pulumi CLI installation completed but binary not found at %s", pulumiPath) } diff --git a/internal/runner/ssh_pool.go b/internal/runner/ssh_pool.go index 3cb555d..28e4f32 100644 --- a/internal/runner/ssh_pool.go +++ b/internal/runner/ssh_pool.go @@ -143,10 +143,10 @@ func (p *SSHPool) Get(ctx context.Context, config *core.RunnerConfig) (*ssh.Clie addr := fmt.Sprintf("%s:%d", config.Host, port) var client *ssh.Client err = retry.Do(ctx, retry.Config{ - MaxAttempts: 3, - InitialDelay: 500 * time.Millisecond, - MaxDelay: 5 * time.Second, - Multiplier: 2.0, + MaxAttempts: 5, + InitialDelay: 10 * time.Second, + MaxDelay: 10 * time.Second, + Multiplier: 1.0, }, func() error { var dialErr error client, dialErr = ssh.Dial("tcp", addr, sshConfig)