tool

package
v0.0.0-...-90deddd Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 70 Imported by: 1

Documentation

Overview

Copyright 2018 GRAIL, Inc. All rights reserved. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

Package tool implements the reflow command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	// Schema is the infrastructure schema.
	Schema infra.Schema
	// SchemaKeys is the schema keys to providers,flags.
	SchemaKeys infra.Keys
	// Config must be specified.
	Config            infra.Config
	DefaultConfigFile string
	Version           string
	Variant           string

	// Commands contains the additional set of invocable commands.
	Commands map[string]Func

	// ConfigFile stores the path of the active configuration file.
	// May be overridden by the -config flag.
	ConfigFile string

	// Intro is an additional introduction printed after the standard one.
	Intro string

	// The standard output and error as defined by this command;
	// these are wrapped through a status writer so that output is
	// properly interleaved.
	Stdout, Stderr io.Writer

	// Status object for the current cmd invocation. This is used to continuously update the
	// progress of the cmd execution.
	Status *status.Status

	// BootstrapBinary stores the path of the bootstrap binary.
	BootstrapBinary string

	Log *log.Logger
	// contains filtered or unexported fields
}

Cmd holds the configuration, flag definitions, and runtime objects required for tool invocations.

func (*Cmd) CurrentPool

func (c *Cmd) CurrentPool(ctx context.Context) pool.Pool

CurrentPool returns the current underlying pool of an ec2cluster. The returned pool reflects the current state of the remote ec2cluster as long as the provided ctx is not done. Note that any existing allocs in the current pool are not "kept alive", so it is only useful for tools performing introspection of the state of the pool.

func (*Cmd) Errorf

func (c *Cmd) Errorf(format string, v ...interface{})

Errorf formats a message in the manner of fmt.Printf and prints it to stderr.

func (Cmd) Errorln

func (c Cmd) Errorln(v ...interface{})

Errorln formats a message in the manner of fmt.Println and prints it to stderr.

func (*Cmd) Exit

func (c *Cmd) Exit(code int)

Exit causes the command to exit with the provided status code. Exit ensures that command teardown is properly handled.

func (*Cmd) Fatal

func (c *Cmd) Fatal(v ...interface{})

Fatal formats a message in the manner of fmt.Print, prints it to stderr, and then exits the tool.

func (*Cmd) Fatalf

func (c *Cmd) Fatalf(format string, v ...interface{})

Fatalf formats a message in the manner of fmt.Printf, prints it to stderr, and then exits the tool.

func (*Cmd) Flags

func (c *Cmd) Flags() *flag.FlagSet

Flags initializes and returns the FlagSet used by this Cmd instance. The user should parse this flagset before invoking (*Cmd).Main, e.g.:

cmd.Flags().Parse(os.Args[1:])

func (*Cmd) Main

func (c *Cmd) Main()

Main parses command line flags and then invokes the requested command. Main uses Cmd's config (and other initialization), which may be overridden by flag configs. It should be invoked only once, at the beginning of command line execution. The caller is expected to have parsed the flagset for us before calling Main.

Main should only be called once.

func (*Cmd) Parse

func (c *Cmd) Parse(fs *flag.FlagSet, args []string, help, usage string)

Parse parses the provided FlagSet from the provided arguments. It adds a -help flag to the flagset, and prints the help and usage string when the command is called with -help. On usage error, it prints the flag defaults and exits with code 2.

func (*Cmd) Printf

func (c *Cmd) Printf(format string, v ...interface{})

Printf formats a message in the manner of fmt.Printf and prints it to stdout.

func (*Cmd) Println

func (c *Cmd) Println(v ...interface{})

Println formats a message in the manner of fmt.Println and prints it to stdout.

func (*Cmd) TransferLimit

func (c *Cmd) TransferLimit() int

TransferLimit returns the configured transfer limit.

func (Cmd) WaitForBackgroundTasks

func (c Cmd) WaitForBackgroundTasks(wg *wg.WaitGroup, timeout time.Duration)

WaitForBackgroundTasks waits until all background tasks complete, or if the provided timeout expires.

type Cost

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

Cost tracks the cost of something along with whether its an exact cost.

func NewCostExact

func NewCostExact(value float64) Cost

NewCostExact creates an exact cost.

func NewCostUB

func NewCostUB(value float64) Cost

NewCostUB creates a cost which is an Upper bound cost.

func (*Cost) Add

func (c *Cost) Add(d Cost)

func (*Cost) Mul

func (c *Cost) Mul(v float64)

func (Cost) String

func (c Cost) String() string

type Func

type Func func(*Cmd, context.Context, ...string)

Func is the type of a command function.

type OfferInspect

type OfferInspect struct {
	ID        string
	Resources reflow.Resources
}

OfferInspect contains Offer metadata.

Jump to

Keyboard shortcuts

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