cmd

package
v0.0.0-...-982e07a Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 31 Imported by: 6

Documentation

Overview

Package cmd contains shared settings/constants among most of Acra component utilities.

Index

Constants

View Source
const (
	DefaultAcraConnectorPort               = 9494
	DefaultAcraConnectorAPIPort            = 9191
	DefaultAcraConnectorConnectionProtocol = "tcp"
	DefaultAcraConnectorHost               = "127.0.0.1"
	DefaultAcraServerHost                  = "0.0.0.0"
	DefaultAcraServerPort                  = 9393
	DefaultAcraServerAPIPort               = 9090
	DefaultAcraServerConnectionProtocol    = "tcp"
	DefaultAcraTranslatorGRPCHost          = "0.0.0.0"
	DefaultAcraTranslatorGRPCPort          = 9696
)

Acra component constants: default port, host, names, path.

View Source
const (
	BuildInfoEditionLabel = "edition"
	BuildInfoVersionLabel = "version"
)

Type of binary version

Variables

View Source
var (
	ErrDumpRequested = errors.New("configurtion dump requested")
)

Argument and configuration parsing errors.

View Source
var ErrIdenticalRedisDBs = errors.New("redis db params are identical")

ErrIdenticalRedisDBs redis DBs related error

View Source
var ErrInvalidJaegerExporterEndpoint = errors.New("empty jaeger_agent_endpoint and jaeger_collector_endpoint")

ErrInvalidJaegerExporterEndpoint incorrect endpoint for jaeger

Functions

func ConfigPath

func ConfigPath(defaultPath string) string

ConfigPath returns path to configuration file. The given default value is used, unless it has been overridden on the command line.

func DumpConfig

func DumpConfig(configPath, serviceName string, useDefault bool) error

DumpConfig writes CLI params to configPath

func DumpConfigFromFlagSets

func DumpConfigFromFlagSets(flagSets []*flag_.FlagSet, configPath, serviceName string, useDefault bool) error

DumpConfigFromFlagSets writes CLI params to configPath

func GenerateMarkdownDoc

func GenerateMarkdownDoc(output io.Writer, serviceName string)

GenerateMarkdownDoc generates Markdown file from CLI params

func GenerateMarkdownDocFromFlagSets

func GenerateMarkdownDocFromFlagSets(flagSets []*flag_.FlagSet, output io.Writer, serviceName string)

GenerateMarkdownDocFromFlagSets generates Markdown file from CLI flag sets.

func GenerateYaml

func GenerateYaml(output io.Writer, useDefault bool)

GenerateYaml generates YAML file from CLI params

func GenerateYamlFromFlagSets

func GenerateYamlFromFlagSets(flagSets []*flag_.FlagSet, output io.Writer, useDefault bool)

GenerateYamlFromFlagSets generates YAML file from CLI flag sets.

func GetJaegerCmdParameters

func GetJaegerCmdParameters() jaeger.Options

GetJaegerCmdParameters return jaeger.Options parsed from config/cmd parameters

func IsTraceToJaegerOn

func IsTraceToJaegerOn() bool

IsTraceToJaegerOn return true if turned on tracing to jaeger

func IsTraceToLogOn

func IsTraceToLogOn() bool

IsTraceToLogOn return true if turned on tracing to log output

func ParseConfig

func ParseConfig(configPath, serviceName string) (map[string]string, error)

ParseConfig parse service config by configPath if exists

func ParseFlags

func ParseFlags(flags *flag_.FlagSet, arguments []string) error

ParseFlags parses CommandLine flags or return ErrDumpRequested if requested.

func PrintFlags

func PrintFlags(flags *flag_.FlagSet)

PrintFlags pretty-prints CLI flag set with default values to stderr.

func RandomStringBytes

func RandomStringBytes(n int) string

RandomStringBytes getting random string using faster randSrc.Int63() and true distribution for letterBytes.

func RegisterBuildInfoMetrics

func RegisterBuildInfoMetrics(serviceName string, edition utils.ProductEdition)

RegisterBuildInfoMetrics set and register metrics with build info

func RegisterJaegerCmdParameters

func RegisterJaegerCmdParameters()

RegisterJaegerCmdParameters register cli parameters with flag for jaeger options

func RegisterRedisKeystoreParameters

func RegisterRedisKeystoreParameters()

RegisterRedisKeystoreParameters registers Redis keystore parameters with given CommandLine flags and empty prefix

func RegisterRedisKeystoreParametersWithPrefix

func RegisterRedisKeystoreParametersWithPrefix(flags *flag.FlagSet, prefix string, description string)

RegisterRedisKeystoreParametersWithPrefix registers Redis keystore parameters with given flag set and prefix. Use empty prefix, or something like "src_" or "dst_", for example.

func RegisterRedisTokenStoreParameters

func RegisterRedisTokenStoreParameters()

RegisterRedisTokenStoreParameters registers Redis TokenStore parameters with given CommandLine flags and empty prefix

func RegisterRedisTokenStoreParametersWithPrefix

func RegisterRedisTokenStoreParametersWithPrefix(flags *flag.FlagSet, prefix string, description string)

RegisterRedisTokenStoreParametersWithPrefix registers Redis keystore parameters with given flag set and prefix. Use empty prefix, or something like "src_" or "dst_", for example.

