config

package
v2.34.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvSettingsPrefix = "c8y"

	// SettingsGlobalName name of the settings file (without extension)
	SettingsGlobalName = "settings"
)
View Source
const (
	// SettingsIncludeAllPageSize property name used to control the default page size when using includeAll parameter
	SettingsIncludeAllPageSize = "settings.includeAll.pageSize"

	// SettingEncryptionCachePassphrase setting to cache the passphrase via environment variables
	SettingEncryptionCachePassphrase = "settings.encryption.cachePassphrase"

	// SettingsMaxWorkers property name used to control the hard limit on the maximum workers used in batch operations
	SettingsMaxWorkers = "settings.defaults.maxWorkers"

	// SettingsWorkers number of workers to use
	SettingsWorkers = "settings.defaults.workers"

	// SettingsMaxJobs maximum allowed jobs to be executed
	SettingsMaxJobs = "settings.defaults.maxJobs"

	// SettingsCurrentPage current page
	SettingsCurrentPage = "settings.defaults.currentPage"

	// SettingsTotalPages total pages to return
	SettingsTotalPages = "settings.defaults.totalPages"

	// SettingsIncludeAll include all available results
	SettingsIncludeAll = "settings.defaults.includeAll"

	// SettingsIncludeAllDelayMS delay in milliseconds between retrieving the next page when using include all
	SettingsIncludeAllDelayMS = "settings.includeAll.delayMS"

	// SettingsPageSize page size
	SettingsPageSize = "settings.defaults.pageSize"

	// SettingsWithTotalPages include the total pages statistics under statistics.totalPages
	SettingsWithTotalPages = "settings.defaults.withTotalPages"

	// SettingsWithTotalElements include the total pages statistics under statistics.totalPages
	SettingsWithTotalElements = "settings.defaults.withTotalElements"

	// SettingsRawOutput include the raw (original) output instead of only returning the nested array property
	SettingsRawOutput = "settings.defaults.raw"

	// SettingsIgnoreAcceptHeader ignore the accept header / set the Accept header to an empty string
	SettingsIgnoreAcceptHeader = "settings.defaults.noAccept"

	// SettingsHeader custom headers to be added to outgoing requests
	SettingsHeader = "settings.defaults.header"

	// SettingsQueryParameters custom query parameters to be added to outgoing requests
	SettingsQueryParameters = "settings.defaults.customQueryParam"

	// SettingsDryRun dry run. Don't send any requests, just print out the information
	SettingsDryRun = "settings.defaults.dry"

	// SettingsDryRunPattern list of methods which should be conditionally dry, i.e. "PUT POST DELETE"
	SettingsDryRunPattern = "settings.defaults.dryPattern"

	// SettingsDryRunFormat dry run output format. Controls how the dry run information is displayed
	SettingsDryRunFormat = "settings.defaults.dryFormat"

	// SettingsDebug Show debug messages
	SettingsDebug = "settings.defaults.debug"

	// SettingsVerbose Show verbose log messages
	SettingsVerbose = "settings.defaults.verbose"

	// SettingsJSONCompact show compact json output
	SettingsJSONCompact = "settings.defaults.compact"

	// SettingsShowProgress show progress bar
	SettingsShowProgress = "settings.defaults.progress"

	// SettingsDisableColor don't print progress bar
	SettingsDisableProgress = "settings.defaults.noProgress"

	// SettingsDisableColor don't print console output in color
	SettingsDisableColor = "settings.defaults.noColor"

	// SettingsProxy http/s proxy settings
	SettingsProxy = "settings.defaults.proxy"

	// SettingsIgnoreProxy ignore proxy settings
	SettingsIgnoreProxy = "settings.defaults.noProxy"

	// SettingsWithError return the error response on stdout rather than stderr
	SettingsWithError = "settings.defaults.withError"

	// SettingsWorkerDelay delay in milliseconds to wait after each request before the worker processes a new job (request)
	SettingsWorkerDelay = "settings.defaults.delay"

	// SettingsWorkerDelayBefore delay in milliseconds to wait before each request
	SettingsWorkerDelayBefore = "settings.defaults.delayBefore"

	// SettingsAbortOnErrorCount abort when the number of errors reaches this value
	SettingsAbortOnErrorCount = "settings.defaults.abortOnErrors"

	// SettingsViewOption controls whether views are applied the output or not
	SettingsViewOption = "settings.defaults.view"

	// SettingsTimeout timeout in seconds use when sending requests
	SettingsTimeout = "settings.defaults.timeout"

	// SettingsConfirmText custom confirmation text to use to prompt the user of an action
	SettingsConfirmText = "settings.defaults.confirmText"

	// SettingsJSONFlatten flatten nested json using dot notation
	SettingsJSONFlatten = "settings.defaults.flatten"

	// SettingsStorageStoreToken controls if the token is saved to the session file or not
	SettingsStorageStoreToken = "settings.storage.storeToken"

	// SettingsStorageStorePassword controls if the password is saved to the session file or not
	SettingsStorageStorePassword = "settings.storage.storePassword"

	// SettingsTemplatePath template folder where the template files are located
	SettingsTemplatePath = "settings.template.path"

	// SettingsTemplateCustomPaths custom template folder where the template files are located
	SettingsTemplateCustomPaths = "settings.template.customPath"

	// SettingsModeEnableCreate enables create (post) commands
	SettingsModeEnableCreate = "settings.mode.enableCreate"

	// SettingsModeEnableUpdate enables update commands
	SettingsModeEnableUpdate = "settings.mode.enableUpdate"

	// SettingsModeEnableDelete enables delete commands
	SettingsModeEnableDelete = "settings.mode.enableDelete"

	// SettingsModeCI enable continuous integration mode (this will enable all commands)
	SettingsModeCI = "settings.ci"

	// SettingsForce don't prompt for confirmation
	SettingsForce = "settings.defaults.force"

	// SettingsForceConfirm force prompt for confirmation
	SettingsForceConfirm = "settings.defaults.confirm"

	// SettingsModeConfirmation sets the confirm mode
	SettingsModeConfirmation = "settings.mode.confirmation"

	// GetOutputFileRaw file path where the raw response will be saved to
	SettingsOutputFileRaw = "settings.defaults.outputFileRaw"

	// SettingsOutputFile file path where the parsed response will be saved to
	SettingsOutputFile = "settings.defaults.outputFile"

	// SettingsOutputFormat Output format i.e. table, json, csv, csvheader
	SettingsOutputFormat = "settings.defaults.output"

	// SettingsOutputTemplate Output jsonnet template
	SettingsOutputTemplate = "settings.defaults.outputTemplate"

	// SettingsEncryptionEnabled enables encryption when storing sensitive session data
	SettingsEncryptionEnabled = "settings.encryption.enabled"

	// SettingsActivityLogPath path where the activity log will be stored
	SettingsActivityLogPath = "settings.activityLog.path"

	// SettingsActivityLogEnabled enables/disables the activity log
	SettingsActivityLogEnabled = "settings.activityLog.enabled"

	// SettingsActivityLogMethodFilter filters the activity log entries by a space delimited methods, i.e. GET POST PUT
	SettingsActivityLogMethodFilter = "settings.activityLog.methodFilter"

	// SettingsConfigPath configuration path
	SettingsConfigPath = "settings.path"

	// SettingsViewsCommonPaths paths to common view definition files
	SettingsViewsCommonPaths = "settings.views.commonPaths"

	// SettingsViewsCustomPaths paths to custom fiew definition files
	SettingsViewsCustomPaths = "settings.views.customPaths"

	// SettingsFilter json filter to be applied to the output
	SettingsFilter = "settings.defaults.filter"

	// SettingsSelect json properties to be selected from the output. Only the given properties will be returned
	SettingsSelect = "settings.defaults.select"

	// SettingsSilentStatusCodes Status codes which will not print out an error message
	SettingsSilentStatusCodes = "settings.defaults.silentStatusCodes"

	// SettingsSilentExit silent status codes don't affect the exit code
	SettingsSilentExit = "settings.defaults.silentExit"

	// SettingsSessionFile Session file to use for api authentication
	SettingsSessionFile = "settings.defaults.session"

	// SettingsAliases list of aliases
	SettingsAliases = "settings.aliases"

	// SettingsCommonAliases list of common aliases which are usually kept in the global configuration and shared amongst sessions
	SettingsCommonAliases = "settings.commonAliases"

	// SettingsViewMinColumnWidth minimum column width in characters
	SettingsViewMinColumnWidth = "settings.views.columnMinWidth"

	// SettingsViewEmptyValueMinColumnWidth minimum column width in characters when a value is empty
	SettingsViewEmptyValueMinColumnWidth = "settings.views.columnMinWidthEmptyValue"

	// SettingsViewMaxColumnWidth maximum column width in characters
	SettingsViewMaxColumnWidth = "settings.views.columnMaxWidth"

	// SettingsViewColumnPadding column padding
	SettingsViewColumnPadding = "settings.views.columnPadding"

	// SettingsViewRowMode controls row rendering, e.g. wrapping or truncation
	SettingsViewRowMode = "settings.views.rowMode"

	// SettingsLoggerHideSensitive hide sensitive information in log entries
	SettingsLoggerHideSensitive = "settings.logger.hideSensitive"

	// SettingsDisableInput disable reading from stdin (pipeline input)
	SettingsDisableInput = "settings.defaults.nullInput"

	// SettingsAllowEmptyPipe allow empty piped data
	SettingsAllowEmptyPipe = "settings.defaults.allowEmptyPipe"

	// SettingsLoginType preferred login type, i.e. BASIC, OAUTH_INTERNAL etc.
	SettingsLoginType = "settings.login.type"

	// Cache settings
	// SettingsDefaultsCacheEnabled enable caching
	SettingsDefaultsCacheEnabled = "settings.defaults.cache"
	SettingsDefaultsNoCache      = "settings.defaults.noCache"

	// SettingsDefaultsCacheTTL Cache time-to-live setting as a duration
	SettingsDefaultsCacheTTL = "settings.defaults.cacheTTL"

	// SettingsCacheDir Cache directory
	SettingsCacheDir = "settings.cache.path"

	// SettingsCacheMethods HTTP methods which should be cached
	SettingsCacheMethods = "settings.cache.methods"

	// SettingsCacheKeyHost include host in cache key generation
	SettingsCacheKeyHost = "settings.cache.keyhost"

	// SettingsCacheMode cache mode. Only used for testing purposes
	SettingsCacheMode = "settings.cache.mode"

	// SettingsCacheKeyAuth include authorization header in cache key generation
	SettingsCacheKeyAuth = "settings.cache.keyauth"

	// SettingsCacheBodyPaths include only specific json body paths in cache hashing calculation
	SettingsCacheBodyPaths = "settings.defaults.cacheBodyPaths"

	// SettingsDefaultsInsecure allow insecure SSL connections
	SettingsDefaultsInsecure = "settings.defaults.insecure"

	// SettingsBrowser default browser
	SettingsBrowser = "settings.browser"

	// Extensions
	SettingsExtensionDataDir         = "settings.extensions.datadir"
	SettingsExtensionDefaultHost     = "settings.extensions.defaultHost"
	SettingsExtensionDefaultUsername = "settings.extensions.defaultUsername"
)
View Source
const (
	ViewsOff  = "off"
	ViewsAuto = "auto"
)

