mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
add errcodes from sd file
Signed-off-by: jessicagreben <jessicagrebens@gmail.com>
This commit is contained in:
parent
764f2d03a5
commit
99bb56fc46
|
@ -57,9 +57,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
successExitCode = 0
|
successExitCode = 0
|
||||||
failureExitCode = 1
|
failureExitCode = 1
|
||||||
// exit code 3 is used for "one or more lint issues detected".
|
configErrExitCode = 2
|
||||||
|
// Exit code 3 is used for "one or more lint issues detected".
|
||||||
lintErrExitCode = 3
|
lintErrExitCode = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ func CheckSD(sdConfigFiles, sdJobName string, sdTimeout time.Duration) int {
|
||||||
cfg, err := config.LoadFile(sdConfigFiles, false, false, logger)
|
cfg, err := config.LoadFile(sdConfigFiles, false, false, logger)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, "Cannot load config", err)
|
fmt.Fprintln(os.Stderr, "Cannot load config", err)
|
||||||
return 2
|
return configErrExitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
var scrapeConfig *config.ScrapeConfig
|
var scrapeConfig *config.ScrapeConfig
|
||||||
|
@ -63,7 +63,7 @@ func CheckSD(sdConfigFiles, sdJobName string, sdTimeout time.Duration) int {
|
||||||
for _, job := range jobs {
|
for _, job := range jobs {
|
||||||
fmt.Fprintf(os.Stderr, "\t%s\n", job)
|
fmt.Fprintf(os.Stderr, "\t%s\n", job)
|
||||||
}
|
}
|
||||||
return 1
|
return failureExitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
targetGroupChan := make(chan []*targetgroup.Group)
|
targetGroupChan := make(chan []*targetgroup.Group)
|
||||||
|
@ -74,7 +74,7 @@ func CheckSD(sdConfigFiles, sdJobName string, sdTimeout time.Duration) int {
|
||||||
d, err := cfg.NewDiscoverer(discovery.DiscovererOptions{Logger: logger})
|
d, err := cfg.NewDiscoverer(discovery.DiscovererOptions{Logger: logger})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, "Could not create new discoverer", err)
|
fmt.Fprintln(os.Stderr, "Could not create new discoverer", err)
|
||||||
return 2
|
return configErrExitCode
|
||||||
}
|
}
|
||||||
go d.Run(ctx, targetGroupChan)
|
go d.Run(ctx, targetGroupChan)
|
||||||
}
|
}
|
||||||
|
@ -100,11 +100,11 @@ outerLoop:
|
||||||
res, err := json.MarshalIndent(results, "", " ")
|
res, err := json.MarshalIndent(results, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Could not marshal result json: %s", err)
|
fmt.Fprintf(os.Stderr, "Could not marshal result json: %s", err)
|
||||||
return 2
|
return configErrExitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("%s", res)
|
fmt.Printf("%s", res)
|
||||||
return 0
|
return successExitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSDCheckResult(targetGroups []*targetgroup.Group, scrapeConfig *config.ScrapeConfig) []sdCheckResult {
|
func getSDCheckResult(targetGroups []*targetgroup.Group, scrapeConfig *config.ScrapeConfig) []sdCheckResult {
|
||||||
|
|
|
@ -56,9 +56,9 @@ func RulesUnitTest(queryOpts promql.LazyLoaderOpts, files ...string) int {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
if failed {
|
if failed {
|
||||||
return 1
|
return failureExitCode
|
||||||
}
|
}
|
||||||
return 0
|
return successExitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
func ruleUnitTest(filename string, queryOpts promql.LazyLoaderOpts) []error {
|
func ruleUnitTest(filename string, queryOpts promql.LazyLoaderOpts) []error {
|
||||||
|
|
Loading…
Reference in a new issue