Add ErrSecretNotFound and clarify other error-related docs
This commit is contained in:
parent
6aa14bb57c
commit
1340f13f95
@ -115,6 +115,7 @@ func New(
|
|||||||
//
|
//
|
||||||
// Errors:
|
// Errors:
|
||||||
// - network.ErrInvalidConfig
|
// - network.ErrInvalidConfig
|
||||||
|
// - ErrAlreadyJoined
|
||||||
func (d *Daemon) CreateNetwork(
|
func (d *Daemon) CreateNetwork(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
name, domain string, ipNet nebula.IPNet, hostName nebula.HostName,
|
name, domain string, ipNet nebula.IPNet, hostName nebula.HostName,
|
||||||
|
@ -10,6 +10,7 @@ const (
|
|||||||
errCodeInvalidConfig
|
errCodeInvalidConfig
|
||||||
errCodeHostNotFound
|
errCodeHostNotFound
|
||||||
errCodeIPInUse
|
errCodeIPInUse
|
||||||
|
errCodeSecretNotFound
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -30,4 +31,8 @@ var (
|
|||||||
// ErrIPInUse is returned when performing an operation which was provided an
|
// ErrIPInUse is returned when performing an operation which was provided an
|
||||||
// IP already in use by another host in the network.
|
// IP already in use by another host in the network.
|
||||||
ErrIPInUse = jsonrpc2.NewError(errCodeIPInUse, "IP in use")
|
ErrIPInUse = jsonrpc2.NewError(errCodeIPInUse, "IP in use")
|
||||||
|
|
||||||
|
// ErrSecretNotFound is returned when a secret was required to perform some
|
||||||
|
// action, but the secret is not found in the secret store.
|
||||||
|
ErrSecretNotFound = jsonrpc2.NewError(errCodeSecretNotFound, "Secret not found")
|
||||||
)
|
)
|
||||||
|
@ -85,6 +85,7 @@ type RPC interface {
|
|||||||
// Errors:
|
// Errors:
|
||||||
// - ErrIPInUse - if IP field of CreateHostOpts is given, and already in use
|
// - ErrIPInUse - if IP field of CreateHostOpts is given, and already in use
|
||||||
// by another host in the network.
|
// by another host in the network.
|
||||||
|
// - ErrSecretNotFound - This Network doesn't have the CA signing key.
|
||||||
CreateHost(
|
CreateHost(
|
||||||
context.Context, nebula.HostName, CreateHostOpts,
|
context.Context, nebula.HostName, CreateHostOpts,
|
||||||
) (
|
) (
|
||||||
@ -97,6 +98,7 @@ type RPC interface {
|
|||||||
//
|
//
|
||||||
// Errors:
|
// Errors:
|
||||||
// - ErrHostNotFound
|
// - ErrHostNotFound
|
||||||
|
// - ErrSecretNotFound - This Network doesn't have the CA signing key.
|
||||||
CreateNebulaCertificate(
|
CreateNebulaCertificate(
|
||||||
context.Context, nebula.HostName, nebula.EncryptingPublicKey,
|
context.Context, nebula.HostName, nebula.EncryptingPublicKey,
|
||||||
) (
|
) (
|
||||||
@ -907,6 +909,9 @@ func (n *network) CreateHost(
|
|||||||
ctx, n.secretsStore,
|
ctx, n.secretsStore,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, secrets.ErrNotFound) {
|
||||||
|
err = ErrSecretNotFound
|
||||||
|
}
|
||||||
return JoiningBootstrap{}, fmt.Errorf("getting CA signing key: %w", err)
|
return JoiningBootstrap{}, fmt.Errorf("getting CA signing key: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -977,6 +982,9 @@ func (n *network) CreateNebulaCertificate(
|
|||||||
ctx, n.secretsStore,
|
ctx, n.secretsStore,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, secrets.ErrNotFound) {
|
||||||
|
err = ErrSecretNotFound
|
||||||
|
}
|
||||||
return nebula.Certificate{}, fmt.Errorf("getting CA signing key: %w", err)
|
return nebula.Certificate{}, fmt.Errorf("getting CA signing key: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
---
|
|
||||||
type: task
|
|
||||||
---
|
|
||||||
|
|
||||||
# Audit Error Code Documentation
|
|
||||||
|
|
||||||
Audit all code for RPC methods in both `daemon` and `daemon/network`, ensuring
|
|
||||||
that all error codes which can be returned are properly documented, and that all
|
|
||||||
errors which should have an error code have one.
|
|
||||||
|
|
||||||
`CreateNebulaCertificate` should return a specific error for if the CA root key
|
|
||||||
secret couldn't be found.
|
|
Loading…
Reference in New Issue
Block a user