Variables

View Source
var (
	// EnvPassphrase passphrase environment variable name
	EnvPassphrase = "C8Y_PASSPHRASE"

	// EnvPassphraseText passphrase text environment variable name
	EnvPassphraseText = "C8Y_PASSPHRASE_TEXT"

	// PrefixEncrypted prefix used in encrypted string fields to identify when a string is encrypted or not
	PrefixEncrypted = "{encrypted}"

	// KeyFileName is the name of the reference encryption text
	KeyFileName = ".key"

	// ActivityLogDirName name of the activitylog directory
	ActivityLogDirName = "activitylog"
)
View Source
var (
	DefaultHome = []string{
		"~/.go-c8y-cli",
		"/usr/local/etc/go-c8y-cli",
		"/opt/homebrew/etc/go-c8y-cli",
		"/home/linuxbrew/.linuxbrew/etc/go-c8y-cli",
		"$HOMEBREW_PREFIX/etc/go-c8y-cli",
		"/etc/go-c8y-cli",
	}
	DefaultSessionDir = ".cumulocity"
	EnvHome           = "C8Y_HOME"
	EnvSessionHome    = "C8Y_SESSION_HOME"
)
View Source
var ConfigExtensions = []string{"json", "yaml", "yml", "env", "toml", "properties"}
View Source
var PathSplitChar = ":"
View Source
var (
	SettingsDefaultsPrefix = "settings.defaults"
)
View Source
var SettingsToken = "token"

