Documentation ¶
Index ¶
- Constants
- Variables
- func ErrNumericText(code ErrNumeric) string
- type Claims
- type Config
- type ErrNumeric
- type KopanoProductClaims
- func (kpc *KopanoProductClaims) Dump() map[string]interface{}
- func (kpc *KopanoProductClaims) EnsureBool(product, claim string, value bool) error
- func (kpc *KopanoProductClaims) EnsureFloat64(product, claim string, value float64) error
- func (kpc *KopanoProductClaims) EnsureFloat64WithOperator(product, claim string, value float64, op OperatorType) error
- func (kpc *KopanoProductClaims) EnsureInt64(product, claim string, value int64) error
- func (kpc *KopanoProductClaims) EnsureInt64WithOperator(product, claim string, value int64, op OperatorType) error
- func (kpc *KopanoProductClaims) EnsureOK(product string) (err error)
- func (kpc *KopanoProductClaims) EnsureOnline() (err error)
- func (kpc *KopanoProductClaims) EnsureOnlineAndTrusted() (err error)
- func (kpc *KopanoProductClaims) EnsureString(product, claim, value string) error
- func (kpc *KopanoProductClaims) EnsureStringArrayValues(product, claim string, value ...string) error
- func (kpc *KopanoProductClaims) EnsureTrusted() (err error)
- func (kpc *KopanoProductClaims) GetBool(product, claim string) (bool, error)
- func (kpc *KopanoProductClaims) GetFloat64(product, claim string) (float64, error)
- func (kpc *KopanoProductClaims) GetInt64(product, claim string) (int64, error)
- func (kpc *KopanoProductClaims) GetString(product, claim string) (string, error)
- func (kpc *KopanoProductClaims) GetStringArrayValues(product, claim string) ([]string, error)
- func (kpc *KopanoProductClaims) SetAllowUntrusted(flag bool)
- func (kpc *KopanoProductClaims) SetMustBeOnline(flag bool)
- type Kustomer
- func (k *Kustomer) BuildDate() string
- func (k *Kustomer) CurrentClaims(ctx context.Context) *Claims
- func (k *Kustomer) CurrentKopanoProductClaims(ctx context.Context) *KopanoProductClaims
- func (k *Kustomer) Initialize(ctx context.Context, productName *string) error
- func (k *Kustomer) NotifyWhenUpdated(ctx context.Context, eventCh chan<- bool) error
- func (k *Kustomer) Uninitialize() error
- func (k *Kustomer) Version() string
- func (k *Kustomer) WaitUntilReady(ctx context.Context) error
- type Logger
- type OperatorType
Constants ¶
const StatusSuccess = ErrStatusNone
StatusSuccess is the success response as returned by this library.
Variables ¶
var DefaultAPIPath = "/run/kopano-kustomerd/api.sock"
DefaultUserAgent is the HTTP user agent set in to request headers for HTTP requests created by this library.
var ErrNumericToTextMap = map[ErrNumeric]string{ ErrStatusUnknown: "Unknown", ErrStatusInvalidProductName: "Invalid Product Name Value", ErrStatusAlreadyInitialized: "Already Initialized", ErrStatusNotInitialized: "Not Initialized", ErrStatusTimeout: "Timeout", ErrEnsureOnlineFailed: "Ensure failed, product claim set not online", ErrEnsureTrustedFailed: "Ensure failed, product claim set not trusted", ErrEnsureProductNotFound: "Ensure failed, product entry not found", ErrEnsureProductNotLicensed: "Ensure failed, product is not licensed", ErrEnsureProductClaimNotFound: "Ensure failed, product claim entry not found", ErrEnsureProductClaimValueTypeMismatch: "Ensure failed, product claim value type mismatch", ErrEnsureProductClaimValueMismatch: "Ensure failed, product claim value mismatch", ErrEnsureUnknownOperator: "Ensure failed, unknown operator", ErrEnsureInvalidTransaction: "Ensure failed, invalid transaction", }
ErrNumericToTextMap maps numeric errors to readable names.
Functions ¶
func ErrNumericText ¶
func ErrNumericText(code ErrNumeric) string
ErrNumericText returns a text for the ErrStatus. It returns the empty string if the code is unknown.
Types ¶
type Claims ¶
type Claims struct {
// contains filtered or unexported fields
}
Claims represent a set of active claim key value pairs.
type Config ¶
A Config holds the configuration for this module.
type ErrNumeric ¶
type ErrNumeric uint64
ErrNumeric is the Error type as used by kustomer.
const ( ErrStatusNone = 0 ErrStatusUnknown ErrNumeric = iota + (1 << 8) ErrStatusInvalidProductName ErrStatusAlreadyInitialized ErrStatusNotInitialized ErrStatusTimeout )
Numeric errors for status.
const ( ErrEnsureOnlineFailed ErrNumeric = iota + (1 << 16) + 1 ErrEnsureTrustedFailed ErrEnsureProductNotFound ErrEnsureProductNotLicensed ErrEnsureProductClaimNotFound ErrEnsureProductClaimValueTypeMismatch ErrEnsureProductClaimValueMismatch ErrEnsureUnknownOperator ErrEnsureInvalidTransaction )
Numeric errors for ensure comparison.
func (ErrNumeric) Error ¶
func (errStatus ErrNumeric) Error() string
type KopanoProductClaims ¶
type KopanoProductClaims struct {
// contains filtered or unexported fields
}
KopanoProductClaims represent a set of all active claims as aggregated values.
func (*KopanoProductClaims) Dump ¶
func (kpc *KopanoProductClaims) Dump() map[string]interface{}
Dump exports the associated KopanoProductClaims data.
func (*KopanoProductClaims) EnsureBool ¶
func (kpc *KopanoProductClaims) EnsureBool(product, claim string, value bool) error
EnsureBool returns an error if the provided product or the claim value is not found. Furthermore the claim value is compared to the provided value and if it is not a match, an error is returned as well.
func (*KopanoProductClaims) EnsureFloat64 ¶
func (kpc *KopanoProductClaims) EnsureFloat64(product, claim string, value float64) error
EnsureFloat64 returns an error if the provided product or the claim value is not found. Furthermore the claim value is compared to the provided value and if it is not a match, an error is returned as well.
func (*KopanoProductClaims) EnsureFloat64WithOperator ¶
func (kpc *KopanoProductClaims) EnsureFloat64WithOperator(product, claim string, value float64, op OperatorType) error
EnsureFloat64WithOperator returns an error if the provided product or the claim value is not found. Furthermore the claim value is compared to the provided value using the provided comparison operator and if it is not a match, an error is returned as well.
func (*KopanoProductClaims) EnsureInt64 ¶
func (kpc *KopanoProductClaims) EnsureInt64(product, claim string, value int64) error
EnsureInt64 returns an error if the provided product or the claim value is not found. Furthermore the claim value is compared to the provided value and if it is not a match, an error is returned as well.
func (*KopanoProductClaims) EnsureInt64WithOperator ¶
func (kpc *KopanoProductClaims) EnsureInt64WithOperator(product, claim string, value int64, op OperatorType) error
EnsureInt64WithOperator returns an error if the provided product or the claim value is not found. Furthermore the claim value is compared to the provided value using the provided comparison operator and if it is not a match, an error is returned as well.
func (*KopanoProductClaims) EnsureOK ¶
func (kpc *KopanoProductClaims) EnsureOK(product string) (err error)
EnsureOK returns an error if the provided product is not found in the associated claims data or if that product is found but the OK flag of the active product is false.
func (*KopanoProductClaims) EnsureOnline ¶
func (kpc *KopanoProductClaims) EnsureOnline() (err error)
EnsureOnline returns ErrEnsureOnlineFailed error if the associated claims data was validated with offline. This function returns the error even if the associated claims mustBeOnline flag was is false.
func (*KopanoProductClaims) EnsureOnlineAndTrusted ¶
func (kpc *KopanoProductClaims) EnsureOnlineAndTrusted() (err error)
EnsureOnlineAndTrusted is the combination of EnsureOnline and EnsureOnline for convinience. Samle rules apply as described in those two functions.
func (*KopanoProductClaims) EnsureString ¶
func (kpc *KopanoProductClaims) EnsureString(product, claim, value string) error
EnsureString returns an error if the provided product or the claim value is not found. Furthermore the claim value is compared to the provided value and if it is not a match, an error is returned as well.
func (*KopanoProductClaims) EnsureStringArrayValues ¶ added in v0.6.0
func (kpc *KopanoProductClaims) EnsureStringArrayValues(product, claim string, value ...string) error
EnsureStringArrayValues returns an error if the provided product or the claim value is not found. Furthermore if not all of the provided value prameters are present in the claim value n error is returned as well.
func (*KopanoProductClaims) EnsureTrusted ¶
func (kpc *KopanoProductClaims) EnsureTrusted() (err error)
EnsureTrusted returns ErrEnsureTrustedFailed error if the associated claims data is not trusted. This function will return the error even if the associated claims SetAllowUntrusted was set to true.
func (*KopanoProductClaims) GetBool ¶
func (kpc *KopanoProductClaims) GetBool(product, claim string) (bool, error)
GetBool returns the prodvided prodcut claim bool value. If the product or the claim is not found, an the returned error describes the reason why the claim value is not available.
func (*KopanoProductClaims) GetFloat64 ¶
func (kpc *KopanoProductClaims) GetFloat64(product, claim string) (float64, error)
GetFloat64 returns the prodvided product claim float value. If the product or the claim is not found, an the returned error describes the reason why the claim value is not available.
func (*KopanoProductClaims) GetInt64 ¶
func (kpc *KopanoProductClaims) GetInt64(product, claim string) (int64, error)
GetInt64 returns the prodvided product claim numeric value. If the product or the claim is not found, an the returned error describes the reason why the claim value is not available.
func (*KopanoProductClaims) GetString ¶
func (kpc *KopanoProductClaims) GetString(product, claim string) (string, error)
GetString returns the prodvided product claim string value. If the product or the claim is not found, an the returned error describes the reason why the claim value is not available.
func (*KopanoProductClaims) GetStringArrayValues ¶ added in v0.6.0
func (kpc *KopanoProductClaims) GetStringArrayValues(product, claim string) ([]string, error)
GetStringArrayValues returns the prodvided product claim string array value. If the product or the claim is not found, an the returned error describes the reason why the claim value is not available.
func (*KopanoProductClaims) SetAllowUntrusted ¶
func (kpc *KopanoProductClaims) SetAllowUntrusted(flag bool)
SetAllowUntrusted sets the allowUntrusted flag value of the associated claims to the provided flag value. If true, any ensure check of the associated claims will ignore the trusted state of the claims data.
func (*KopanoProductClaims) SetMustBeOnline ¶
func (kpc *KopanoProductClaims) SetMustBeOnline(flag bool)
SetMustBeOnline sets the mustBeOnline flag value of the associated claims to the provided flag value. If true, any ensure check of the associated claims will fail if the claims data was produced without online verification.
type Kustomer ¶
type Kustomer struct {
// contains filtered or unexported fields
}
A Kustomer is the representation of the Kustomer interface.
func New ¶
New creates a new Kustomer instance using the provided configuration.
func (*Kustomer) BuildDate ¶
BuildDate returns the build data string of this module.
func (*Kustomer) CurrentClaims ¶
CurrentClaims returns the active claim set of the associated instance. This function blocks until a value is available or until the provided context is done. The fetched claims are cached, so no subsequent requests will result when calling this function, unless the underlaying active claims have changed since the last call.
func (*Kustomer) CurrentKopanoProductClaims ¶
func (k *Kustomer) CurrentKopanoProductClaims(ctx context.Context) *KopanoProductClaims
CurrentKopanoProductClaims returns the active Kopano product claims of the associated instance. This function blocks until a value is available or until the provided context is done. In the current implementation, a value will always be returned directly.
func (*Kustomer) Initialize ¶
Initialize intializes the associated instance with a context and a product name. Initialize must be called first, before most of the other functions of the instance return ErrStatusNotInitialized if this function was not called first.
func (*Kustomer) NotifyWhenUpdated ¶
NotifyWhenUpdated registers the provided even channel to receive bool values whenever the associated isntance claims have been updated. Calling this function blocks until the provided context is Done or until the associated instance is unintialized. An error is also returned if Initialize was not called before.
func (*Kustomer) Uninitialize ¶
Uninitialize is the opposite of initialize and releases the associated resources. Returns ErrStatusNotInitialized when this function is called without a call to Initialize before.
func (*Kustomer) Version ¶
Version returns the runtime version string of this module.
type Logger ¶
type Logger interface {
Printf(string, ...interface{})
}
A Logger defines a simple logging interface for pluggable loggers used by this module.
var DefaultLogger Logger = &nullLogger{}
DefaultLogger is the packageLogger used by this library if no other logger is explicitly specified.
type OperatorType ¶
type OperatorType string
OperatorsType is a special type of strring which can be used as operator.
const ( OperatorGreaterThan OperatorType = "gt" OperatorGreaterThanOrEqual OperatorType = "ge" OperatorLesserThan OperatorType = "lt" OperatorLesserThanOrEqual OperatorType = "le" )
Operators to use with the operator comparisons.