mirror of
https://github.com/getsops/sops.git
synced 2026-02-05 12:45:21 +01:00
go lint
This commit is contained in:
@@ -9,7 +9,9 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
// empty import as per https://godoc.org/github.com/lib/pq
|
||||
_ "github.com/lib/pq"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"go.mozilla.org/sops/logging"
|
||||
"gopkg.in/yaml.v2"
|
||||
@@ -67,36 +69,46 @@ type config struct {
|
||||
|
||||
var auditors []Auditor
|
||||
|
||||
// SubmitEvent handles an event for all auditors
|
||||
func SubmitEvent(event interface{}) {
|
||||
for _, auditor := range auditors {
|
||||
auditor.Handle(event)
|
||||
}
|
||||
}
|
||||
|
||||
// Register registers a new Auditor in the global auditor list
|
||||
func Register(auditor Auditor) {
|
||||
auditors = append(auditors, auditor)
|
||||
}
|
||||
|
||||
// Auditor is notified when noteworthy events happen, for example when a file is encrypted or decrypted.
|
||||
type Auditor interface {
|
||||
Handle(event interface{})
|
||||
}
|
||||
|
||||
// DecryptEvent contains fields relevant to a decryption event
|
||||
type DecryptEvent struct {
|
||||
File string
|
||||
}
|
||||
|
||||
// EncryptEvent contains fields relevant to an encryption event
|
||||
type EncryptEvent struct {
|
||||
File string
|
||||
}
|
||||
|
||||
// RotateEvent contains fields relevant to a key rotation event
|
||||
type RotateEvent struct {
|
||||
File string
|
||||
}
|
||||
|
||||
// PostgresAuditor is a Postgres SQL DB implementation of the
|
||||
// Auditor interface
|
||||
type PostgresAuditor struct {
|
||||
DB *sql.DB
|
||||
}
|
||||
|
||||
// NewPostgresAuditor is the constructor for a new PostgresAuditor object
|
||||
// initialized with the given db connection string
|
||||
func NewPostgresAuditor(connStr string) (*PostgresAuditor, error) {
|
||||
db, err := sql.Open("postgres", connStr)
|
||||
pg := &PostgresAuditor{DB: db}
|
||||
@@ -113,6 +125,8 @@ func NewPostgresAuditor(connStr string) (*PostgresAuditor, error) {
|
||||
return pg, nil
|
||||
}
|
||||
|
||||
// Handle is the PostgresAuditor implementation of the function required by the
|
||||
// Auditor interface
|
||||
func (p *PostgresAuditor) Handle(event interface{}) {
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user