Functions

func GetSettingsName

func GetSettingsName(flagName string) string

GetSettingsName get the settings name from a flag name

func GetSettingsNameWithoutPrefix added in v2.20.0

func GetSettingsNameWithoutPrefix(name string) string

GetSettingsNameWithoutPrefix converts the setting name without the settings prefix

func SetMode

func SetMode(v *viper.Viper, mode string) error

SetMode set the session mode to control which commands are enabled or not

func SupportsFileExtension

func SupportsFileExtension(p string) bool

SupportsFileExtension check if a filepath is using a supported extension or not

func WithBindEnv

func WithBindEnv(name string, defaultValue interface{}) func(*Config) error

func WithBoolEnvOverride added in v2.18.0

func WithBoolEnvOverride(name string, envName string) func(*Config) error

WithBoolEnvOverride support optional override boolean variable

func WithDefault

func WithDefault(name string, defaultValue interface{}) func(*Config) error

Types

type ActivityLogSettings

type ActivityLogSettings struct {
	CurrentPath  string `json:"currentPath,omitempty"`
	Enabled      *bool  `json:"enabled,omitempty"`
	MethodFilter string `json:"methodFilter,omitempty"`
	Path         string `json:"path,omitempty"`
}

ActivityLogSettings activity log settings

type CommandSettings

type CommandSettings struct {
	ActivityLog *ActivityLogSettings   `json:"activityLog,omitempty"`
	Encryption  *EncryptionSettings    `json:"encryption,omitempty"`
	IncludeAll  *IncludeAllSettings    `json:"includeAll,omitempty"`
	Session     *SessionSettings       `json:"session,omitempty"`
	Mode        *ModeSettings          `json:"mode,omitempty"`
	Storage     *StorageSettings       `json:"storage,omitempty"`
	Template    *TemplateSettings      `json:"template,omitempty"`
	View        *ViewSettings          `json:"views,omitempty"`
	Defaults    map[string]interface{} `json:"defaults,omitempty"`
}

