datum

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package datum is our cobra/viper cli implementation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DatumHost contains the root url for the Datum API
	DatumHost string
	// GraphAPIHost contains the url for the Datum graph api
	GraphAPIHost string
)
View Source
var (
	// ErrTokenRequired is returned when no authentication token is provided
	ErrTokenRequired = errors.New("DATUM_ACCESS_TOKEN not set")
)
View Source
var (
	Logger *zap.SugaredLogger
)
View Source
var RootCmd = &cobra.Command{
	Use:   appName,
	Short: "the datum cli",
}

RootCmd represents the base command when called without any subcommands

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func GetKeyring

func GetKeyring() (keyring.Keyring, error)

GetKeyring will return the already loaded keyring so that we don't prompt users for passwords multiple times

func GetTokenFromKeyring

func GetTokenFromKeyring(ctx context.Context) (*oauth2.Token, error)

GetTokenFromKeyring will return the oauth token from the keyring if the token is expired, but the refresh token is still valid, the token will be refreshed

func JSONPrint

func JSONPrint(s []byte) error

func StoreToken

func StoreToken(token *oauth2.Token) error

StoreToken in local keyring

func ViperBindFlag

func ViperBindFlag(name string, flag *pflag.Flag)

ViperBindFlag provides a wrapper around the viper bindings that panics if an error occurs

Types

type CLI

type CLI struct {
	Client      datumclient.DatumClient
	Interceptor clientv2.RequestInterceptor
	AccessToken string
}

func GetClient

func GetClient(ctx context.Context) (CLI, error)

type RequiredFieldMissingError

type RequiredFieldMissingError struct {
	// Field contains the required field that was missing from the input
	Field string
}

RequiredFieldMissingError is returned when a field is required but not provided

func NewRequiredFieldMissingError

func NewRequiredFieldMissingError(f string) *RequiredFieldMissingError

NewRequiredFieldMissingError returns an error for a missing required field

func (*RequiredFieldMissingError) Error

func (e *RequiredFieldMissingError) Error() string

Error returns the RequiredFieldMissingError in string format

Directories

Path Synopsis
Package datumgroup is our cobra/viper cli for group endpoints
Package datumgroup is our cobra/viper cli for group endpoints
Package datumlogin is our cobra/viper cli for authentication endpoints
Package datumlogin is our cobra/viper cli for authentication endpoints
Package datumorg is our cobra/viper cli for organization endpoints
Package datumorg is our cobra/viper cli for organization endpoints
Package register allows user registration
Package register allows user registration
Package reset allows user password reset
Package reset allows user password reset
Package datumtokens is our cobra/viper cli for token endpoints
Package datumtokens is our cobra/viper cli for token endpoints
Package datumuser is our cobra/viper cli for user endpoints
Package datumuser is our cobra/viper cli for user endpoints

Jump to

Keyboard shortcuts

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