Skip to content

Commit 79a1057

Browse files
authored
Merge pull request #10 from grafana/20191217_404_info
clean exit message when 404 occurs
2 parents 2334ed6 + 918ac2b commit 79a1057

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+728
-100
lines changed

.golangci.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
run:
2+
# timeout for analysis, e.g. 30s, 5m, default is 1m
3+
deadline: 5m
4+
5+
modules-download-mode: vendor

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ cmd/cortextool/cortextool: $(APP_GO_FILES) cmd/cortextool/main.go
1717
CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D)
1818

1919
lint:
20-
GOGC=20 golangci-lint --deadline=20m run
20+
golangci-lint run
2121

2222
cross:
2323
CGO_ENABLED=0 gox -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" -ldflags=${LDFLAGS} -arch="amd64" -os="linux windows darwin" ./cmd/cortextool
2424

2525
test:
26-
go test -p=8 ./...
26+
go test -mod=vendor -p=8 ./...
2727

2828
clean:
2929
rm -rf cmd/cortextool/cortextool

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ replace github.com/hashicorp/consul => github.com/hashicorp/consul v1.5.1
66

77
require (
88
cloud.google.com/go v0.35.0
9-
github.com/alecthomas/chroma v0.6.6
9+
github.com/alecthomas/chroma v0.7.0
1010
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 // indirect
1111
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
1212
github.com/cortexproject/cortex v0.1.1-0.20190808112445-606262b7a637

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmx
3636
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
3737
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
3838
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
39-
github.com/alecthomas/chroma v0.6.6 h1:AwWMP1sWgMNgEiptNtV/T5GWOLtZFDdrc2ZfWx1ogmg=
40-
github.com/alecthomas/chroma v0.6.6/go.mod h1:zVlgtbRS7BJDrDY9SB238RmpoCBCYFlLmcfZ3durxTk=
39+
github.com/alecthomas/chroma v0.7.0 h1:z+0HgTUmkpRDRz0SRSdMaqOLfJV4F+N1FPDZUZIDUzw=
40+
github.com/alecthomas/chroma v0.7.0/go.mod h1:1U/PfCsTALWWYHDnsIQkxEBM0+6LLe0v8+RSVMOwxeY=
4141
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
4242
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
4343
github.com/alecthomas/kong v0.1.17-0.20190424132513-439c674f7ae0/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=

pkg/commands/alerts.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/alecthomas/chroma/quick"
1010
"github.com/grafana/cortextool/pkg/client"
1111
"github.com/prometheus/alertmanager/config"
12+
log "github.com/sirupsen/logrus"
1213
"gopkg.in/alecthomas/kingpin.v2"
1314
)
1415

@@ -51,6 +52,10 @@ func (a *AlertCommand) setup(k *kingpin.ParseContext) error {
5152
func (a *AlertCommand) getConfig(k *kingpin.ParseContext) error {
5253
cfg, templates, err := a.cli.GetAlertmanagerConfig(context.Background())
5354
if err != nil {
55+
if err == client.ErrResourceNotFound {
56+
log.Infof("no alertmanager config currently exist for this user")
57+
return nil
58+
}
5459
return err
5560
}
5661

pkg/commands/rules.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ func (r *RuleCommand) listRules(k *kingpin.ParseContext) error {
110110
func (r *RuleCommand) printRules(k *kingpin.ParseContext) error {
111111
rules, err := r.cli.ListRules(context.Background(), "")
112112
if err != nil {
113+
if err == client.ErrResourceNotFound {
114+
log.Infof("no rule groups currently exist for this user")
115+
return nil
116+
}
113117
log.Fatalf("unable to read rules from cortex, %v", err)
114118
}
115119
d, err := yaml.Marshal(&rules)
@@ -128,6 +132,10 @@ func (r *RuleCommand) printRules(k *kingpin.ParseContext) error {
128132
func (r *RuleCommand) getRuleGroup(k *kingpin.ParseContext) error {
129133
group, err := r.cli.GetRuleGroup(context.Background(), r.Namespace, r.RuleGroup)
130134
if err != nil {
135+
if err == client.ErrResourceNotFound {
136+
log.Infof("this rule group does not currently exist")
137+
return nil
138+
}
131139
log.Fatalf("unable to read rules from cortex, %v", err)
132140
}
133141
d, err := yaml.Marshal(&group)

vendor/github.com/alecthomas/chroma/.golangci.yml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/alecthomas/chroma/.travis.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/alecthomas/chroma/README.md

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/alecthomas/chroma/delegate.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)