CommandSettings contains the standard commonly used configuration settings

func (*CommandSettings) Bool

func (s *CommandSettings) Bool(v bool) *bool

Bool returns a bool pointer set to the given value

func (*CommandSettings) Int

func (s *CommandSettings) Int(v int) *int

Int returns a int pointer set to the given value

type CommonCommandOptions

type CommonCommandOptions struct {
	ConfirmText       string
	OutputFile        string
	OutputFileRaw     string
	OutputTemplate    string
	CommandFlags      map[string]string
	Filters           *jsonfilter.JSONFilters
	ResultProperty    string
	IncludeAll        bool
	WithTotalPages    bool
	WithTotalElements bool
	PageSize          int
	CurrentPage       int64
	TotalPages        int64
}

CommonCommandOptions control the handling of the response which are available for all commands which interact with the server

func (CommonCommandOptions) AddQueryParameters

func (options CommonCommandOptions) AddQueryParameters(query *flags.QueryTemplate)

AddQueryParameters adds the common query parameters to the given query values

func (CommonCommandOptions) AddQueryParametersWithMapping added in v2.22.0

func (options CommonCommandOptions) AddQueryParametersWithMapping(query *flags.QueryTemplate, aliases map[string]string)

type Config

type Config struct {

	// Persistent settings (stored to file)
	Persistent *viper.Viper

	// SecureData accessor to encrypt/decrypt data
	SecureData *encrypt.SecureData

	// Passphrase used for encrypting/decrypting fields
	Passphrase string

	// SecretText used to test the encryption passphrase
	SecretText string

	Logger *logger.Logger
	// contains filtered or unexported fields
}

Config cli configuration settings

func NewConfig

func NewConfig(v *viper.Viper) *Config

NewConfig returns a new CLI configuration object

func (*Config) AbortOnErrorCount

func (c *Config) AbortOnErrorCount() int

AbortOnErrorTotal abort when the number of errors reaches this value

func (*Config) ActivityLogEnabled

func (c *Config) ActivityLogEnabled() bool

ActivityLogEnabled enables/disables the activity log

func (*Config) Aliases

func (c *Config) Aliases() map[string]string

Aliases get aliases configured in the current session

func (*Config) AllSettings

func (c *Config) AllSettings() map[string]interface{}

AllSettings get all the settings as a map

func (*Config) AllowEmptyPipe

func (c *Config) AllowEmptyPipe() bool

AllowEmptyPipe check if empty piped data is allowed

func (*Config) AllowModeCreate

func (c *Config) AllowModeCreate() bool

AllowModeCreate enables create (post) commands

func (*Config) AllowModeDelete

func (c *Config) AllowModeDelete() bool

AllowModeDelete enables delete commands

func (*Config) AllowModeUpdate

func (c *Config) AllowModeUpdate() bool

AllowModeUpdate enables update commands

func (*Config) BindAuthorization

func (c *Config) BindAuthorization() error

BindAuthorization binds environment variables related to the authrorization to the configuration

func (*Config) BindPFlag

func (c *Config) BindPFlag(flags *pflag.FlagSet) error

BindPFlag binds flags to the configuration Configuration precendence is: 1. Arguments 2. Environment variables 3. Session configuration 4. Global configuration

func (*Config) Browser

func (c *Config) Browser() string

Browser get default web browser

func (*Config) CacheBodyKeys added in v2.15.0

func (c *Config) CacheBodyKeys() []string

func (*Config) CacheDir

func (c *Config) CacheDir() string

CacheDir get the cache directory

func (*Config) CacheEnabled

func (c *Config) CacheEnabled() bool

CacheEnabled shows if caching is enabled or not

func (*Config) CacheKeyIncludeAuth

func (c *Config) CacheKeyIncludeAuth() bool

CacheKeyIncludeAuth include authorization cache key generation

func (*Config) CacheKeyIncludeHost

func (c *Config) CacheKeyIncludeHost() bool

CacheKeyIncludeHost include full host name in cache key generation

func (*Config) CacheMethods

func (c *Config) CacheMethods() string

CacheMethods HTTP methods which should be cached

func (*Config) CacheMode

func (c *Config) CacheMode() c8y.StoreMode

CacheMode caching mode which controls

func (*Config) CachePassphraseVariables

func (c *Config) CachePassphraseVariables() bool

CachePassphraseVariables return true if the passphrase variables should be persisted or not

func (*Config) CacheTTL

func (c *Config) CacheTTL() time.Duration

CacheTTL cache time-to-live. After the duration then the cache will no longer be used.

func (*Config) CheckEncryption

func (c *Config) CheckEncryption(encryptedText ...string) (string, error)

CheckEncryption checks if the usuer has provided the correct encryption password or not by testing the decryption of the secret text

func (*Config) CommonAliases

