diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index c1fdb63..0000000 --- a/.drone.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -kind: pipeline -name: default - - -workspace: - base: /go - path: src/github.com/morningconsult/go-elasticsearch-alerts - -steps: -- name: test - image: golang - commands: - - go get - - make test ---- -kind: signature -hmac: ef06a301e605821f6b1320b2a6dc4e12c789f9c14d5a180cd817659ce2ce8e14 - -... diff --git a/Dockerfile b/Dockerfile index e9e3f46..5025f26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Makefile b/Makefile index 4779bea..c96cbb4 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/ci/build-release.sh b/ci/build-release.sh index e103119..ab8faa8 100755 --- a/ci/build-release.sh +++ b/ci/build-release.sh @@ -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 diff --git a/ci/run-tests.sh b/ci/run-tests.sh index 9f0f0c2..291e74a 100755 --- a/ci/run-tests.sh +++ b/ci/run-tests.sh @@ -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 diff --git a/command/alert/alert.go b/command/alert/alert.go index bc2bd0c..7ecd6a7 100644 --- a/command/alert/alert.go +++ b/command/alert/alert.go @@ -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 diff --git a/command/alert/alert_test.go b/command/alert/alert_test.go index 82ffba5..c9da2be 100644 --- a/command/alert/alert_test.go +++ b/command/alert/alert_test.go @@ -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 @@ -14,12 +14,13 @@ package alert import ( + "bytes" "context" "fmt" "io" - // "io/ioutil" "os" "path/filepath" + "strings" "sync" "testing" "time" @@ -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{} @@ -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 { diff --git a/command/alert/email/email.go b/command/alert/email/email.go index c5f0958..0d01427 100644 --- a/command/alert/email/email.go +++ b/command/alert/email/email.go @@ -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 diff --git a/command/alert/email/email_test.go b/command/alert/email/email_test.go index 0308f50..ae4093d 100644 --- a/command/alert/email/email_test.go +++ b/command/alert/email/email_test.go @@ -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 diff --git a/command/alert/file/file.go b/command/alert/file/file.go index 0c18f06..5b1a680 100644 --- a/command/alert/file/file.go +++ b/command/alert/file/file.go @@ -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 diff --git a/command/alert/file/file_test.go b/command/alert/file/file_test.go index 5d8ec98..ee66458 100644 --- a/command/alert/file/file_test.go +++ b/command/alert/file/file_test.go @@ -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 diff --git a/command/alert/inventory.go b/command/alert/inventory.go index 43f4da8..3640f2e 100644 --- a/command/alert/inventory.go +++ b/command/alert/inventory.go @@ -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 diff --git a/command/alert/inventory_test.go b/command/alert/inventory_test.go index b8cfa50..24e1106 100644 --- a/command/alert/inventory_test.go +++ b/command/alert/inventory_test.go @@ -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 diff --git a/command/alert/slack/attachment.go b/command/alert/slack/attachment.go index 84ee467..0568b9f 100644 --- a/command/alert/slack/attachment.go +++ b/command/alert/slack/attachment.go @@ -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 diff --git a/command/alert/slack/slack.go b/command/alert/slack/slack.go index 5b463eb..e948f1e 100644 --- a/command/alert/slack/slack.go +++ b/command/alert/slack/slack.go @@ -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 diff --git a/command/alert/slack/slack_test.go b/command/alert/slack/slack_test.go index 4b0e88f..6166f3f 100644 --- a/command/alert/slack/slack_test.go +++ b/command/alert/slack/slack_test.go @@ -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 diff --git a/command/command.go b/command/command.go index 4a376d0..f44b8b7 100644 --- a/command/command.go +++ b/command/command.go @@ -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 @@ -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" @@ -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{}) -} diff --git a/command/controller.go b/command/controller.go index b3bcc09..42ed0d7 100644 --- a/command/controller.go +++ b/command/controller.go @@ -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 diff --git a/command/handlers.go b/command/handlers.go index 0e166d4..79f0b00 100644 --- a/command/handlers.go +++ b/command/handlers.go @@ -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 diff --git a/command/query/job.go b/command/query/job.go index dd6d1a2..fe2ef0d 100644 --- a/command/query/job.go +++ b/command/query/job.go @@ -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 diff --git a/command/query/job_test.go b/command/query/job_test.go index 41fb5e5..66df97d 100644 --- a/command/query/job_test.go +++ b/command/query/job_test.go @@ -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 diff --git a/command/query/transform.go b/command/query/transform.go index 0c187bc..4a997b3 100644 --- a/command/query/transform.go +++ b/command/query/transform.go @@ -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 diff --git a/command/query/transform_test.go b/command/query/transform_test.go index f112a39..dd714af 100644 --- a/command/query/transform_test.go +++ b/command/query/transform_test.go @@ -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 diff --git a/config/client.go b/config/client.go index 392d659..4e8fa15 100644 --- a/config/client.go +++ b/config/client.go @@ -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 diff --git a/config/client_test.go b/config/client_test.go index 2d43ff7..dff9cf3 100644 --- a/config/client_test.go +++ b/config/client_test.go @@ -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 diff --git a/config/parse.go b/config/parse.go index fd0bc83..9004d2d 100644 --- a/config/parse.go +++ b/config/parse.go @@ -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 diff --git a/config/parse_test.go b/config/parse_test.go index 15388ac..7e540e1 100644 --- a/config/parse_test.go +++ b/config/parse_test.go @@ -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 diff --git a/main.go b/main.go index ece0918..d0eb54b 100644 --- a/main.go +++ b/main.go @@ -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 diff --git a/scripts/build-binary.sh b/scripts/build-binary.sh index 5ce7370..bb56fbe 100755 --- a/scripts/build-binary.sh +++ b/scripts/build-binary.sh @@ -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 diff --git a/scripts/docker-build.sh b/scripts/docker-build.sh index cf9dac0..f662ad7 100755 --- a/scripts/docker-build.sh +++ b/scripts/docker-build.sh @@ -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 diff --git a/scripts/update-deps.sh b/scripts/update-deps.sh index 21003a3..db46fc2 100755 --- a/scripts/update-deps.sh +++ b/scripts/update-deps.sh @@ -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 diff --git a/utils/lock/lock.go b/utils/lock/lock.go index 5ef641b..87a2ce3 100644 --- a/utils/lock/lock.go +++ b/utils/lock/lock.go @@ -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 diff --git a/utils/traverse.go b/utils/traverse.go index f7c3ecc..957b989 100644 --- a/utils/traverse.go +++ b/utils/traverse.go @@ -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 diff --git a/utils/traverse_test.go b/utils/traverse_test.go index 2aeeb05..04d5607 100644 --- a/utils/traverse_test.go +++ b/utils/traverse_test.go @@ -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 diff --git a/version/version.go b/version/version.go index dabbc6e..93905fa 100644 --- a/version/version.go +++ b/version/version.go @@ -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