Skip to content

Commit

Permalink
chore: Updated license header to 2019; command/client.go: Separated l…
Browse files Browse the repository at this point in the history
…ogic for creating new Consul client into its own file; .drone.yml: Deleted since no longer using drone
  • Loading branch information
dbellinghoven committed Jan 9, 2019
1 parent 86ab09b commit 08a272c
Show file tree
Hide file tree
Showing 35 changed files with 45 additions and 85 deletions.
20 changes: 0 additions & 20 deletions .drone.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
# Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

# Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
# Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion ci/build-release.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
# Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion ci/run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
# Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion command/alert/alert.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
15 changes: 12 additions & 3 deletions command/alert/alert_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand All @@ -14,12 +14,13 @@
package alert

import (
"bytes"
"context"
"fmt"
"io"
// "io/ioutil"
"os"
"path/filepath"
"strings"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -177,8 +178,12 @@ func TestRunError(t *testing.T) {

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)

buf := new(bytes.Buffer)
logger := hclog.New(&hclog.LoggerOptions{
Output: buf,
})
ah := NewAlertHandler(&AlertHandlerConfig{
Logger: hclog.Default(),
Logger: logger,
})

em := &errorAlertMethod{}
Expand Down Expand Up @@ -223,6 +228,10 @@ func TestRunError(t *testing.T) {
time.Sleep(10 * time.Second)

// Should attempt to execute Write() 3 times (see logs)
expected := `[ERROR] [Alert Handler] error returned by alert function: error="test error" remaining_retries=0`
if !strings.Contains(buf.String(), expected) {
t.Fatalf("Expected errors to contain:\n\t%s\nGot:\n\t%s", expected, buf.String())
}
}

func randomUUID(t *testing.T) string {
Expand Down
2 changes: 1 addition & 1 deletion command/alert/email/email.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion command/alert/email/email_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion command/alert/file/file.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion command/alert/file/file_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion command/alert/inventory.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion command/alert/inventory_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion command/alert/slack/attachment.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion command/alert/slack/slack.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion command/alert/slack/slack_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
30 changes: 1 addition & 29 deletions command/command.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand All @@ -18,10 +18,8 @@ import (
"fmt"
"os"
"os/signal"
"strings"
"syscall"

"github.com/hashicorp/consul/api"
"github.com/hashicorp/go-hclog"
"github.com/morningconsult/go-elasticsearch-alerts/command/alert"
"github.com/morningconsult/go-elasticsearch-alerts/config"
Expand Down Expand Up @@ -204,29 +202,3 @@ func makeReloadCh(ctx context.Context) chan struct{} {
}()
return resultCh
}

func newConsulClient(config map[string]string) (*api.Client, error) {
consulEnvVars := []string{
api.HTTPAddrEnvName,
api.HTTPTokenEnvName,
api.HTTPSSLEnvName,
api.HTTPCAFile,
api.HTTPCAPath,
api.HTTPClientCert,
api.HTTPClientKey,
api.HTTPTLSServerName,
api.HTTPSSLVerifyEnvName,
}

for _, env := range consulEnvVars {
v, ok := config[env]
if !ok {
v, ok = config[strings.ToLower(env)]
}
if ok && v != "" && os.Getenv(env) == "" {
os.Setenv(env, v)
defer os.Unsetenv(env)
}
}
return api.NewClient(&api.Config{})
}
2 changes: 1 addition & 1 deletion command/controller.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion command/handlers.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion command/query/job.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion command/query/job_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion command/query/transform.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion command/query/transform_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion config/client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion config/client_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion config/parse.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion config/parse_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-binary.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
# Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker-build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
# Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-deps.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
# Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion utils/lock/lock.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion utils/traverse.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion utils/traverse_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Morning Consult, LLC or its affiliates. All Rights Reserved.
// Copyright 2019 The Morning Consult, LLC or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
Expand Down

0 comments on commit 08a272c

Please sign in to comment.