types

package
v0.0.0-...-0490640 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const LegacyTokenDescription = "Legacy data collector token ported from A1"

Variables

This section is empty.

Functions

This section is empty.

Types

type ConflictError

type ConflictError struct{}

ConflictError is the error returned when the token creation request specifies an ID that has already been used

func (*ConflictError) Error

func (e *ConflictError) Error() string

type NotFoundError

type NotFoundError struct{}

NotFoundError is the error returned when the token wasn't found, to discern this from other errors -- failures to reach the backend services, etc.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type Resetter

type Resetter interface {
	Reset(context.Context) error
}

Resetter allows resetting the adapter to factory settings (e.g. deletes all data) -- use with caution

type Storage

type Storage interface {
	CreateToken(ctx context.Context, id, description string, active bool, projects []string) (*Token, error)
	CreateTokenWithValue(ctx context.Context, id, value, description string,
		active bool, projects []string) (*Token, error)
	CreateLegacyTokenWithValue(ctx context.Context, value string) (*Token, error)
	DeleteToken(context.Context, string) error
	UpdateToken(ctx context.Context, id, description string, active bool, projects []string) (*Token, error)
	GetToken(context.Context, string) (*Token, error)
	GetTokenIDWithValue(ctx context.Context, value string) (string, error)
	GetTokens(context.Context) ([]*Token, error)
}

Storage is the interface for various adapters

type Token

type Token struct {
	ID          string
	Description string
	Value       string
	Active      bool
	Created     time.Time
	Updated     time.Time
	Projects    []string
}

Token represents a token we are able to use to authenticate: the ID is arbitrary, the Token will be checked for in incoming requests.

type TokenConfig

type TokenConfig interface {
	Open(*certs.ServiceCerts, *zap.Logger) (Storage, error)
}

TokenConfig is a configuration that can open a storage adapter

Jump to

Keyboard shortcuts

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