Skip to content

Commit

Permalink
Merge pull request #258 from keel-hq/feature/approvals_in_mem
Browse files Browse the repository at this point in the history
Feature/approvals in mem
  • Loading branch information
rusenask authored Aug 29, 2018
2 parents ce61b44 + 84d5e3e commit f883ecc
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 21 deletions.
2 changes: 1 addition & 1 deletion bot/slack/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (b *Bot) handleMessage(event *slack.MessageEvent) {
"event_user": event.User,
"msg": event.Text,
"event_subtype": event.SubType,
}).Info("handleMessage: ignoring message")
}).Debug("handleMessage: ignoring message")
return
}

Expand Down
17 changes: 3 additions & 14 deletions cmd/keel/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/keel-hq/keel/approvals"
"github.com/keel-hq/keel/bot"
"github.com/keel-hq/keel/cache/kubekv"
"github.com/keel-hq/keel/cache/memory"

"github.com/keel-hq/keel/constants"
"github.com/keel-hq/keel/extension/credentialshelper"
Expand Down Expand Up @@ -156,21 +156,10 @@ func main() {
k8s.WatchStatefulSets(&g, implementer.Client(), wl, buf)
k8s.WatchDaemonSets(&g, implementer.Client(), wl, buf)

keelsNamespace := constants.DefaultNamespace
if os.Getenv(EnvNamespace) != "" {
keelsNamespace = os.Getenv(EnvNamespace)
}

kkv, err := kubekv.New(implementer.ConfigMaps(keelsNamespace), "approvals")
if err != nil {
log.WithFields(log.Fields{
"error": err,
"namespace": keelsNamespace,
}).Fatal("main: failed to initialise kube-kv")
}
approvalsCache := memory.NewMemoryCache(24*time.Hour, 24*time.Hour, 10*time.Second)

serializer := codecs.DefaultSerializer()
approvalsManager := approvals.New(kkv, serializer)
approvalsManager := approvals.New(approvalsCache, serializer)

go approvalsManager.StartExpiryService(ctx)

Expand Down
6 changes: 2 additions & 4 deletions extension/credentialshelper/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"encoding/base64"
"fmt"
"net/url"
"regexp"
"strings"
"time"
"regexp"

// "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws"
Expand All @@ -24,6 +24,7 @@ import (
// This is required to reduce chance of hiting rate limits,
// more info here: https://docs.aws.amazon.com/AmazonECR/latest/userguide/service_limits.html
const AWSCredentialsExpiry = 2 * time.Hour

var registryRegxp *regexp.Regexp

func init() {
Expand All @@ -46,9 +47,7 @@ type CredentialsHelper struct {
func New() *CredentialsHelper {
ch := &CredentialsHelper{}
ch.enabled = true
log.Infof("extension.credentialshelper.aws: enabled")
ch.cache = NewCache(AWSCredentialsExpiry)

return ch
}

Expand Down Expand Up @@ -167,4 +166,3 @@ func parseRegistry(registry string) (registryID string, region string, err error

return registryParsed["registryID"], registryParsed["region"], nil
}

2 changes: 1 addition & 1 deletion extension/credentialshelper/credentialshelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ func GetCredentials(image *types.TrackedImage) (creds *types.Credentials) {
}
log.WithFields(log.Fields{
"tracked_image": image,
}).Error("extension.credentialshelper: credentials helper not found")
}).Debug("extension.credentialshelper: credentials helper not found")
return creds
}
2 changes: 1 addition & 1 deletion extension/notification/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func RegisterSender(name string, s Sender) {

log.WithFields(log.Fields{
"name": name,
}).Info("extension.notification: sender registered")
}).Debug("extension.notification: sender registered")

senders[name] = s
}
Expand Down

0 comments on commit f883ecc

Please sign in to comment.