cli

package
v0.0.0-...-a216e23 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2016 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Overview

Package cli implements a command line client for Inago. Cobra CLI is used as framework.

Index

Constants

This section is empty.

Variables

View Source
var (

	// MainCmd contains the cobra.Command to execute inagoctl.
	MainCmd = &cobra.Command{
		Use:   "inagoctl",
		Short: "Inago orchestrates groups of units on Fleet clusters",
		Long:  "Inago orchestrates groups of units on Fleet clusters",
		Run:   mainRun,
		PersistentPreRun: func(cmd *cobra.Command, args []string) {

			fs = afero.Afero{Fs: afero.NewOsFs()}

			loggingConfig := logging.DefaultConfig()
			if globalFlags.Verbose {
				loggingConfig.LogLevel = "DEBUG"
			}
			newLogger = logging.NewLogger(loggingConfig)

			URL, err := url.Parse(globalFlags.FleetEndpoint)
			if err != nil {
				panic(err)
			}

			newFleetConfig := fleet.DefaultConfig()
			newFleetConfig.Endpoint = *URL
			newFleetConfig.Logger = newLogger
			if globalFlags.Tunnel != "" {
				newSSHTunnelConfig := fleet.DefaultSSHTunnelConfig()
				newSSHTunnelConfig.Endpoint = *URL
				newSSHTunnelConfig.KnownHostsFile = globalFlags.SSHKnownHostsFile
				newSSHTunnelConfig.Logger = newLogger
				newSSHTunnelConfig.StrictHostKeyChecking = globalFlags.SSHStrictHostKeyChecking
				newSSHTunnelConfig.Timeout = globalFlags.SSHTimeout
				newSSHTunnelConfig.Tunnel = globalFlags.Tunnel
				newSSHTunnelConfig.Username = globalFlags.SSHUsername
				newSSHTunnel, err := fleet.NewSSHTunnel(newSSHTunnelConfig)
				if err != nil {
					panic(err)
				}
				newFleetConfig.SSHTunnel = newSSHTunnel
			}
			newFleet, err = fleet.NewFleet(newFleetConfig)
			if err != nil {
				panic(err)
			}

			newTaskServiceConfig := task.DefaultConfig()
			newTaskServiceConfig.Logger = newLogger
			newTaskService = task.NewTaskService(newTaskServiceConfig)

			newControllerConfig := controller.DefaultConfig()
			newControllerConfig.Logger = newLogger
			newControllerConfig.Fleet = newFleet
			newControllerConfig.TaskService = newTaskService

			newController = controller.NewController(newControllerConfig)

			newCtx = context.Background()
		},
	}
)

Functions

func FormatValidationError

func FormatValidationError(err controller.ValidationError) string

FormatValidationError returns the CausingErrors formatted: Validation Error found:

  • unit slice not found
  • unit does not have group prefix

func IsInvalidArgumentsError

func IsInvalidArgumentsError(err error) bool

IsInvalidArgumentsError checks whether the given command line arguments are valid

Types

This section is empty.

Jump to

Keyboard shortcuts

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