mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 06:17:27 -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 (
|
||||
successExitCode = 0
|
||||
failureExitCode = 1
|
||||
// exit code 3 is used for "one or more lint issues detected".
|
||||
successExitCode = 0
|
||||
failureExitCode = 1
|
||||
configErrExitCode = 2
|
||||
// Exit code 3 is used for "one or more lint issues detected".
|
||||
lintErrExitCode = 3
|
||||
)
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ func CheckSD(sdConfigFiles, sdJobName string, sdTimeout time.Duration) int {
|
|||
cfg, err := config.LoadFile(sdConfigFiles, false, false, logger)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Cannot load config", err)
|
||||
return 2
|
||||
return configErrExitCode
|
||||
}
|
||||
|
||||
var scrapeConfig *config.ScrapeConfig
|
||||
|
@ -63,7 +63,7 @@ func CheckSD(sdConfigFiles, sdJobName string, sdTimeout time.Duration) int {
|
|||
for _, job := range jobs {
|
||||
fmt.Fprintf(os.Stderr, "\t%s\n", job)
|
||||
}
|
||||
return 1
|
||||
return failureExitCode
|
||||
}
|
||||
|
||||
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})
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Could not create new discoverer", err)
|
||||
return 2
|
||||
return configErrExitCode
|
||||
}
|
||||
go d.Run(ctx, targetGroupChan)
|
||||
}
|
||||
|
@ -100,11 +100,11 @@ outerLoop:
|
|||
res, err := json.MarshalIndent(results, "", " ")
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not marshal result json: %s", err)
|
||||
return 2
|
||||
return configErrExitCode
|
||||
}
|
||||
|
||||
fmt.Printf("%s", res)
|
||||
return 0
|
||||
return successExitCode
|
||||
}
|
||||
|
||||
func getSDCheckResult(targetGroups []*targetgroup.Group, scrapeConfig *config.ScrapeConfig) []sdCheckResult {
|
||||
|
|
|
@ -56,9 +56,9 @@ func RulesUnitTest(queryOpts promql.LazyLoaderOpts, files ...string) int {
|
|||
fmt.Println()
|
||||
}
|
||||
if failed {
|
||||
return 1
|
||||
return failureExitCode
|
||||
}
|
||||
return 0
|
||||
return successExitCode
|
||||
}
|
||||
|
||||
func ruleUnitTest(filename string, queryOpts promql.LazyLoaderOpts) []error {
|
||||
|
|
Loading…
Reference in a new issue