-
Notifications
You must be signed in to change notification settings - Fork 0
/
captainhook.go
38 lines (31 loc) · 934 Bytes
/
captainhook.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package captainhook
import "errors"
type (
// Data structure contains information on an Endpoint, with associated rules
// and sources.
Endpoint struct {
Name string `yaml:"name"`
Secrets []string `yaml:"secrets"`
Rules []Rule `yaml:"rules"`
}
// Interface provides an extensible way of implementing the EndpointService,
// this is used in various parts of the application logic to decouple
// implementations.
EndpointService interface {
Endpoint(name string) (*Endpoint, error)
Endpoints() ([]Endpoint, error)
CreateEndpoint() error
DeleteEndpoint() error
}
SecretEngine interface {
GetTextSecret(name string) (string, error)
ValidateEndpointConfig(endpoints []Endpoint) error
}
)
// Obtains the associated rules for an endpoint.
func (e *Endpoint) GetRules() ([]Rule, error) {
if e.Rules == nil {
return nil, errors.New("Endpoint has no associated rules.")
}
return e.Rules, nil
}