Skip to content

Commit

Permalink
Merge pull request #6 from johntdyer/fix-release
Browse files Browse the repository at this point in the history
Switch to using webex teams adaptive cards
  • Loading branch information
johntdyer authored Nov 24, 2019
2 parents 719041f + 9dab531 commit 12663ee
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 101 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendor/
bonsai/
coverage.txt
coverage.out
dist/
Expand Down
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ checksum:
# You can change the name of the checksums file.
# Default is `{{ .ProjectName }}_{{ .Version }}_checksums.txt`.
name_template: "{{ .ProjectName }}_{{ .Version }}_sha512-checksums.txt"
algorithm: sha512

archives:
- id: default
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ after_deploy:
- rm -f coverage.txt
- git clone https://github.com/sensu/sensu-go-bonsai-asset.git bonsai
- bonsai/generate-sha512sum.sh
- bonsai/github-release-upload.sh github_api_token=$GITHUB_TOKEN repo_slug="$TRAVIS_REPO_SLUG"
tag="${TRAVIS_TAG}" filename="dist/$(cat dist/sha512_file)"
- bonsai/github-release-upload.sh github_api_token=$GITHUB_TOKEN repo_slug="$TRAVIS_REPO_SLUG" tag="${TRAVIS_TAG}" filename="dist/$(cat dist/sha512_file)"
9 changes: 8 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ go 1.13

require (
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc
github.com/coreos/etcd v3.3.12+incompatible
github.com/davecgh/go-spew v1.1.1
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/echlebek/crock v1.0.1 // indirect
github.com/go-resty/resty/v2 v2.1.0
github.com/gogo/protobuf v1.2.1
github.com/golang/protobuf v1.3.1
github.com/google/gofuzz v1.0.0 // indirect
github.com/robfig/cron v1.0.1-0.20171101201047-2315d5715e36 // indirect
github.com/json-iterator/go v0.0.0-20171115153421-f7279a603ede
github.com/pmezard/go-difflib v1.0.0
github.com/robfig/cron v1.0.1-0.20171101201047-2315d5715e36
github.com/sensu/sensu-go v0.0.0-20190508172758-32aea478ae74
github.com/sensu/sensu-plugins-go-library v0.0.0-20190807215741-0080e59982e6
github.com/stretchr/testify v1.3.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ github.com/robfig/cron v1.0.1-0.20171101201047-2315d5715e36 h1:rnqcu/6Ngp83VH+ZT
github.com/robfig/cron v1.0.1-0.20171101201047-2315d5715e36/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
github.com/sensu/sensu-go v0.0.0-20190508172758-32aea478ae74 h1:j8X+G1s42GdIcVWvNcbVy1vN8bsX24DADOW8FfOupk0=
github.com/sensu/sensu-go v0.0.0-20190508172758-32aea478ae74/go.mod h1:oP0w1f0WSgVPzGUhK5EmM774W/JaWEpj4zg9Kd972y8=
github.com/sensu/sensu-go v5.10.1+incompatible h1:X0J/FSRV/Y6qTzNPlEnGm8do4SsPm0OPPjLLkSidMgs=
github.com/sensu/sensu-plugins-go-library v0.0.0-20190807215741-0080e59982e6 h1:oLeVmvrj2+FtRhmo/tjEhMZn6vr+LYrrKMxnivTDaBc=
github.com/sensu/sensu-plugins-go-library v0.0.0-20190807215741-0080e59982e6/go.mod h1:IXXp61sHWSafQtx3dlFxnbm74fGmu/tA7NcKVkFG3ug=
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ func sendMessage(event *corev2.Event) error {
}

func validateEvent(event *corev2.Event) error {

if event.Timestamp <= 0 {
return errors.New("timestamp is missing or must be greater than zero")
}
Expand Down
61 changes: 61 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,72 @@ package main

import (
"testing"
"time"

corev2 "github.com/sensu/sensu-go/api/core/v2"
"github.com/sensu/sensu-go/types"
"github.com/stretchr/testify/assert"
)

var (
eventWithStatus = &corev2.Event{
Check: &corev2.Check{
Output: "This is a string w/ new line\n",
Status: 10,
},
}
)

func TestTrimSuffixCheckOutput(t *testing.T) {
assert := assert.New(t)
output := trimSuffixCheckOutput(eventWithStatus)
assert.Equal("This is a string w/ new line", output)
}

func TestParseTime(t *testing.T) {
assert := assert.New(t)
timeStamp, _ := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "Dec 29, 2014 at 7:54pm (SGT)")
assert.Equal("2014-12-29 19:54:00 +0000 SGT", timeStamp.String())
}

func TestValidateEvent(t *testing.T) {

assert := assert.New(t)
err := validateEvent(&corev2.Event{
Timestamp: 11231231,
Entity: &corev2.Entity{
EntityClass: "agent",
ObjectMeta: corev2.ObjectMeta{
Name: "fp",
Namespace: "default",
},
},
Check: &corev2.Check{
Output: "This is a string w/ new line\n",
Status: 10,
Interval: 20,
ObjectMeta: corev2.ObjectMeta{
Name: "check-name",
},
},
})
assert.Nil(err)
}

func TestStringMinifier(t *testing.T) {
assert := assert.New(t)

input := `<blockquote class='blue'> foo bar <br/>
<b>Check Name:</b> foocheck
<b>Entity:</b> entity-nmame <br/>
<b>Check output:</b> this is output <br/>
<b>History:</b> <br/>
</blockquote>`

output := stringMinifier(input)
assert.Equal(output, "<blockquote class='blue'> foo bar <br/> <b>Check Name:</b> foocheck <b>Entity:</b> entity-nmame <br/> <b>Check output:</b> this is output <br/> <b>History:</b> <br/> </blockquote>")

}
func TestFormattedEventAction(t *testing.T) {
assert := assert.New(t)
event := types.FixtureEvent("entity1", "check1")
Expand Down
22 changes: 0 additions & 22 deletions travis/generate-sha512sum.sh

This file was deleted.

76 changes: 0 additions & 76 deletions travis/github-release-upload.sh

This file was deleted.

0 comments on commit 12663ee

Please sign in to comment.