func (c *Config) CommonAliases() map[string]string

CommonAliases Get common aliases from the global configuration file deprecated in favor of extensions

func (*Config) CompactJSON

func (c *Config) CompactJSON() bool

CompactJSON show compact json output

func (*Config) ConfirmText

func (c *Config) ConfirmText() string

ConfirmText custom confirmation text to use to prompt the user of an action

func (*Config) CreateKeyFile

func (c *Config) CreateKeyFile(keyText string) error

CreateKeyFile creates a file used as reference to validate encryption

func (*Config) Debug

func (c *Config) Debug() bool

Debug show debug messages

func (Config) DebugViper

func (c Config) DebugViper()

DebugViper debug viper configuration

func (Config) DecryptAllProperties

func (c Config) DecryptAllProperties() (err error)

DecryptAllProperties decrypt all properties

func (*Config) DecryptSession

func (c *Config) DecryptSession() error

DecryptSession decrypts a session (as long as the encryption passphrase has already been provided)

func (*Config) DecryptString

func (c *Config) DecryptString(value string) (string, error)

DecryptString returns the decrypted string if the string is encrypted

func (*Config) DefaultHost added in v2.30.0

func (c *Config) DefaultHost() string

func (*Config) DisableColor

func (c *Config) DisableColor() bool

DisableColor don't print console output in color

func (*Config) DisableProgress added in v2.16.0

func (c *Config) DisableProgress() bool

DisableProgress don't print progress bar

func (*Config) DisableStdin

func (c *Config) DisableStdin() bool

DisableStdin hide sensitive information in log entries

func (*Config) DryRun

func (c *Config) DryRun() bool

DryRun dont sent any destructive requests. Just print out what would be sent

func (*Config) DryRunFormat

func (c *Config) DryRunFormat() string

SettingsDryRunFormat dry run output format. Controls how the dry run information is displayed

func (*Config) EncryptionEnabled

func (c *Config) EncryptionEnabled() bool

EncryptionEnabled enables encryption when storing sensitive session data

func (*Config) ExpandHomePath

func (c *Config) ExpandHomePath(path string) string

ExpandHomePath expand home path references found in the path

func (*Config) ExtensionDefaultUsername added in v2.30.0

func (c *Config) ExtensionDefaultUsername() string

func (*Config) ExtensionsDataDir added in v2.30.0

func (c *Config) ExtensionsDataDir() string

Get Extension Data Directory

func (*Config) FlattenJSON

func (c *Config) FlattenJSON() bool

FlattenJSON flatten nested json using dot notation

func (*Config) Force

func (c *Config) Force() bool

Force don't prompt for confirmation

func (*Config) ForceConfirm

func (c *Config) ForceConfirm() bool

ForceConfirm force prompt for confirmation

func (*Config) GetActivityLogMethodFilter

func (c *Config) GetActivityLogMethodFilter() string

GetActivityLogMethodFilter filters the activity log entries by a space delimited methods, i.e. GET POST PUT

func (*Config) GetActivityLogPath

func (c *Config) GetActivityLogPath() string

GetActivityLogPath path where the activity log will be stored

func (*Config) GetConfigPath

func (c *Config) GetConfigPath() string

GetConfigPath get global settings file path

func (*Config) GetConfirmationMethods

func (c *Config) GetConfirmationMethods() string

GetConfirmationMethods get HTTP methods that require confirmation

func (*Config) GetCumulocityVersion added in v2.33.0

func (c *Config) GetCumulocityVersion() string

GetCumulocityVersion gets Cumulocity version

func (*Config) GetCurrentPage

func (c *Config) GetCurrentPage() int64

GetCurrentPage get current page

func (*Config) GetDefaultUsername

func (c *Config) GetDefaultUsername() string

GetDefaultUsername returns the default username

func (*Config) GetDescription

func (c *Config) GetDescription() string

GetDescription returns the name description of the current session

func (*Config) GetDomain added in v2.20.0

func (c *Config) GetDomain() string

GetDomain gets the custom Cumulocity domain for cases where it differs from the Host

func (*Config) GetDryRunPattern

func (c *Config) GetDryRunPattern() string

GetDryRunPattern pattern used to check if a command should be run using dry run or not if dry run is activated

func (*Config) GetEncryptedString

func (c *Config) GetEncryptedString(key string) string

GetEncryptedString returns string value of a potentially encrypted field in the configuration If the fields starts with the encrypted prefix, then it will be decrypted using the CLI passphrase, otherwise the value will be returned as is.

func (Config) GetEnvKey

func (c Config) GetEnvKey(key string) string

GetEnvKey returns the environment key value associated

func (Config) GetEnvironmentVariables

func (c Config) GetEnvironmentVariables(client *c8y.Client, setPassword bool) map[string]interface{}

GetEnvironmentVariables gets all the environment variables associated with the current session

func (*Config) GetHeader

func (c *Config) GetHeader() []string

GetHeader get custom headers

func (*Config) GetHomeDir

