From 45567a804d2e64b742e5f151dff7cb13647e9155 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Mon, 9 Jul 2018 19:27:04 +0200 Subject: [PATCH] amtool: add support for stdin to check-config (#1431) * amtool: add support for stdin to check-config Signed-off-by: Simon Pasquier * Address Stuart's comment Signed-off-by: Simon Pasquier --- cli/check_config.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cli/check_config.go b/cli/check_config.go index 06047721..efaf7ebb 100644 --- a/cli/check_config.go +++ b/cli/check_config.go @@ -15,6 +15,7 @@ package cli import ( "fmt" + "os" "github.com/prometheus/alertmanager/config" "github.com/prometheus/alertmanager/template" @@ -47,6 +48,14 @@ func (c *checkConfigCmd) checkConfig(ctx *kingpin.ParseContext) error { } func CheckConfig(args []string) error { + if len(args) == 0 { + stat, _ := os.Stdin.Stat() + if (stat.Mode() & os.ModeCharDevice) != 0 { + kingpin.Fatalf("Failed to read from standard input") + } + args = []string{os.Stdin.Name()} + } + failed := 0 for _, arg := range args {