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
579acdc9e2
commit
45567a804d
|
@ -15,6 +15,7 @@ package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/prometheus/alertmanager/config"
|
"github.com/prometheus/alertmanager/config"
|
||||||
"github.com/prometheus/alertmanager/template"
|
"github.com/prometheus/alertmanager/template"
|
||||||
|
@ -47,6 +48,14 @@ func (c *checkConfigCmd) checkConfig(ctx *kingpin.ParseContext) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckConfig(args []string) 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
|
failed := 0
|
||||||
|
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
|
|
Loading…
Reference in New Issue