func (c *Config) GetHomeDir() string

GetHomeDir get the home directory related to the cli tool

func (*Config) GetHost

func (c *Config) GetHost() string

GetHost returns the Cumulocity host URL

func (*Config) GetIncludeAllDelay

func (c *Config) GetIncludeAllDelay() int64

GetIncludeAllDelay include all delay in milliseconds

func (*Config) GetIncludeAllPageSize

func (c *Config) GetIncludeAllPageSize() int

GetIncludeAllPageSize get page size used for include all pagination

func (*Config) GetJSONFilter

func (c *Config) GetJSONFilter() []string

GetJSONFilter get json filter to be applied to the output

func (*Config) GetJSONSelect

func (c *Config) GetJSONSelect() []string

GetJSONSelect get json properties to be selected from the output. Only the given properties will be returned

func (*Config) GetLoginType

func (c *Config) GetLoginType() string

GetLoginType get the preferred login type

func (*Config) GetMaxJobs

func (c *Config) GetMaxJobs() int64

GetMaxJobs maximum number of jobs allowed to run

func (*Config) GetMaxWorkers

func (c *Config) GetMaxWorkers() int

GetMaxWorkers maximum number of workers allowed. If the number of works is larger than this value then an error will be raised

func (*Config) GetName

func (c *Config) GetName() string

GetName returns the name of the current session

func (*Config) GetOutputCommonOptions

func (c *Config) GetOutputCommonOptions(cmd *cobra.Command) (CommonCommandOptions, error)

GetOutputCommonOptions get common output options which controls how the output should be handled i.e. json filter, selects, csv etc.

func (*Config) GetOutputFile

func (c *Config) GetOutputFile() string

GetOutputFileRaw file path where the parsed response will be saved to

func (*Config) GetOutputFileRaw

func (c *Config) GetOutputFileRaw() string

GetOutputFileRaw file path where the raw output file will be saved to

func (*Config) GetOutputFormat

func (c *Config) GetOutputFormat() OutputFormat

GetOutputFormat Get output format type, i.e. json, csv, table etc.

func (*Config) GetOutputTemplate added in v2.32.0

func (c *Config) GetOutputTemplate() string

GetOutputTemplate returns the output template to use when processing the output

func (*Config) GetPageSize

func (c *Config) GetPageSize() int

GetPageSize get page size

func (*Config) GetPassword

func (c *Config) GetPassword() (string, error)

GetPassword returns the decrypted password of the current session

func (*Config) GetPathSlice

func (c *Config) GetPathSlice(name string) (paths []string)

GetPathSlice get a slice of paths

func (*Config) GetProgressBar added in v2.16.0

func (c *Config) GetProgressBar(w io.Writer, enable bool) (progress *mpb.Progress)

func (*Config) GetQueryParameters

func (c *Config) GetQueryParameters() []string

GetQueryParameters get custom query parameters

func (*Config) GetSessionFile

func (c *Config) GetSessionFile(overrideSession ...string) string

GetSessionFile detect the session file path

func (*Config) GetSessionHomeDir

func (c *Config) GetSessionHomeDir() string

func (*Config) GetSilentExit

func (c *Config) GetSilentExit() bool

GetSilentExit silent status codes don't affect the exit code

func (*Config) GetSilentStatusCodes

func (c *Config) GetSilentStatusCodes() string

GetSilentStatusCodes Status codes which will not print out an error message

func (*Config) GetString

func (c *Config) GetString(key string) string

GetString returns a string from the configuration

func (*Config) GetStringSlice

func (c *Config) GetStringSlice(key string) []string

GetStringSlice returns a slice of strings

func (*Config) GetTOTP

func (c *Config) GetTOTP(t time.Time) (string, error)

GetTOTP returns a TOTP generated by a TOTP secret (if present)

func (*Config) GetTemplatePaths

func (c *Config) GetTemplatePaths() []string

GetTemplatePaths template folders where the template files are located

func (*Config) GetTenant

func (c *Config) GetTenant() string

GetTenant returns the Cumulocity tenant id

func (*Config) GetToken

func (c *Config) GetToken() (string, error)

GetToken return the decrypted token from the current session

func (*Config) GetTotalPages

func (c *Config) GetTotalPages() int64

GetTotalPages get total pages to return

func (*Config) GetUsername

func (c *Config) GetUsername() string

GetUsername returns the Cumulocity username for the session

func (*Config) GetViewPaths

func (c *Config) GetViewPaths() []string

GetViewPaths get list of view paths

func (*Config) GetWorkers

func (c *Config) GetWorkers() int

GetWorkers number of workers to use. If the total workers exceeds the maximum allowed workers then a warning will be logged and the maximum value will be used instead.

func (Config) HasEncryptedProperties

func (c Config) HasEncryptedProperties() bool

HasEncryptedProperties check if some fields are encrypted

func (*Config) HideSensitive

func (c *Config) HideSensitive() bool

