admin

package
v0.17.4 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultAuthorityID is the default AuthorityID. This will be the ID
	// of the first Authority created, as well as the default AuthorityID
	// if one is not specified in the configuration.
	DefaultAuthorityID = "00000000-0000-0000-0000-000000000000"
)

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is an error that should be used by the authority.DB interface to indicate that an entity does not exist.

Functions

func UnmarshalProvisionerDetails

func UnmarshalProvisionerDetails(typ linkedca.Provisioner_Type, data []byte) (*linkedca.ProvisionerDetails, error)

UnmarshalProvisionerDetails unmarshals details type to the specific provisioner details.

func WriteError

func WriteError(w http.ResponseWriter, err *Error)

WriteError writes to w a JSON representation of the given error.

Types

type DB

type DB interface {
	CreateProvisioner(ctx context.Context, prov *linkedca.Provisioner) error
	GetProvisioner(ctx context.Context, id string) (*linkedca.Provisioner, error)
	GetProvisioners(ctx context.Context) ([]*linkedca.Provisioner, error)
	UpdateProvisioner(ctx context.Context, prov *linkedca.Provisioner) error
	DeleteProvisioner(ctx context.Context, id string) error

	CreateAdmin(ctx context.Context, admin *linkedca.Admin) error
	GetAdmin(ctx context.Context, id string) (*linkedca.Admin, error)
	GetAdmins(ctx context.Context) ([]*linkedca.Admin, error)
	UpdateAdmin(ctx context.Context, admin *linkedca.Admin) error
	DeleteAdmin(ctx context.Context, id string) error
}

DB is the DB interface expected by the step-ca Admin API.

type Error

type Error struct {
	Type    string `json:"type"`
	Detail  string `json:"detail"`
	Message string `json:"message"`
	Err     error  `json:"-"`
	Status  int    `json:"-"`
}

Error represents an Admin

func NewError

func NewError(pt ProblemType, msg string, args ...interface{}) *Error

NewError creates a new Error type.

func NewErrorISE

func NewErrorISE(msg string, args ...interface{}) *Error

NewErrorISE creates a new ErrorServerInternalType Error.

func WrapError

func WrapError(typ ProblemType, err error, msg string, args ...interface{}) *Error

WrapError attempts to wrap the internal error.

func WrapErrorISE

func WrapErrorISE(err error, msg string, args ...interface{}) *Error

WrapErrorISE shortcut to wrap an internal server error type.

func (*Error) Cause

func (e *Error) Cause() error

Cause returns the internal error and implements the Causer interface.

func (*Error) Error

func (e *Error) Error() string

Error allows AError to implement the error interface.

func (*Error) IsType

func (e *Error) IsType(pt ProblemType) bool

IsType returns true if the error type matches the input type.

func (*Error) StatusCode

func (e *Error) StatusCode() int

StatusCode returns the status code and implements the StatusCoder interface.

func (*Error) ToLog

func (e *Error) ToLog() (interface{}, error)

ToLog implements the EnableLogger interface.

type MockDB

type MockDB struct {
	MockCreateProvisioner func(ctx context.Context, prov *linkedca.Provisioner) error
	MockGetProvisioner    func(ctx context.Context, id string) (*linkedca.Provisioner, error)
	MockGetProvisioners   func(ctx context.Context) ([]*linkedca.Provisioner, error)
	MockUpdateProvisioner func(ctx context.Context, prov *linkedca.Provisioner) error
	MockDeleteProvisioner func(ctx context.Context, id string) error

	MockCreateAdmin func(ctx context.Context, adm *linkedca.Admin) error
	MockGetAdmin    func(ctx context.Context, id string) (*linkedca.Admin, error)
	MockGetAdmins   func(ctx context.Context) ([]*linkedca.Admin, error)
	MockUpdateAdmin func(ctx context.Context, adm *linkedca.Admin) error
	MockDeleteAdmin func(ctx context.Context, id string) error

	MockError error
	MockRet1  interface{}
}

MockDB is an implementation of the DB interface that should only be used as a mock in tests.

func (*MockDB) CreateAdmin

func (m *MockDB) CreateAdmin(ctx context.Context, admin *linkedca.Admin) error

CreateAdmin mock

func (*MockDB) CreateProvisioner

func (m *MockDB) CreateProvisioner(ctx context.Context, prov *linkedca.Provisioner) error

CreateProvisioner mock.

func (*MockDB) DeleteAdmin

func (m *MockDB) DeleteAdmin(ctx context.Context, id string) error

DeleteAdmin mock

func (*MockDB) DeleteProvisioner

func (m *MockDB) DeleteProvisioner(ctx context.Context, id string) error

DeleteProvisioner mock

func (*MockDB) GetAdmin

func (m *MockDB) GetAdmin(ctx context.Context, id string) (*linkedca.Admin, error)

GetAdmin mock.

func (*MockDB) GetAdmins

func (m *MockDB) GetAdmins(ctx context.Context) ([]*linkedca.Admin, error)

GetAdmins mock

func (*MockDB) GetProvisioner

func (m *MockDB) GetProvisioner(ctx context.Context, id string) (*linkedca.Provisioner, error)

GetProvisioner mock.

func (*MockDB) GetProvisioners

func (m *MockDB) GetProvisioners(ctx context.Context) ([]*linkedca.Provisioner, error)

GetProvisioners mock

func (*MockDB) UpdateAdmin

func (m *MockDB) UpdateAdmin(ctx context.Context, adm *linkedca.Admin) error

UpdateAdmin mock

func (*MockDB) UpdateProvisioner

func (m *MockDB) UpdateProvisioner(ctx context.Context, prov *linkedca.Provisioner) error

UpdateProvisioner mock

type ProblemType

type ProblemType int

ProblemType is the type of the Admin problem.

const (
	// ErrorNotFoundType resource not found.
	ErrorNotFoundType ProblemType = iota
	// ErrorAuthorityMismatchType resource Authority ID does not match the
	// context Authority ID.
	ErrorAuthorityMismatchType
	// ErrorDeletedType resource has been deleted.
	ErrorDeletedType
	// ErrorBadRequestType bad request.
	ErrorBadRequestType
	// ErrorNotImplementedType not implemented.
	ErrorNotImplementedType
	// ErrorUnauthorizedType internal server error.
	ErrorUnauthorizedType
	// ErrorServerInternalType internal server error.
	ErrorServerInternalType
)

func (ProblemType) String

func (ap ProblemType) String() string

String returns the string representation of the admin problem type, fulfilling the Stringer interface.

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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