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
This commit is contained in:
j3ssie
2026-04-06 23:09:01 +08:00
parent 69e3be23eb
commit 52b4f05709
2 changed files with 25 additions and 5 deletions
+21 -1
View File
@@ -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)
}
+4 -4
View File
@@ -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)