HideSensitive hide sensitive information in log entries

func (*Config) HideSensitiveInformationIfActive

func (c *Config) HideSensitiveInformationIfActive(client *c8y.Client, message string) string

func (*Config) IgnoreAcceptHeader

func (c *Config) IgnoreAcceptHeader() bool

IgnoreAcceptHeader ignore accept header

func (*Config) IgnoreProxy

func (c *Config) IgnoreProxy() bool

IgnoreProxy ignore proxy settings

func (*Config) IncludeAll

func (c *Config) IncludeAll() bool

IncludeAll return all available results

func (*Config) IsCIMode

func (c *Config) IsCIMode() bool

IsCIMode return true if the cli is running in CI mode

func (*Config) IsCSVOutput

func (c *Config) IsCSVOutput() bool

IsCSVOutput check if csv output is enabled

func (*Config) IsCompletionOutput added in v2.30.0

func (c *Config) IsCompletionOutput() bool

func (*Config) IsEncryptionEnabled

func (c *Config) IsEncryptionEnabled() bool

IsEncryptionEnabled indicates if session encryption is enabled or not

func (*Config) IsPasswordEncrypted

func (c *Config) IsPasswordEncrypted() bool

IsPasswordEncrypted return true if the password is encrypted If the password is empty then treat it as encrypted

func (*Config) IsResponseOutput

func (c *Config) IsResponseOutput() bool

IsResponseOutput check if raw server response should be used

func (*Config) IsTSVOutput added in v2.30.0

func (c *Config) IsTSVOutput() bool

func (*Config) IsTokenEncrypted

func (c *Config) IsTokenEncrypted() bool

func (*Config) KeyFile

func (c *Config) KeyFile() string

KeyFile path to the key file used to test encryption

func (*Config) LogErrorF

func (c *Config) LogErrorF(err error, format string, args ...interface{})

LogErrorF dynamically changes where the error is logged based on the users Silent Status Codes preferences Silent errors are only logged on the INFO level, where as non-silent errors are logged on the ERROR level

func (*Config) MustGetPassword

func (c *Config) MustGetPassword() string

MustGetPassword returns the decrypted password if there are no encryption errors, otherwise it will return an encrypted password

func (*Config) MustGetToken

func (c *Config) MustGetToken() string

MustGetToken returns the decrypted token if there are no encryption errors, otherwise it will return an encrypted value

func (*Config) Proxy

func (c *Config) Proxy() string

Proxy http/s proxy settings

func (*Config) RawOutput

func (c *Config) RawOutput() bool

RawOutput return raw (original) response

func (*Config) ReadConfig

func (c *Config) ReadConfig(file string) error

ReadConfig reads the given file and loads it into the persistent session config

func (*Config) ReadConfigFiles

func (c *Config) ReadConfigFiles(client *c8y.Client) (path string, err error)

ReadConfigFiles reads multiple configuration files to load the c8y session and other settings

The session files are 1. load settings (from C8Y_SESSION_HOME path) 2. load session file (by path) 3. load session file (by name)

func (*Config) ReadKeyFile

func (c *Config) ReadKeyFile() error

ReadKeyFile reads the key file used as a reference to validate encryption (i.e. when no sessions exist)

func (*Config) RegisterTemplateResolver added in v2.32.0

func (c *Config) RegisterTemplateResolver(resolver flags.Resolver)

func (*Config) RequestTimeout

func (c *Config) RequestTimeout() time.Duration

RequestTimeout timeout to use when sending requests

func (*Config) SaveClientConfig

func (c *Config) SaveClientConfig(client *c8y.Client) error

SaveClientConfig save client settings to the session configuration

func (*Config) SetAliases

func (c *Config) SetAliases(v map[string]string)

SetAliases set aliases for the current session

func (*Config) SetCumulocityVersion added in v2.33.0

func (c *Config) SetCumulocityVersion(p string)

SetCumulocityVersion sets the Cumulocity version

func (*Config) SetEncryptedString

func (c *Config) SetEncryptedString(key, value string) error

SetEncryptedString encrypts and sets a value in the configuration. If the give value is empty, then the value will be read from the configuration file

func (*Config) SetLogger

func (c *Config) SetLogger(l *logger.Logger)

SetLogger sets the logger

func (*Config) SetPassword

func (c *Config) SetPassword(p string)

SetPassword sets the password

func (*Config) SetSessionFile

func (c *Config) SetSessionFile(path string)

func (*Config) SetTenant

func (c *Config) SetTenant(value string)

SetTenant sets the tenant name

func (*Config) SetToken

func (c *Config) SetToken(p string)

SetToken sets the token used for OAUTH authentication

func (*Config) ShouldConfirm

func (c *Config) ShouldConfirm(methods ...string) bool

func (*Config) ShouldUseDryRun

func (c *Config) ShouldUseDryRun(commandLine string) bool

ShouldUseDryRun returns true of dry run should be applied to the command based on the type of method

func (*Config) ShowProgress

func (c *Config) ShowProgress() bool

ShowProgress show progress bar

func (*Config) SkipSSLVerify

func (c *Config) SkipSSLVerify() bool

SkipSSLVerify skip SSL verify

func (*Config) StorePassword

func (c *Config) StorePassword() bool

StorePassword controls if the password is saved to the session file or not

func (*Config) StoreToken

func (c *Config) StoreToken() bool

StoreToken controls if the tokens are saved to the session file or not

func (*Config) Verbose

func (c *Config) Verbose() bool

Verbose show verbose messages

func (*Config) ViewColumnEmptyValueMinWidth added in v2.18.0

func (c *Config) ViewColumnEmptyValueMinWidth() int

ViewColumnEmptyValueMinWidth minimum column width in characters

func (*Config) ViewColumnMaxWidth

func (c *Config) ViewColumnMaxWidth() int

ViewColumnMinWidth maximum column width in characters

func (*Config) ViewColumnMinWidth

func (c *Config) ViewColumnMinWidth() int

ViewColumnMinWidth minimum column width in characters

func (*Config) ViewColumnPadding

func (c *Config) ViewColumnPadding() int

ViewColumnPadding column padding

func (*Config) ViewOption

func (c *Config) ViewOption() string

ViewOption controls whether views are applied the output or not

func (*Config) ViewRowMode added in v2.18.0

func (c *Config) ViewRowMode() string

ViewRowMode get view row rendering mode (truncation or wrapping)

func (*Config) WithError

func (c *Config) WithError() bool

WithError return the error response on stdout rather than stderr

func (*Config) WithOptions

func (c *Config) WithOptions(opts ...Option) error

func (*Config) WithTotalElements added in v2.16.0

func (c *Config) WithTotalElements() bool

WithTotalElements return total of all elements

func (*Config) WithTotalPages

func (c *Config) WithTotalPages() bool

WithTotalPages return all available results

func (*Config) WorkerDelay

func (c *Config) WorkerDelay() time.Duration

WorkerDelay delay in milliseconds to wait after each request before the worker processes a new job (request)

func (*Config) WorkerDelayBefore

func (c *Config) WorkerDelayBefore() time.Duration

WorkerDelayBefore delay in milliseconds to wait before each request

func (*Config) WritePersistentConfig

func (c *Config) WritePersistentConfig() error

WritePersistentConfig saves the configuration to file

type EncryptionSettings

type EncryptionSettings struct {
	CachePassphrase *bool `json:"cachePassphrase,omitempty"`
	Enabled         *bool `json:"enabled,omitempty"`
}

EncryptionSettings encryption settings

type ErrDecrypt

type ErrDecrypt struct {
	Err error
}

func (ErrDecrypt) Error

func (e ErrDecrypt) Error() string

type IncludeAllSettings

type IncludeAllSettings struct {
	DelayMS  *int `json:"delayMS,omitempty"`
	PageSize *int `json:"pageSize,omitempty"`
}

IncludeAllSettings controls the pagination parameters used when paging through all results

type ModeSettings

type ModeSettings struct {
	Confirmation string `json:"confirmation,omitempty"`
	EnableCreate *bool  `json:"enableCreate,omitempty"`
	EnableUpdate *bool  `json:"enableUpdate,omitempty"`
	EnableDelete *bool  `json:"enableDelete,omitempty"`
}

ModeSettings controls which types of commands are disabled or not

type Option

type Option func(*Config) error

Option cli configuration option

type OutputFormat

type OutputFormat int
const (
	// OutputJSON json output
	OutputJSON OutputFormat = iota

	// OutputTable table output
	OutputTable

	// OutputCSV csv output
	OutputCSV

	// OutputTSV tsv output
	OutputTSV

	// OutputCompletion completion output format, e.g. {value}\t{key1}: {value1} | {key2}: {value2}
	OutputCompletion

	// OutputCSVWithHeader csv output with header
	OutputCSVWithHeader

	// OutputServerResponse unparsed output as received from the server
	OutputServerResponse
)

func (OutputFormat) FromString

func (f OutputFormat) FromString(name string) OutputFormat

func (OutputFormat) String

func (f OutputFormat) String() string

type SessionSettings

type SessionSettings struct {
	DefaultUsername string `json:"defaultUsername,omitempty"`
}

type StorageSettings

type StorageSettings struct {
	StoreToken    *bool `json:"storeToken,omitempty"`
	StorePassword *bool `json:"storePassword,omitempty"`
}

StorageSettings storage settings whether passwords and tokens are stored

type TemplateSettings

type TemplateSettings struct {
	Path string `json:"path,omitempty"`
}

TemplateSettings controls the jsonnet template settings

type ViewSettings

type ViewSettings struct {
	CommonPaths string `json:"commonPaths,omitempty"`
	CustomPaths string `json:"customPaths,omitempty"`
}

ViewSettings controls the console table view settings

Jump to

Keyboard shortcuts

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