product

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Consul = Product{
	Name:              consulName,
	BinaryName:        binaryName(consulName),
	GetVersion:        nil,
	BuildInstructions: nil,
}
View Source
var Terraform = Product{
	Name:       terraformName,
	BinaryName: binaryName(terraformName),
	GetVersion: func(ctx context.Context, path string) (*version.Version, error) {
		cmd := exec.CommandContext(ctx, path, "version")

		out, err := cmd.Output()
		if err != nil {
			return nil, err
		}

		stdout := strings.TrimSpace(string(out))

		submatches := terraformVersionOutputRe.FindStringSubmatch(stdout)
		if len(submatches) != 2 {
			return nil, fmt.Errorf("unexpected number of version matches %d for %s", len(submatches), stdout)
		}
		v, err := version.NewVersion(submatches[1])
		if err != nil {
			return nil, fmt.Errorf("unable to parse version %q: %w", submatches[1], err)
		}

		return v, err
	},
	BuildInstructions: &BuildInstructions{
		GitRepoURL:    "https://github.com/hashicorp/terraform.git",
		PreCloneCheck: &build.GoIsInstalled{},
		Build:         &build.GoBuild{DetectVendoring: true},
	},
}
View Source
var Vault = Product{
	Name:              vaultName,
	BinaryName:        binaryName(vaultName),
	GetVersion:        nil,
	BuildInstructions: nil,
}

Functions

This section is empty.

Types

type BinaryNameFunc

type BinaryNameFunc func() string

type BuildInstructions

type BuildInstructions struct {
	GitRepoURL string

	// CloneTimeout overrides default timeout
	// for cloning the repository
	CloneTimeout time.Duration

	// PreCloneCheck represents any checks to run
	// prior to building, such as verifying build
	// dependencies (e.g. whether Go is installed)
	PreCloneCheck Checker

	// PreCloneCheckTimeout overrides default timeout
	// for the PreCloneCheck
	PreCloneCheckTimeout time.Duration

	// Build represents how to build the product
	// after checking out the source code
	Build Builder

	// BuildTimeout overrides default timeout
	// for the Builder
	BuildTimeout time.Duration
}

type Builder

type Builder interface {
	Build(ctx context.Context, repoDir, targetDir, binaryName string) (string, error)
	Remove(ctx context.Context) error
}

type Checker

type Checker interface {
	Check(ctx context.Context) error
}

type Product

type Product struct {
	// Name which identifies the product
	// on releases.hashicorp.com and in Checkpoint
	Name string

	// BinaryName represents name of the unpacked binary to be executed or built
	BinaryName BinaryNameFunc

	// GetVersion represents how to obtain the version of the product
	// reflecting any output or CLI flag differences
	GetVersion func(ctx context.Context, execPath string) (*version.Version, error)

	// BuildInstructions represents how to build the product "from scratch"
	BuildInstructions *BuildInstructions
}

Jump to

Keyboard shortcuts

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