snaptel

package
v0.0.0-...-9bdc77a Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	K = 1000
	M = 1000 * K
	G = 1000 * M
)

Constants used to truncate task hit and miss counts e.g. 1K(10^3), 1M(10^6, 1G(10^9) etc (not 1024^#). We do not use units larger than Gb to support 32 bit compiles.

Variables

View Source
var (
	FlURL = cli.StringFlag{
		Name:   "url, u",
		Usage:  "Sets the URL to use",
		EnvVar: "SNAP_URL",
		Value:  "http://localhost:8181",
	}
	FlAPIVer = cli.StringFlag{
		Name:   "api-version, a",
		Usage:  "The Snap API version",
		EnvVar: "SNAP_API_VERSION",
		Value:  "v2",
	}
	FlSecure = cli.BoolFlag{
		Name:   "insecure",
		Usage:  "Ignore certificate errors when Snap's API is running HTTPS",
		EnvVar: "SNAP_INSECURE",
	}

	FlPassword = cli.BoolFlag{
		Name:   "password, p",
		Usage:  "Require password for REST API authentication. e.g. snaptel -p plugin list",
		EnvVar: "SNAP_REST_PASSWORD",
	}
	FlConfig = cli.StringFlag{
		Name:   "config, c",
		EnvVar: "SNAPTEL_CONFIG_PATH,SNAPCTL_CONFIG_PATH",
		Usage:  "Path to a config file",
		Value:  "",
	}
	FlTimeout = cli.DurationFlag{
		Name:  "timeout, t",
		Usage: "Timeout to be set on HTTP request to the server",
		Value: 10 * time.Second,
	}
)

FlURL to FlTimeout are Main flags

View Source
var (
	// Commands defines a list of Snap CLI commands.
	Commands = []cli.Command{
		{
			Name: "task",
			Subcommands: []cli.Command{
				{
					Name:        "create",
					Description: "Creates a new task in the snap scheduler",
					Usage:       "There are two ways to create a task.\n\t1) Use a task manifest with [--task-manifest]\n\t2) Provide a workflow manifest and schedule details.\n\n\t* Note: Start, stop date/time, and count are optional.\n\t* Using `task create -h` to see options.\n",
					Action:      createTask,
					Flags: []cli.Flag{
						flTaskManifest,
						flWorkfowManifest,
						flTaskSchedInterval,
						flTaskSchedCount,
						flTaskSchedStartDate,
						flTaskSchedStartTime,
						flTaskSchedStopDate,
						flTaskSchedStopTime,
						flTaskName,
						flTaskSchedDuration,
						flTaskSchedNoStart,
						flTaskDeadline,
						flTaskMaxFailures,
					},
				},
				{
					Name:   "list",
					Usage:  "list or list --verbose",
					Action: listTask,
					Flags: []cli.Flag{
						flTaskManifest,
						flWorkfowManifest,
						flTaskSchedInterval,
						flTaskSchedCount,
						flTaskSchedStartDate,
						flTaskSchedStartTime,
						flTaskSchedStopDate,
						flTaskSchedStopTime,
						flTaskName,
						flTaskSchedDuration,
						flTaskSchedNoStart,
						flTaskDeadline,
						flTaskMaxFailures,
					},
				},
				{
					Name:   "start",
					Usage:  "start <task_id>",
					Action: startTask,
				},
				{
					Name:   "stop",
					Usage:  "stop <task_id>",
					Action: stopTask,
				},
				{
					Name:   "remove",
					Usage:  "remove <task_id>",
					Action: removeTask,
				},
				{
					Name:   "export",
					Usage:  "export <task_id>",
					Action: exportTask,
				},
				{
					Name:   "watch",
					Usage:  "watch <task_id> or watch <task_id> --verbose",
					Action: watchTask,
					Flags: []cli.Flag{
						flVerbose,
					},
				},
				{
					Name:   "enable",
					Usage:  "enable <task_id>",
					Action: enableTask,
				},
			},
		},
		{
			Name: "plugin",
			Subcommands: []cli.Command{
				{
					Name:   "load",
					Usage:  "load <plugin_path> [--plugin-cert=<plugin_cert_path> --plugin-key=<plugin_key_path> --plugin-ca-certs=<ca_cert_paths>]",
					Action: loadPlugin,
					Flags: []cli.Flag{
						flPluginAsc,
						flPluginCert,
						flPluginKey,
						flPluginCACerts,
					},
				},
				{
					Name:   "unload",
					Usage:  "unload <plugin_type> <plugin_name> <plugin_version>",
					Action: unloadPlugin,
				},
				{
					Name:   "list",
					Usage:  "list or list --running",
					Action: listPlugins,
					Flags: []cli.Flag{
						flRunning,
					},
				},
				{
					Name: "config",
					Subcommands: []cli.Command{
						{
							Name:   "get",
							Usage:  "get <plugin_type>:<plugin_name>:<plugin_version> or get -t <plugin_type> -n <plugin_name> -v <plugin_version>",
							Action: getConfig,
							Flags: []cli.Flag{
								flPluginName,
								flPluginType,
								flPluginVersion,
							},
						},
					},
				},
			},
		},
		{
			Name: "metric",
			Subcommands: []cli.Command{
				{
					Name:   "list",
					Usage:  "list",
					Action: listMetrics,
					Flags: []cli.Flag{
						flMetricVersion,
						flMetricNamespace,
						flVerbose,
					},
				},
				{
					Name:   "get",
					Usage:  `get -m <namespace> or get -m <namespace> -v <version>`,
					Action: getMetric,
					Flags: []cli.Flag{
						flMetricVersion,
						flMetricNamespace,
					},
				},
			},
		},
	}
)

Functions

func BasicAuth

func BasicAuth(ctx *cli.Context) runtime.ClientAuthInfoWriter

BasicAuth returns the instance of runtime.ClientAuthInfoWriter.

func GetFirstChar

func GetFirstChar(s string) string

GetFirstChar gets the first character of a giving string.

func SetAuthInfo

func SetAuthInfo(aw runtime.ClientAuthInfoWriter)

SetAuthInfo sets the runtime ClientAuthInfoWriter.

func SetClient

func SetClient(cl *snapClient.Snap)

SetClient sets the private HTTP Client in this package.

func SetScheme

func SetScheme(s string)

SetScheme sets the request protocol.

Types

type UsageError

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

UsageError defines the error message and CLI context

func (UsageError) Error

func (ue UsageError) Error() string

Error prints the usage error

func (UsageError) Help

func (ue UsageError) Help()

Help displays the command help

Jump to

Keyboard shortcuts

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