func RegisterTracingCmdParameters

func RegisterTracingCmdParameters()

RegisterTracingCmdParameters register cli parameters with flag for tracing

func RegisterVersionMetrics

func RegisterVersionMetrics(serviceName string, version *utils.Version)

RegisterVersionMetrics set and register metrics with current version value

func RunPrometheusHTTPHandler

func RunPrometheusHTTPHandler(connectionString string) (net.Listener, *http.Server, error)

RunPrometheusHTTPHandler run in goroutine http server that process with connectionString address and export prometheus metrics

func SetupTracing

func SetupTracing(serviceName string)

SetupTracing with global options related with exporters

func ValidateClientID

func ValidateClientID(clientID string)

ValidateClientID checks that clientID has digits, letters, _ - ' '

func ValidateJaegerCmdParameters

func ValidateJaegerCmdParameters() error

ValidateJaegerCmdParameters validate cli parameters

func ValidateRedisCLIOptions

func ValidateRedisCLIOptions(redisOptions *RedisOptions)

ValidateRedisCLIOptions validate Redis CLI options.

Types

type Argon2Params

type Argon2Params struct {
	Time    uint32
	Memory  uint32
	Threads uint8
	Length  uint32
}

Argon2Params describes params for Argon2 hashing

type RedisOptions

type RedisOptions struct {
	HostPort  string
	Password  string
	DBKeys    int
	DBTokens  int
	TLSEnable bool
}

RedisOptions keep command-line options related to Redis database configuration.

func GetTestRedisOptions

func GetTestRedisOptions(t *testing.T) RedisOptions

GetTestRedisOptions returns options configured with test env variables use this function for tests

func ParseRedisCLIParameters

func ParseRedisCLIParameters(extractor *args.ServiceExtractor) *RedisOptions

ParseRedisCLIParameters parse RedisOptions from CommandLine flags

func ParseRedisCLIParametersFromFlags

func ParseRedisCLIParametersFromFlags(extractor *args.ServiceExtractor, prefix string) *RedisOptions

ParseRedisCLIParametersFromFlags parse CLI args from FlagSet

func (*RedisOptions) KeysConfigured

func (redis *RedisOptions) KeysConfigured() bool

KeysConfigured returns true if Redis is configured for key storage.

func (*RedisOptions) KeysOptions

func (redis *RedisOptions) KeysOptions(extractor *args.ServiceExtractor) (*goRedis.Options, error)

KeysOptions returns Redis connection configuration for key storage.

func (*RedisOptions) TokensConfigured

func (redis *RedisOptions) TokensConfigured() bool

TokensConfigured returns true if Redis is configured for token storage.

type SignalCallback

type SignalCallback func()

SignalCallback callback function

type SignalHandler

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

SignalHandler sends Signal to listeners and call registered callbacks

func NewSignalHandler

func NewSignalHandler(handledSignals []os.Signal) (*SignalHandler, error)

NewSignalHandler returns new SignalHandler registered for particular os.Signals

func (*SignalHandler) AddCallback

func (handler *SignalHandler) AddCallback(callback SignalCallback)

AddCallback to callbacks list

func (*SignalHandler) AddListener

func (handler *SignalHandler) AddListener(listener net.Listener)

AddListener to listeners list

func (*SignalHandler) GetChannel

func (handler *SignalHandler) GetChannel() chan os.Signal

GetChannel returns channel of os.Signal

func (*SignalHandler) Register

func (handler *SignalHandler) Register()

Register should be called as goroutine

func (*SignalHandler) RegisterWithContext

func (handler *SignalHandler) RegisterWithContext(globalContext context.Context)

RegisterWithContext is a no-exit version of Register function with context usage

type UserAuth

type UserAuth struct {
	Salt string
	Argon2Params
	Hash []byte
}

UserAuth describes user params for password hashing: salt, params, hash

func (UserAuth) UserAuthString

func (auth UserAuth) UserAuthString(userDataDelimiter string, paramsDelimiter string) string

UserAuthString returns string representation of UserAuth

Directories

Path Synopsis
Package main is entry point for AcraKeymaker utility.
Package main is entry point for AcraKeymaker utility.
Package main is entry point for `acra-keys` utility.
Package main is entry point for `acra-keys` utility.
Package main is entry point for AcraPoisonRecordsMaker utility.
Package main is entry point for AcraPoisonRecordsMaker utility.
Package main is entry point for AcraRollback utility.
Package main is entry point for AcraRollback utility.
Package main is entry point for acra-rotate.
Package main is entry point for acra-rotate.
Package main is entry point for AcraServer utility.
Package main is entry point for AcraServer utility.
Package main is entry point for `acra-tokens` utility used to manipulate token stores.
Package main is entry point for `acra-tokens` utility used to manipulate token stores.
tokens
Package tokens defines reusable business logic of "acra-tokens" utility.
Package tokens defines reusable business logic of "acra-tokens" utility.
Package main is entry point for AcraTranslator service.
Package main is entry point for AcraTranslator service.
common
Package common has shared data betwee gRPC API handler and HTTP API handler.
Package common has shared data betwee gRPC API handler and HTTP API handler.

Jump to

Keyboard shortcuts

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