Documentation ¶
Overview ¶
Package tokens defines reusable business logic of "acra-tokens" utility.
Index ¶
- Constants
- Variables
- type CommonDateParameters
- type CommonTokenStorageParameters
- func (p *CommonTokenStorageParameters) BoltDBConfigured() bool
- func (p *CommonTokenStorageParameters) Open(extractor *args.ServiceExtractor) (tokenCommon.TokenStorage, error)
- func (p *CommonTokenStorageParameters) Register(flags *flag.FlagSet)
- func (p *CommonTokenStorageParameters) Validate(extractor *args.ServiceExtractor) error
- type DisableSubcommand
- type EnableSubcommand
- type RemoveSubcommand
- type StatusSubcommand
- type Subcommand
Constants ¶
const CmdTokenDisable = "disable"
CmdTokenDisable is the name of "acra-tokens disable" subcommand.
const CmdTokenEnable = "enable"
CmdTokenEnable is the name of "acra-tokens enable" subcommand.
const CmdTokenRemove = "remove"
CmdTokenRemove is the name of "acra-tokens remove" subcommand.
const CmdTokenStatus = "status"
CmdTokenStatus is the name of "acra-tokens status" subcommand.
const ServiceName = "acra-tokens"
ServiceName constant for logging and configuration parsing.
Variables ¶
var DefaultConfigPath = utils.GetConfigPathByName(ServiceName)
DefaultConfigPath is the default path to service configuration file.
var ErrInvalidDateTime = errors.New("unrecognized date format")
ErrInvalidDateTime is returned when we can't parse the time string provided by the user.
var (
ErrInvalidTokenStorage = errors.New("token storage is configured incorrectly")
)
Errors returned by token storage parameter parsing.
var (
ErrRemoveNotSpecified = errors.New("underspecified removal conditions")
)
Errors returned by "acra-tokens remove" subcommand.
var (
ErrUnknownSubCommand = errors.New("unknown command")
)
Comman-line parsing errors:
Functions ¶
This section is empty.
Types ¶
type CommonDateParameters ¶
type CommonDateParameters struct {
// contains filtered or unexported fields
}
CommonDateParameters is a mix-in of command line parameters for date limits.
func (*CommonDateParameters) AccessedWithinLimits ¶
func (p *CommonDateParameters) AccessedWithinLimits(accessTime time.Time) bool
AccessedWithinLimits returns true if the access time is within specified limits.
func (*CommonDateParameters) CreatedWithinLimits ¶
func (p *CommonDateParameters) CreatedWithinLimits(creationTime time.Time) bool
CreatedWithinLimits returns true if the creation time is within specified limits.
func (*CommonDateParameters) Register ¶
func (p *CommonDateParameters) Register(flags *flag.FlagSet)
Register registers token storage flags with the given flag set.
func (*CommonDateParameters) Validate ¶
func (p *CommonDateParameters) Validate() error
Validate date limit parameters.
type CommonTokenStorageParameters ¶
type CommonTokenStorageParameters struct {
// contains filtered or unexported fields
}
CommonTokenStorageParameters is a mix-in of command line parameters for token storage construction.
func (*CommonTokenStorageParameters) BoltDBConfigured ¶
func (p *CommonTokenStorageParameters) BoltDBConfigured() bool
BoltDBConfigured returns true if BoltDB is configured.
func (*CommonTokenStorageParameters) Open ¶
func (p *CommonTokenStorageParameters) Open(extractor *args.ServiceExtractor) (tokenCommon.TokenStorage, error)
Open a token storage based on the command-line configuration.
func (*CommonTokenStorageParameters) Register ¶
func (p *CommonTokenStorageParameters) Register(flags *flag.FlagSet)
Register registers token storage flags with the given flag set.
func (*CommonTokenStorageParameters) Validate ¶
func (p *CommonTokenStorageParameters) Validate(extractor *args.ServiceExtractor) error
Validate token storage parameter set.
type DisableSubcommand ¶
type DisableSubcommand struct {
// contains filtered or unexported fields
}
DisableSubcommand is the "acra-tokens disable" subcommand.
func (*DisableSubcommand) FlagSet ¶
func (s *DisableSubcommand) FlagSet() *flag.FlagSet
FlagSet returns flag set of this subcommand.
func (*DisableSubcommand) Name ¶
func (s *DisableSubcommand) Name() string
Name returns the same of this subcommand.
func (*DisableSubcommand) Parse ¶
func (s *DisableSubcommand) Parse(arguments []string) error
Parse command-line parameters of the subcommand.
func (*DisableSubcommand) RegisterFlags ¶
func (s *DisableSubcommand) RegisterFlags()
RegisterFlags registers command-line flags of this subcommand.
type EnableSubcommand ¶
type EnableSubcommand struct {
// contains filtered or unexported fields
}
EnableSubcommand is the "acra-tokens enable" subcommand.
func (*EnableSubcommand) FlagSet ¶
func (s *EnableSubcommand) FlagSet() *flag.FlagSet
FlagSet returns flag set of this subcommand.
func (*EnableSubcommand) Name ¶
func (s *EnableSubcommand) Name() string
Name returns the same of this subcommand.
func (*EnableSubcommand) Parse ¶
func (s *EnableSubcommand) Parse(arguments []string) error
Parse command-line parameters of the subcommand.
func (*EnableSubcommand) RegisterFlags ¶
func (s *EnableSubcommand) RegisterFlags()
RegisterFlags registers command-line flags of this subcommand.
type RemoveSubcommand ¶
type RemoveSubcommand struct {
// contains filtered or unexported fields
}
RemoveSubcommand is the "acra-tokens remove" subcommand.
func (*RemoveSubcommand) FlagSet ¶
func (s *RemoveSubcommand) FlagSet() *flag.FlagSet
FlagSet returns flag set of this subcommand.
func (*RemoveSubcommand) Name ¶
func (s *RemoveSubcommand) Name() string
Name returns the same of this subcommand.
func (*RemoveSubcommand) Parse ¶
func (s *RemoveSubcommand) Parse(arguments []string) error
Parse command-line parameters of the subcommand.
func (*RemoveSubcommand) RegisterFlags ¶
func (s *RemoveSubcommand) RegisterFlags()
RegisterFlags registers command-line flags of this subcommand.
type StatusSubcommand ¶
type StatusSubcommand struct {
// contains filtered or unexported fields
}
StatusSubcommand is the "acra-tokens status" subcommand.
func (*StatusSubcommand) FlagSet ¶
func (s *StatusSubcommand) FlagSet() *flag.FlagSet
FlagSet returns flag set of this subcommand.
func (*StatusSubcommand) Name ¶
func (s *StatusSubcommand) Name() string
Name returns the same of this subcommand.
func (*StatusSubcommand) Parse ¶
func (s *StatusSubcommand) Parse(arguments []string) error
Parse command-line parameters of the subcommand.
func (*StatusSubcommand) RegisterFlags ¶
func (s *StatusSubcommand) RegisterFlags()
RegisterFlags registers command-line flags of this subcommand.
type Subcommand ¶
type Subcommand interface { Name() string RegisterFlags() FlagSet() *flag.FlagSet Parse(arguments []string) error Execute() }
Subcommand is "acra-tokens" subcommand.
func ParseParameters ¶
func ParseParameters(subcommands []Subcommand) Subcommand
ParseParameters parses command-line parameters and returns the selected subcommand. There may be no subcommand selected, in which case nil is returned. It terminates the process on error.