diff --git a/pkg/config/config.go b/pkg/config/config.go index e08887f..660d3ff 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -27,6 +27,7 @@ type Config struct { TrustStoreFile string `flag:"trust-store-file" desc:"Trust store used by HTTP signature verifier (.pem or .p12)"` } +// Validate configuration func (c *Config) Validate() error { if matched, _ := regexp.MatchString(`^/\w+$`, c.StaticPath); !matched { return fmt.Errorf("invalid static path: %s", c.StaticPath) diff --git a/pkg/hook/job.go b/pkg/hook/job.go index ebd96b0..dc528a1 100644 --- a/pkg/hook/job.go +++ b/pkg/hook/job.go @@ -60,19 +60,22 @@ func NewHookJob(request *Request) (*Job, error) { return job, nil } +// ID returns job ID func (job *Job) ID() uint64 { return job.id } +// Name returns job name func (job *Job) Name() string { return job.name } +// Err returns job error func (job *Job) Err() error { return job.err } -// Meta return job meta +// Meta returns job meta func (job *Job) Meta() []string { return []string{ "hook_id=" + strconv.FormatUint(job.id, 10), diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index 02dd37a..23d4220 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -7,7 +7,9 @@ import ( ) var ( - HookOutputEnabled = false + // HookOutputEnabled writes hook output into logs if true + HookOutputEnabled = false + // RequestOutputEnabled writes HTTP request into logs if true RequestOutputEnabled = false ) diff --git a/pkg/middleware/signature/ed25519-signature.go b/pkg/middleware/signature/ed25519-signature.go index 8a78362..a63ffde 100644 --- a/pkg/middleware/signature/ed25519-signature.go +++ b/pkg/middleware/signature/ed25519-signature.go @@ -13,7 +13,7 @@ import ( ) const ( - defaultKeyId = "default" + defaultKeyID = "default" xSignatureEd25519 = "X-Signature-Ed25519" xSignatureTimestamp = "X-Signature-Timestamp" ) @@ -25,9 +25,9 @@ func IsEd25519SignatureRequest(headers http.Header) bool { // Ed25519SignatureHandler validate request HTTP signature func Ed25519SignatureHandler(r *http.Request, ts truststore.TrustStore) error { - pubkey := ts.GetPublicKey(defaultKeyId) + pubkey := ts.GetPublicKey(defaultKeyID) if pubkey == nil { - return fmt.Errorf("public key not found: %s", defaultKeyId) + return fmt.Errorf("public key not found: %s", defaultKeyID) } key, ok := pubkey.(ed25519.PublicKey) diff --git a/pkg/notification/types.go b/pkg/notification/types.go index 9e6554e..6986c9f 100644 --- a/pkg/notification/types.go +++ b/pkg/notification/types.go @@ -1,5 +1,6 @@ package notification +// HookResult is the result of a hook execution type HookResult interface { ID() uint64 Name() string diff --git a/pkg/truststore/truststore.go b/pkg/truststore/truststore.go index 1112700..a590a77 100644 --- a/pkg/truststore/truststore.go +++ b/pkg/truststore/truststore.go @@ -17,6 +17,7 @@ type InMemoryTrustStore struct { Keys map[string]crypto.PublicKey } +// GetPublicKey returns the public key with this key ID func (ts *InMemoryTrustStore) GetPublicKey(keyID string) crypto.PublicKey { if key, ok := ts.Keys[keyID]; ok { return key diff --git a/pkg/worker/types.go b/pkg/worker/types.go index e9d1c27..d7bfac8 100644 --- a/pkg/worker/types.go +++ b/pkg/worker/types.go @@ -10,6 +10,7 @@ func (c *ChanWriter) Write(p []byte) (int, error) { return len(p), nil } +// Work is a dispatched work given to a worker type Work interface { ID() uint64 Name() string