dep

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotImplemented = errors.New("dep: not implemented")

ErrNotImplemented is the error returned if a method is not implemented.

Functions

func DefaultBinaryDir

func DefaultBinaryDir() string

DefaultBinaryDir returns default binary directory path.

Builds the binary directory path based on the OS's platform.

  • Linux/Unix: $HOME/.spotinst/bin
  • Windows: %USERPROFILE%\.spotinst\bin

Types

type Dependency

type Dependency interface {
	// Name returns the name of the dependency.
	Name() string

	// UpstreamBinaryName is the name of the dependency binary that we download.
	// Can be different from our dependency name.
	UpstreamBinaryName() string

	// Version returns the version of the dependency.
	Version() string

	// URL returns the download link of the dependency.
	URL() (*url.URL, error)

	// Extension returns the extension type of the dependency.
	Extension() string

	// Executable returns the name of the dependency executable.
	Executable() string
}

Dependency represents an executable package.

var (
	// See: https://kubernetes.io/docs/reference/kubectl.
	DependencyKubectl Dependency = &dependency{
		name:    "kubectl",
		version: "1.19.6",
		url: "https://storage.googleapis.com/kubernetes-release/" +
			"release/v{{.version}}/bin/{{.os}}/{{.arch}}/kubectl{{.extension}}",
	}

	// See: https://github.com/kubernetes/kops.
	DependencyKops Dependency = &dependency{
		name:    "kops",
		version: "1.27.0",
		url: "https://github.com/kubernetes/kops/releases/download/" +
			"v{{.version}}/kops-{{.os}}-{{.arch}}",
	}

	// Spot fork of eksctl
	// See: https://github.com/spotinst/weaveworks-eksctl.
	DependencyEksctlSpot Dependency = &dependency{
		name:               "eksctl-spot",
		upstreamBinaryName: "eksctl",
		version:            "0.149.0",
		url: "https://github.com/spotinst/weaveworks-eksctl/releases/download" +
			"/v{{.version}}/eksctl_{{.os}}_{{.arch}}.tar.gz",
	}
)

func DefaultDependencyListKubernetes

func DefaultDependencyListKubernetes() []Dependency

DefaultDependencyListKubernetes returns the default list of packages needed to work with Kubernetes-based products, such as Ocean.

type InstallOption

type InstallOption func(*InstallOptions)

InstallOption allows specifying various settings configurable by the dependency manager for overriding the defaults used when calling the `Install` method.

func WithBinaryDir

func WithBinaryDir(path string) InstallOption

WithBinaryDir sets the binary directory.

func WithDryRun

func WithDryRun(value bool) InstallOption

WithDryRun toggles the dry-run mode on/off.

func WithInstallPolicy added in v0.0.16

func WithInstallPolicy(value InstallPolicy) InstallOption

WithInstallPolicy configures the install policy.

func WithNoninteractive

func WithNoninteractive(value bool) InstallOption

WithNoninteractive toggles the noninteractive mode on/off.

type InstallOptions

type InstallOptions struct {
	// BinaryDir specifies the binary directory that the manager should download
	// and install the binary to.
	BinaryDir string

	// InstallPolicy describes a policy for if/when to install a dependency.
	InstallPolicy InstallPolicy

	// Noninteractive disables the interactive mode user interface by quieting the
	// configuration prompts.
	Noninteractive bool

	// DryRun configures the dependency manager to print the actions that would
	// be executed, without executing them.
	DryRun bool
}

type InstallPolicy added in v0.0.16

type InstallPolicy string

InstallPolicy describes a policy for if/when to install a dependency.

const (
	// InstallAlways means that the Manager always attempts to install the Dependency.
	InstallAlways InstallPolicy = "Always"
	// InstallNever means that the Manager never installs a Dependency, but only uses a local one.
	InstallNever InstallPolicy = "Never"
	// InstallIfNotPresent means that the Manager installs if the Dependency isn't present.
	InstallIfNotPresent InstallPolicy = "IfNotPresent"
)

type Manager added in v0.0.16

type Manager interface {
	// Install installs a new dependency.
	Install(ctx context.Context, dep Dependency, options ...InstallOption) error

	// InstallBulk installs a bulk of new dependencies.
	InstallBulk(ctx context.Context, deps []Dependency, options ...InstallOption) error

	// DependencyPresent determines if a dependency is present
	DependencyPresent(dep Dependency, options ...InstallOption) (bool, error)
}

Manager defines the interface of a Dependency Manager.

func NewManager added in v0.0.16

func NewManager(survey survey.Interface) Manager

Jump to

Keyboard shortcuts

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