-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
98 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package main | ||
|
||
type config struct { | ||
RekorServerURL string `yaml:"rekorServerURL"` | ||
Policies []policy `yaml:"policies"` | ||
RekorServerURL string `yaml:"rekorServerURL"` | ||
Policies []policy `yaml:"policies"` | ||
Outputs map[string]map[string]interface{} `yaml:"outputs"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package outputs | ||
|
||
type Event struct { | ||
Name string | ||
Description string | ||
RekorURL string | ||
} | ||
|
||
type Output interface { | ||
Send(Event) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package outputs | ||
|
||
import "errors" | ||
|
||
type CreatorFunc func(map[string]interface{}) (Output, error) | ||
|
||
var drivers map[string]CreatorFunc | ||
|
||
func init() { | ||
drivers = make(map[string]CreatorFunc) | ||
} | ||
|
||
func RegisterDriver(name string, maker CreatorFunc) { | ||
drivers[name] = maker | ||
} | ||
|
||
func LoadDriver(name string, conf map[string]interface{}) (Output, error) { | ||
f, ok := drivers[name] | ||
if !ok { | ||
return nil, errors.New(`driver doesn't exist or wasn't loaded`) | ||
} | ||
|
||
return f(conf) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package stdout | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/nsmith5/rekor-sidekick/outputs" | ||
) | ||
|
||
type impl struct{} | ||
|
||
func (i impl) Send(e outputs.Event) error { | ||
fmt.Printf( | ||
`{"name": "%s", "description": "%s", rekorURL: "%s"}`, | ||
e.Name, | ||
e.Description, | ||
e.RekorURL, | ||
) | ||
fmt.Println() | ||
return nil | ||
} | ||
|
||
func New(map[string]interface{}) (outputs.Output, error) { | ||
return &impl{}, nil | ||
} | ||
|
||
func init() { | ||
outputs.RegisterDriver("stdout", outputs.CreatorFunc(New)) | ||
} |