Documentation ¶
Index ¶
- Constants
- Variables
- func NewContext(ctx context.Context, db DB) context.Context
- func UnmarshalProvisionerDetails(typ linkedca.Provisioner_Type, data []byte) (*linkedca.ProvisionerDetails, error)
- type DB
- type Error
- type MockDB
- func (m *MockDB) CreateAdmin(ctx context.Context, admin *linkedca.Admin) error
- func (m *MockDB) CreateAuthorityPolicy(ctx context.Context, policy *linkedca.Policy) error
- func (m *MockDB) CreateProvisioner(ctx context.Context, prov *linkedca.Provisioner) error
- func (m *MockDB) DeleteAdmin(ctx context.Context, id string) error
- func (m *MockDB) DeleteAuthorityPolicy(ctx context.Context) error
- func (m *MockDB) DeleteProvisioner(ctx context.Context, id string) error
- func (m *MockDB) GetAdmin(ctx context.Context, id string) (*linkedca.Admin, error)
- func (m *MockDB) GetAdmins(ctx context.Context) ([]*linkedca.Admin, error)
- func (m *MockDB) GetAuthorityPolicy(ctx context.Context) (*linkedca.Policy, error)
- func (m *MockDB) GetProvisioner(ctx context.Context, id string) (*linkedca.Provisioner, error)
- func (m *MockDB) GetProvisioners(ctx context.Context) ([]*linkedca.Provisioner, error)
- func (m *MockDB) UpdateAdmin(ctx context.Context, adm *linkedca.Admin) error
- func (m *MockDB) UpdateAuthorityPolicy(ctx context.Context, policy *linkedca.Policy) error
- func (m *MockDB) UpdateProvisioner(ctx context.Context, prov *linkedca.Provisioner) error
- type ProblemType
Constants ¶
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 ¶
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 NewContext ¶ added in v0.20.0
NewContext adds the given admin database to the context.
func UnmarshalProvisionerDetails ¶
func UnmarshalProvisionerDetails(typ linkedca.Provisioner_Type, data []byte) (*linkedca.ProvisionerDetails, error)
UnmarshalProvisionerDetails unmarshals details type to the specific provisioner details.
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 CreateAuthorityPolicy(ctx context.Context, policy *linkedca.Policy) error GetAuthorityPolicy(ctx context.Context) (*linkedca.Policy, error) UpdateAuthorityPolicy(ctx context.Context, policy *linkedca.Policy) error DeleteAuthorityPolicy(ctx context.Context) error }
DB is the DB interface expected by the step-ca Admin API.
func FromContext ¶ added in v0.20.0
FromContext returns the current admin database from the given context.
func MustFromContext ¶ added in v0.20.0
MustFromContext returns the current admin database from the given context. It will panic if it's not in the context.
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 error
func NewError ¶
func NewError(pt ProblemType, msg string, args ...interface{}) *Error
NewError creates a new Error type.
func NewErrorISE ¶
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 ¶
WrapErrorISE shortcut to wrap an internal server error type.
func (*Error) IsType ¶
func (e *Error) IsType(pt ProblemType) bool
IsType returns true if the error type matches the input type.
func (*Error) Render ¶ added in v0.19.0
func (e *Error) Render(w http.ResponseWriter)
Render implements render.RenderableError for Error.
func (*Error) StatusCode ¶
StatusCode returns the status code and implements the StatusCoder 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 MockCreateAuthorityPolicy func(ctx context.Context, policy *linkedca.Policy) error MockGetAuthorityPolicy func(ctx context.Context) (*linkedca.Policy, error) MockUpdateAuthorityPolicy func(ctx context.Context, policy *linkedca.Policy) error MockDeleteAuthorityPolicy func(ctx context.Context) 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 ¶
CreateAdmin mock
func (*MockDB) CreateAuthorityPolicy ¶ added in v0.20.0
CreateAuthorityPolicy mock
func (*MockDB) CreateProvisioner ¶
CreateProvisioner mock.
func (*MockDB) DeleteAdmin ¶
DeleteAdmin mock
func (*MockDB) DeleteAuthorityPolicy ¶ added in v0.20.0
DeleteAuthorityPolicy mock
func (*MockDB) DeleteProvisioner ¶
DeleteProvisioner mock
func (*MockDB) GetAuthorityPolicy ¶ added in v0.20.0
GetAuthorityPolicy mock
func (*MockDB) GetProvisioner ¶
GetProvisioner mock.
func (*MockDB) GetProvisioners ¶
GetProvisioners mock
func (*MockDB) UpdateAdmin ¶
UpdateAdmin mock
func (*MockDB) UpdateAuthorityPolicy ¶ added in v0.20.0
UpdateAuthorityPolicy mock
func (*MockDB) UpdateProvisioner ¶
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 // ErrorServerInternalType internal server error. ErrorServerInternalType // ErrorConflictType conflict. ErrorConflictType )
func (ProblemType) String ¶
func (ap ProblemType) String() string
String returns the string representation of the admin problem type, fulfilling the Stringer interface.