automationcli

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAndRun

func ParseAndRun(routines automation.Routines) int

ParseAndRun parses command-line options and runs content from routines. On completion, the function return an exit status that should be passed on to os.Exit.

Types

type Config

type Config struct {
	// AppName holds the app-name to use in automation. The default is set to
	// match the Go main module import path.
	AppName string

	// CredentialsFile describes the path to a valid Clarify integration JSON
	// credentials file. This property is required if Username is set.
	CredentialsFile string

	// Username can be set to use Basic Authentication ot authorize against
	// Clarify. The user-name is the same as the integration ID. When set,
	// the content of the CredentialsFile config is ignored.
	Username string

	// Password can be set to use Basic Authentication to authorize against
	// Clarify. This property is required if Username is set.
	Password Password

	// Patterns describes which sub-routines to run. If empty, all sub-routines
	// are run.
	Patterns []string

	// Verbose, if set, turns on DEBUG logging. The default log level is INFO.
	Verbose bool

	// DryRun, if set, signals routines and actions to not persist changes.
	DryRun bool

	// EarlyOut, if set, signals the program to abort at the first routine
	// error. The default is to continue to the next routine.
	EarlyOut bool
}

Config describe a set of command-line options.

func ParseArguments

func ParseArguments(arguments []string) (*Config, error)

ParseArguments parses command-line arguments into a Config structure using the provided or prints usage information to os.Stderr. When using this method, the Patterns property is set from the remaining command-line arguments after all flags (options) have been parsed.

This function can be used by users who need to customize the configuration before it's run, but do not need to customize command-line flags.

func (Config) Client

func (p Config) Client(ctx context.Context) (*clarify.Client, error)

Client returns an http.Client according to the configuration or an error in case of invalid configuration. Note that invalid or expired credentials is not considered a configuration error, and will still result in a client being returned.

func (*Config) FlagSet

func (cfg *Config) FlagSet(name string, errorHandling flag.ErrorHandling) *flag.FlagSet

FlagSet returns a named flag-set for parsing command line configuration flags where fallback values are fetched from environment variables. Note that there is no flag for the AppName and Patterns property.

This method can be used by users who need to customize the which command-line flags are available in their application.

func (*Config) Run

func (cfg *Config) Run(ctx context.Context, routines automation.Routines) error

Run runs configuration from routines using configuration from cfg in an arbitrary order.

type Password

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

Password helps prevent a string value from being exposed in logs or marshalled as text or JSON.

func NewPassword

func NewPassword(value string) Password

func (Password) GoString

func (p Password) GoString() string

func (Password) MarshalText

func (p Password) MarshalText() ([]byte, error)

func (Password) String

func (p Password) String() string

func (*Password) UnmarshalText

func (p *Password) UnmarshalText(data []byte) error

Jump to

Keyboard shortcuts

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