mirror of
https://github.com/thegeeklab/drone-yaml.git
synced 2024-11-01 01:00:41 +00:00
36 lines
884 B
Go
36 lines
884 B
Go
// Copyright (c) 2019, Drone IO Inc.
|
|
// Copyright (c) 2021, Robert Kaussow <mail@thegeeklab.de>
|
|
|
|
package yaml
|
|
|
|
import "errors"
|
|
|
|
type (
|
|
// Signature is a resource that provides an hmac
|
|
// signature of combined resources. This signature
|
|
// can be used to validate authenticity and prevent
|
|
// tampering.
|
|
Signature struct {
|
|
Version string `json:"version,omitempty"`
|
|
Kind string `json:"kind"`
|
|
Hmac string `json:"hmac"`
|
|
}
|
|
)
|
|
|
|
var ErrInvalidSignature = errors.New("yaml: invalid signature due to missing hash")
|
|
|
|
// GetVersion returns the resource version.
|
|
func (s *Signature) GetVersion() string { return s.Version }
|
|
|
|
// GetKind returns the resource kind.
|
|
func (s *Signature) GetKind() string { return s.Kind }
|
|
|
|
// Validate returns an error if the signature is invalid.
|
|
func (s Signature) Validate() error {
|
|
if s.Hmac == "" {
|
|
return ErrInvalidSignature
|
|
}
|
|
|
|
return nil
|
|
}
|