commands

package
v3.27.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: Apache-2.0 Imports: 68 Imported by: 0

Documentation

Overview

Package commands implements the commands for the ttn-lw-cli binary.

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = MakeDefaultConfig(defaultGRPCAddress, defaultOAuthServerAddress, defaultInsecure)

DefaultConfig contains the default config for the ttn-lw-cli binary.

View Source
var (

	// Root command is the entrypoint of the program
	Root = &cobra.Command{
		Use:           name,
		SilenceErrors: true,
		SilenceUsage:  true,
		Short:         "The Things Network Command-line Interface",
		PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
			if cmd.Name() == "__complete" {
				return nil
			}

			return preRun(checkAuth, refreshToken, requireAuth)(cmd, args)
		},
		PersistentPostRunE: func(cmd *cobra.Command, args []string) error {
			if cmd.Name() == "__complete" {
				return nil
			}

			api.CloseAll()

			select {
			case <-ctx.Done():
			case <-time.After(versionCheckTimeout):
				logger.Warn("Version check timed out")
			case versionUpdate, ok := <-versionUpdate:
				if ok {
					pkgversion.LogUpdate(ctx, versionUpdate)
				}
			}

			select {
			case <-ctx.Done():
			case <-time.After(telemetryTimeout):
				logger.Warn("Telemetry submission timed out")
			case <-telemetrySubmission:
			}

			err := util.SaveAuthCache(cache)
			if err != nil {
				return err
			}

			return ctx.Err()
		},
	}
)

Functions

func AddCollaboratorFlagAlias added in v3.19.1

func AddCollaboratorFlagAlias(flagSet *pflag.FlagSet, prefix string)

AddCollaboratorFlagAlias adds alias for user id and organization id in User

func AddGatewayAntennaIdentifierFlags added in v3.19.1

func AddGatewayAntennaIdentifierFlags(flagSet *pflag.FlagSet, prefix string)

AddGatewayAntennaIdentifierFlags adds a string slice flag for gateway antennas.

func GetGatewayAntennaIdentifiers added in v3.19.1

func GetGatewayAntennaIdentifiers(flagSet *pflag.FlagSet, prefix string) (antennas []*ttnpb.GatewayAntennaIdentifiers, err error)

GetGatewayAntennaIdentifiers gets a string slice value from a flag and returns a slice of gateway antenna identifiers.

Types

type Config

type Config struct {
	conf.Base                          `name:",squash"`
	CredentialsID                      string `name:"credentials-id" yaml:"credentials-id" description:"Credentials ID (if using multiple configurations)"`            //nolint:lll
	InputFormat                        string `name:"input-format" yaml:"input-format" description:"Input format"`                                                     //nolint:lll
	OutputFormat                       string `name:"output-format" yaml:"output-format" description:"Output format"`                                                  //nolint:lll
	AllowUnknownHosts                  bool   `name:"allow-unknown-hosts" yaml:"allow-unknown-hosts" description:"Allow sending credentials to unknown hosts"`         //nolint:lll
	OAuthServerAddress                 string `name:"oauth-server-address" yaml:"oauth-server-address" description:"OAuth Server address"`                             //nolint:lll
	IdentityServerGRPCAddress          string `name:"identity-server-grpc-address" yaml:"identity-server-grpc-address" description:"Identity Server address"`          //nolint:lll
	GatewayServerEnabled               bool   `name:"gateway-server-enabled" yaml:"gateway-server-enabled" description:"Gateway Server enabled"`                       //nolint:lll
	GatewayServerGRPCAddress           string `name:"gateway-server-grpc-address" yaml:"gateway-server-grpc-address" description:"Gateway Server address"`             //nolint:lll
	NetworkServerEnabled               bool   `name:"network-server-enabled" yaml:"network-server-enabled" description:"Network Server enabled"`                       //nolint:lll
	NetworkServerGRPCAddress           string `name:"network-server-grpc-address" yaml:"network-server-grpc-address" description:"Network Server address"`             //nolint:lll
	ApplicationServerEnabled           bool   `name:"application-server-enabled" yaml:"application-server-enabled" description:"Application Server enabled"`           //nolint:lll
	ApplicationServerGRPCAddress       string `name:"application-server-grpc-address" yaml:"application-server-grpc-address" description:"Application Server address"` //nolint:lll
	JoinServerEnabled                  bool   `name:"join-server-enabled" yaml:"join-server-enabled" description:"Join Server enabled"`                                //nolint:lll
	JoinServerGRPCAddress              string `name:"join-server-grpc-address" yaml:"join-server-grpc-address" description:"Join Server address"`                      //nolint:lll
	DeviceTemplateConverterGRPCAddress string ``                                                                                                                       //nolint:lll
	/* 139-byte string literal not displayed */
	DeviceClaimingServerGRPCAddress string `` //nolint:lll
	/* 130-byte string literal not displayed */
	QRCodeGeneratorGRPCAddress   string        `name:"qr-code-generator-grpc-address" yaml:"qr-code-generator-grpc-address" description:"QR Code Generator address"`       //nolint:lll
	PacketBrokerAgentGRPCAddress string        `name:"packet-broker-agent-grpc-address" yaml:"packet-broker-agent-grpc-address" description:"Packet Broker Agent address"` //nolint:lll
	Insecure                     bool          `name:"insecure" yaml:"insecure" description:"Connect without TLS"`                                                         //nolint:lll
	CA                           string        `name:"ca" yaml:"ca" description:"CA certificate file"`
	DumpRequests                 bool          `name:"dump-requests" yaml:"dump-requests" description:"When log level is set to debug, also dump request payload as JSON"` //nolint:lll
	SkipVersionCheck             bool          `name:"skip-version-check" yaml:"skip-version-check" description:"Do not perform version checks"`                           //nolint:lll
	Retry                        RetryConfig   `name:"retry" yaml:"retry"`
	Telemetry                    telemetry.CLI `name:"telemetry" yaml:"telemetry" description:"Telemetry configuration"` //nolint:lll
}

Config for the ttn-lw-cli binary.

func MakeDefaultConfig

func MakeDefaultConfig(clusterGRPCAddress string, oauthServerAddress string, insecure bool) Config

MakeDefaultConfig builds the default config for the ttn-lw-cli binary for a given host.

type RetryConfig added in v3.17.2

type RetryConfig struct {
	Max            uint          `name:"max" yaml:"max" description:"Maximum amount of times that a request can be reattempted"`      //nolint:lll
	DefaultTimeout time.Duration `name:"default-timeout" yaml:"default-timeout" description:"Default timeout between retry attempts"` //nolint:lll
	EnableMetadata bool          ``                                                                                                   //nolint:lll
	/* 145-byte string literal not displayed */
	Jitter float64 `name:"jitter" yaml:"jitter" description:"Fraction that creates a deviation of the timeout used between retry attempts"` //nolint:lll
}

RetryConfig defines the values for the retry behavior in the CLI.

Jump to

Keyboard shortcuts

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