pkiadm/transport.go
Gibheer bc84bc4a28 add location support
This commit adds basic support for adding, deleting, ... locations. This
needed a bit of rework for the ResourceName, as it was kind of stupid to
have different implementations server internally and in the lib.

There is still some need for cleanup, but it works basically.
2017-05-31 21:03:51 +02:00

52 lines
1.0 KiB
Go

package pkiadm
import (
"fmt"
)
// Result is a struct to send error messages from the server to the client.
type Result struct {
// TODO make field private to avoid accidental write
// HasError is true when an error was hit
HasError bool
// Error contains a list of errors, which can be used to add more details.
Error Error
// A message with more detailed information can be provided.
Message string
}
type Error string
func (e Error) Error() string { return string(e) }
func (r *Result) SetError(err error, msg string, args ...interface{}) {
r.HasError = true
r.Error = Error(err.Error())
if len(args) > 0 {
r.Message = fmt.Sprintf(msg, args)
} else {
r.Message = msg
}
}
// TODO documentation and cleanup
const (
RTPrivateKey ResourceType = iota
RTPublicKey
RTCSR
RTCertificate
RTLocation
RTSerial
RTSubject
RTUnknown
)
type ResourceName struct {
ID string
Type ResourceType
}
type ResourceType uint
func (r ResourceName) String() string { return r.Type.String() + "/" + r.ID }
type Filter struct{}