command

package
v1.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Docker = &Dependency{
	name:    "Docker",
	command: "docker",
	assist: func() error {
		return fmt.Errorf("docker is required to run this command. For installation instructions see: https://docs.docker.com/engine/install/")
	},
}
View Source
var Pulumi = &Dependency{
	name:    "Pulumi",
	command: "pulumi",
	assist: func() error {
		var resp bool
		_ = survey.AskOne(&survey.Confirm{
			Message: fmt.Sprintf("Pulumi is required by %s but is not installed, would you like to install it?", "command"),
			Default: false,
		}, &resp)

		if !resp {
			return fmt.Errorf("pulumi is required to run this command. For installation instructions see: https://www.pulumi.com/docs/get-started/install/")
		}

		var installErr error
		platform := runtime.GOOS
		switch platform {
		case "darwin", "linux":
			cmd := exec.Command("sh", "-c", "curl -fsSL https://get.pulumi.com | sh")
			cmd.Stdout = os.Stdout
			installErr = cmd.Run()
		case "windows":
			cmd := exec.Command("powershell", "-NoProfile", "-InputFormat", "None", "-ExecutionPolicy", "Bypass", "-Command", "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; iex ((New-Object System.Net.WebClient).DownloadString('https://get.pulumi.com/install.ps1'))")
			cmd.Stdout = os.Stdout
			installErr = cmd.Run()
			if installErr == nil {
				cmd := exec.Command("powershell", "SET", "PATH='%PATH%;%USERPROFILE%\\.pulumi\\bin'")
				cmd.Stdout = os.Stdout
				installErr = cmd.Run()
			}
		default:
			installErr = fmt.Errorf("platform %s not supported", platform)
		}

		return installErr
	},
}

Functions

func AddDependencyCheck

func AddDependencyCheck(cmd *cobra.Command, deps ...*Dependency) *cobra.Command

AddDependencyCheck - Wraps a cobra command with a pre-run that will check for dependencies

Types

type Dependency

type Dependency struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL