Documentation ¶
Index ¶
- Constants
- Variables
- func GetSettingsName(flagName string) string
- func GetSettingsNameWithoutPrefix(name string) string
- func SetMode(v *viper.Viper, mode string) error
- func SupportsFileExtension(p string) bool
- func WithBindEnv(name string, defaultValue interface{}) func(*Config) error
- func WithBoolEnvOverride(name string, envName string) func(*Config) error
- func WithDefault(name string, defaultValue interface{}) func(*Config) error
- type ActivityLogSettings
- type CommandSettings
- type CommonCommandOptions
- type Config
- func (c *Config) AbortOnErrorCount() int
- func (c *Config) ActivityLogEnabled() bool
- func (c *Config) Aliases() map[string]string
- func (c *Config) AllSettings() map[string]interface{}
- func (c *Config) AllowEmptyPipe() bool
- func (c *Config) AllowModeCreate() bool
- func (c *Config) AllowModeDelete() bool
- func (c *Config) AllowModeUpdate() bool
- func (c *Config) BindAuthorization() error
- func (c *Config) BindPFlag(flags *pflag.FlagSet) error
- func (c *Config) Browser() string
- func (c *Config) CacheBodyKeys() []string
- func (c *Config) CacheDir() string
- func (c *Config) CacheEnabled() bool
- func (c *Config) CacheKeyIncludeAuth() bool
- func (c *Config) CacheKeyIncludeHost() bool
- func (c *Config) CacheMethods() string
- func (c *Config) CacheMode() c8y.StoreMode
- func (c *Config) CachePassphraseVariables() bool
- func (c *Config) CacheTTL() time.Duration
- func (c *Config) CheckEncryption(encryptedText ...string) (string, error)
- func (c *Config) CommonAliases() map[string]string
- func (c *Config) CompactJSON() bool
- func (c *Config) ConfirmText() string
- func (c *Config) CreateKeyFile(keyText string) error
- func (c *Config) Debug() bool
- func (c Config) DebugViper()
- func (c Config) DecryptAllProperties() (err error)
- func (c *Config) DecryptSession() error
- func (c *Config) DecryptString(value string) (string, error)
- func (c *Config) DefaultHost() string
- func (c *Config) DisableColor() bool
- func (c *Config) DisableProgress() bool
- func (c *Config) DisableStdin() bool
- func (c *Config) DryRun() bool
- func (c *Config) DryRunFormat() string
- func (c *Config) EncryptionEnabled() bool
- func (c *Config) ExpandHomePath(path string) string
- func (c *Config) ExtensionDefaultUsername() string
- func (c *Config) ExtensionsDataDir() string
- func (c *Config) FlattenJSON() bool
- func (c *Config) Force() bool
- func (c *Config) ForceConfirm() bool
- func (c *Config) GetActivityLogMethodFilter() string
- func (c *Config) GetActivityLogPath() string
- func (c *Config) GetConfigPath() string
- func (c *Config) GetConfirmationMethods() string
- func (c *Config) GetCumulocityVersion() string
- func (c *Config) GetCurrentPage() int64
- func (c *Config) GetDefaultUsername() string
- func (c *Config) GetDescription() string
- func (c *Config) GetDomain() string
- func (c *Config) GetDryRunPattern() string
- func (c *Config) GetEncryptedString(key string) string
- func (c Config) GetEnvKey(key string) string
- func (c Config) GetEnvironmentVariables(client *c8y.Client, setPassword bool) map[string]interface{}
- func (c *Config) GetHeader() []string
- func (c *Config) GetHomeDir() string
- func (c *Config) GetHost() string
- func (c *Config) GetIncludeAllDelay() int64
- func (c *Config) GetIncludeAllPageSize() int
- func (c *Config) GetJSONFilter() []string
- func (c *Config) GetJSONSelect() []string
- func (c *Config) GetLoginType() string
- func (c *Config) GetMaxJobs() int64
- func (c *Config) GetMaxWorkers() int
- func (c *Config) GetName() string
- func (c *Config) GetOutputCommonOptions(cmd *cobra.Command) (CommonCommandOptions, error)
- func (c *Config) GetOutputFile() string
- func (c *Config) GetOutputFileRaw() string
- func (c *Config) GetOutputFormat() OutputFormat
- func (c *Config) GetOutputTemplate() string
- func (c *Config) GetPageSize() int
- func (c *Config) GetPassword() (string, error)
- func (c *Config) GetPathSlice(name string) (paths []string)
- func (c *Config) GetProgressBar(w io.Writer, enable bool) (progress *mpb.Progress)
- func (c *Config) GetQueryParameters() []string
- func (c *Config) GetSessionFile(overrideSession ...string) string
- func (c *Config) GetSessionHomeDir() string
- func (c *Config) GetSilentExit() bool
- func (c *Config) GetSilentStatusCodes() string
- func (c *Config) GetString(key string) string
- func (c *Config) GetStringSlice(key string) []string
- func (c *Config) GetTOTP(t time.Time) (string, error)
- func (c *Config) GetTemplatePaths() []string
- func (c *Config) GetTenant() string
- func (c *Config) GetToken() (string, error)
- func (c *Config) GetTotalPages() int64
- func (c *Config) GetUsername() string
- func (c *Config) GetViewPaths() []string
- func (c *Config) GetWorkers() int
- func (c Config) HasEncryptedProperties() bool
- func (c *Config) HideSensitive() bool
- func (c *Config) HideSensitiveInformationIfActive(client *c8y.Client, message string) string
- func (c *Config) IgnoreAcceptHeader() bool
- func (c *Config) IgnoreProxy() bool
- func (c *Config) IncludeAll() bool
- func (c *Config) IsCIMode() bool
- func (c *Config) IsCSVOutput() bool
- func (c *Config) IsCompletionOutput() bool
- func (c *Config) IsEncryptionEnabled() bool
- func (c *Config) IsPasswordEncrypted() bool
- func (c *Config) IsResponseOutput() bool
- func (c *Config) IsTSVOutput() bool
- func (c *Config) IsTokenEncrypted() bool
- func (c *Config) KeyFile() string
- func (c *Config) LogErrorF(err error, format string, args ...interface{})
- func (c *Config) MustGetPassword() string
- func (c *Config) MustGetToken() string
- func (c *Config) Proxy() string
- func (c *Config) RawOutput() bool
- func (c *Config) ReadConfig(file string) error
- func (c *Config) ReadConfigFiles(client *c8y.Client) (path string, err error)
- func (c *Config) ReadKeyFile() error
- func (c *Config) RegisterTemplateResolver(resolver flags.Resolver)
- func (c *Config) RequestTimeout() time.Duration
- func (c *Config) SaveClientConfig(client *c8y.Client) error
- func (c *Config) SetAliases(v map[string]string)
- func (c *Config) SetCumulocityVersion(p string)
- func (c *Config) SetEncryptedString(key, value string) error
- func (c *Config) SetLogger(l *logger.Logger)
- func (c *Config) SetPassword(p string)
- func (c *Config) SetSessionFile(path string)
- func (c *Config) SetTenant(value string)
- func (c *Config) SetToken(p string)
- func (c *Config) ShouldConfirm(methods ...string) bool
- func (c *Config) ShouldUseDryRun(commandLine string) bool
- func (c *Config) ShowProgress() bool
- func (c *Config) SkipSSLVerify() bool
- func (c *Config) StorePassword() bool
- func (c *Config) StoreToken() bool
- func (c *Config) Verbose() bool
- func (c *Config) ViewColumnEmptyValueMinWidth() int
- func (c *Config) ViewColumnMaxWidth() int
- func (c *Config) ViewColumnMinWidth() int
- func (c *Config) ViewColumnPadding() int
- func (c *Config) ViewOption() string
- func (c *Config) ViewRowMode() string
- func (c *Config) WithError() bool
- func (c *Config) WithOptions(opts ...Option) error
- func (c *Config) WithTotalElements() bool
- func (c *Config) WithTotalPages() bool
- func (c *Config) WorkerDelay() time.Duration
- func (c *Config) WorkerDelayBefore() time.Duration
- func (c *Config) WritePersistentConfig() error
- type EncryptionSettings
- type ErrDecrypt
- type IncludeAllSettings
- type ModeSettings
- type Option
- type OutputFormat
- type SessionSettings
- type StorageSettings
- type TemplateSettings
- type ViewSettings
Constants ¶
const ( EnvSettingsPrefix = "c8y" // SettingsGlobalName name of the settings file (without extension) SettingsGlobalName = "settings" )
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" )
const ( ViewsOff = "off" ViewsAuto = "auto" )
Variables ¶
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" )
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" )
var ConfigExtensions = []string{"json", "yaml", "yml", "env", "toml", "properties"}
var PathSplitChar = ":"
var (
SettingsDefaultsPrefix = "settings.defaults"
)
var SettingsToken = "token"
Functions ¶
func GetSettingsName ¶
GetSettingsName get the settings name from a flag name
func GetSettingsNameWithoutPrefix ¶ added in v2.20.0
GetSettingsNameWithoutPrefix converts the setting name without the settings prefix
func SupportsFileExtension ¶
SupportsFileExtension check if a filepath is using a supported extension or not
func WithBindEnv ¶
func WithBoolEnvOverride ¶ added in v2.18.0
WithBoolEnvOverride support optional override boolean variable
func WithDefault ¶
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 (*Config) AbortOnErrorCount ¶
AbortOnErrorTotal abort when the number of errors reaches this value
func (*Config) ActivityLogEnabled ¶
ActivityLogEnabled enables/disables the activity log
func (*Config) AllSettings ¶
AllSettings get all the settings as a map
func (*Config) AllowEmptyPipe ¶
AllowEmptyPipe check if empty piped data is allowed
func (*Config) AllowModeCreate ¶
AllowModeCreate enables create (post) commands
func (*Config) AllowModeDelete ¶
AllowModeDelete enables delete commands
func (*Config) AllowModeUpdate ¶
AllowModeUpdate enables update commands
func (*Config) BindAuthorization ¶
BindAuthorization binds environment variables related to the authrorization to the configuration
func (*Config) BindPFlag ¶
BindPFlag binds flags to the configuration Configuration precendence is: 1. Arguments 2. Environment variables 3. Session configuration 4. Global configuration
func (*Config) CacheBodyKeys ¶ added in v2.15.0
func (*Config) CacheEnabled ¶
CacheEnabled shows if caching is enabled or not
func (*Config) CacheKeyIncludeAuth ¶
CacheKeyIncludeAuth include authorization cache key generation
func (*Config) CacheKeyIncludeHost ¶
CacheKeyIncludeHost include full host name in cache key generation
func (*Config) CacheMethods ¶
CacheMethods HTTP methods which should be cached
func (*Config) CachePassphraseVariables ¶
CachePassphraseVariables return true if the passphrase variables should be persisted or not
func (*Config) CacheTTL ¶
CacheTTL cache time-to-live. After the duration then the cache will no longer be used.
func (*Config) CheckEncryption ¶
CheckEncryption checks if the usuer has provided the correct encryption password or not by testing the decryption of the secret text
func (*Config) CommonAliases ¶
CommonAliases Get common aliases from the global configuration file deprecated in favor of extensions
func (*Config) CompactJSON ¶
CompactJSON show compact json output
func (*Config) ConfirmText ¶
ConfirmText custom confirmation text to use to prompt the user of an action
func (*Config) CreateKeyFile ¶
CreateKeyFile creates a file used as reference to validate encryption
func (Config) DecryptAllProperties ¶
DecryptAllProperties decrypt all properties
func (*Config) DecryptSession ¶
DecryptSession decrypts a session (as long as the encryption passphrase has already been provided)
func (*Config) DecryptString ¶
DecryptString returns the decrypted string if the string is encrypted
func (*Config) DefaultHost ¶ added in v2.30.0
func (*Config) DisableColor ¶
DisableColor don't print console output in color
func (*Config) DisableProgress ¶ added in v2.16.0
DisableProgress don't print progress bar
func (*Config) DisableStdin ¶
DisableStdin hide sensitive information in log entries
func (*Config) DryRun ¶
DryRun dont sent any destructive requests. Just print out what would be sent
func (*Config) DryRunFormat ¶
SettingsDryRunFormat dry run output format. Controls how the dry run information is displayed
func (*Config) EncryptionEnabled ¶
EncryptionEnabled enables encryption when storing sensitive session data
func (*Config) ExpandHomePath ¶
ExpandHomePath expand home path references found in the path
func (*Config) ExtensionDefaultUsername ¶ added in v2.30.0
func (*Config) ExtensionsDataDir ¶ added in v2.30.0
Get Extension Data Directory
func (*Config) FlattenJSON ¶
FlattenJSON flatten nested json using dot notation
func (*Config) ForceConfirm ¶
ForceConfirm force prompt for confirmation
func (*Config) GetActivityLogMethodFilter ¶
GetActivityLogMethodFilter filters the activity log entries by a space delimited methods, i.e. GET POST PUT
func (*Config) GetActivityLogPath ¶
GetActivityLogPath path where the activity log will be stored
func (*Config) GetConfigPath ¶
GetConfigPath get global settings file path
func (*Config) GetConfirmationMethods ¶
GetConfirmationMethods get HTTP methods that require confirmation
func (*Config) GetCumulocityVersion ¶ added in v2.33.0
GetCumulocityVersion gets Cumulocity version
func (*Config) GetCurrentPage ¶
GetCurrentPage get current page
func (*Config) GetDefaultUsername ¶
GetDefaultUsername returns the default username
func (*Config) GetDescription ¶
GetDescription returns the name description of the current session
func (*Config) GetDomain ¶ added in v2.20.0
GetDomain gets the custom Cumulocity domain for cases where it differs from the Host
func (*Config) GetDryRunPattern ¶
GetDryRunPattern pattern used to check if a command should be run using dry run or not if dry run is activated
func (*Config) GetEncryptedString ¶
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) 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) GetHomeDir ¶
GetHomeDir get the home directory related to the cli tool
func (*Config) GetIncludeAllDelay ¶
GetIncludeAllDelay include all delay in milliseconds
func (*Config) GetIncludeAllPageSize ¶
GetIncludeAllPageSize get page size used for include all pagination
func (*Config) GetJSONFilter ¶
GetJSONFilter get json filter to be applied to the output
func (*Config) GetJSONSelect ¶
GetJSONSelect get json properties to be selected from the output. Only the given properties will be returned
func (*Config) GetLoginType ¶
GetLoginType get the preferred login type
func (*Config) GetMaxJobs ¶
GetMaxJobs maximum number of jobs allowed to run
func (*Config) GetMaxWorkers ¶
GetMaxWorkers maximum number of workers allowed. If the number of works is larger than this value then an error will be raised
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 ¶
GetOutputFileRaw file path where the parsed response will be saved to
func (*Config) GetOutputFileRaw ¶
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
GetOutputTemplate returns the output template to use when processing the output
func (*Config) GetPassword ¶
GetPassword returns the decrypted password of the current session
func (*Config) GetPathSlice ¶
GetPathSlice get a slice of paths
func (*Config) GetProgressBar ¶ added in v2.16.0
func (*Config) GetQueryParameters ¶
GetQueryParameters get custom query parameters
func (*Config) GetSessionFile ¶
GetSessionFile detect the session file path
func (*Config) GetSessionHomeDir ¶
func (*Config) GetSilentExit ¶
GetSilentExit silent status codes don't affect the exit code
func (*Config) GetSilentStatusCodes ¶
GetSilentStatusCodes Status codes which will not print out an error message
func (*Config) GetStringSlice ¶
GetStringSlice returns a slice of strings
func (*Config) GetTemplatePaths ¶
GetTemplatePaths template folders where the template files are located
func (*Config) GetTotalPages ¶
GetTotalPages get total pages to return
func (*Config) GetUsername ¶
GetUsername returns the Cumulocity username for the session
func (*Config) GetViewPaths ¶
GetViewPaths get list of view paths
func (*Config) GetWorkers ¶
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 ¶
HasEncryptedProperties check if some fields are encrypted
func (*Config) HideSensitive ¶
HideSensitive hide sensitive information in log entries
func (*Config) HideSensitiveInformationIfActive ¶
func (*Config) IgnoreAcceptHeader ¶
IgnoreAcceptHeader ignore accept header
func (*Config) IncludeAll ¶
IncludeAll return all available results
func (*Config) IsCSVOutput ¶
IsCSVOutput check if csv output is enabled
func (*Config) IsCompletionOutput ¶ added in v2.30.0
func (*Config) IsEncryptionEnabled ¶
IsEncryptionEnabled indicates if session encryption is enabled or not
func (*Config) IsPasswordEncrypted ¶
IsPasswordEncrypted return true if the password is encrypted If the password is empty then treat it as encrypted
func (*Config) IsResponseOutput ¶
IsResponseOutput check if raw server response should be used
func (*Config) IsTSVOutput ¶ added in v2.30.0
func (*Config) IsTokenEncrypted ¶
func (*Config) LogErrorF ¶
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 ¶
MustGetPassword returns the decrypted password if there are no encryption errors, otherwise it will return an encrypted password
func (*Config) MustGetToken ¶
MustGetToken returns the decrypted token if there are no encryption errors, otherwise it will return an encrypted value
func (*Config) ReadConfig ¶
ReadConfig reads the given file and loads it into the persistent session config
func (*Config) ReadConfigFiles ¶
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 ¶
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 (*Config) RequestTimeout ¶
RequestTimeout timeout to use when sending requests
func (*Config) SaveClientConfig ¶
SaveClientConfig save client settings to the session configuration
func (*Config) SetAliases ¶
SetAliases set aliases for the current session
func (*Config) SetCumulocityVersion ¶ added in v2.33.0
SetCumulocityVersion sets the Cumulocity version
func (*Config) SetEncryptedString ¶
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) SetSessionFile ¶
func (*Config) ShouldConfirm ¶
func (*Config) ShouldUseDryRun ¶
ShouldUseDryRun returns true of dry run should be applied to the command based on the type of method
func (*Config) StorePassword ¶
StorePassword controls if the password is saved to the session file or not
func (*Config) StoreToken ¶
StoreToken controls if the tokens are saved to the session file or not
func (*Config) ViewColumnEmptyValueMinWidth ¶ added in v2.18.0
ViewColumnEmptyValueMinWidth minimum column width in characters
func (*Config) ViewColumnMaxWidth ¶
ViewColumnMinWidth maximum column width in characters
func (*Config) ViewColumnMinWidth ¶
ViewColumnMinWidth minimum column width in characters
func (*Config) ViewColumnPadding ¶
ViewColumnPadding column padding
func (*Config) ViewOption ¶
ViewOption controls whether views are applied the output or not
func (*Config) ViewRowMode ¶ added in v2.18.0
ViewRowMode get view row rendering mode (truncation or wrapping)
func (*Config) WithOptions ¶
func (*Config) WithTotalElements ¶ added in v2.16.0
WithTotalElements return total of all elements
func (*Config) WithTotalPages ¶
WithTotalPages return all available results
func (*Config) WorkerDelay ¶
WorkerDelay delay in milliseconds to wait after each request before the worker processes a new job (request)
func (*Config) WorkerDelayBefore ¶
WorkerDelayBefore delay in milliseconds to wait before each request
func (*Config) WritePersistentConfig ¶
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 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