amtool: add support for stdin to check-config (#1431)
* amtool: add support for stdin to check-config Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Address Stuart's comment Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
42ea9a565b
commit
5aac7c840b
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue