-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use env RUNBOOK_URL_TEMPLATE for the runbooks URL template (#307)
Signed-off-by: assafad <aadmi@redhat.com>
- Loading branch information
Showing
3 changed files
with
85 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package hostpathprovisioner | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Prometheus", func() { | ||
BeforeEach(func() { | ||
os.Unsetenv(runbookURLTemplateEnv) | ||
}) | ||
|
||
AfterEach(func() { | ||
os.Unsetenv(runbookURLTemplateEnv) | ||
}) | ||
|
||
It("should use the default runbook URL template when no ENV Variable is set", func() { | ||
promRule := createPrometheusRule("mynamespace") | ||
|
||
for _, group := range promRule.Spec.Groups { | ||
for _, rule := range group.Rules { | ||
if rule.Alert != "" { | ||
if rule.Annotations["runbook_url"] != "" { | ||
Expect(rule.Annotations["runbook_url"]).To(Equal(fmt.Sprintf(defaultRunbookURLTemplate, rule.Alert))) | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
|
||
It("should use the desired runbook URL template when its ENV Variable is set", func() { | ||
desiredRunbookURLTemplate := "desired/runbookURL/template/%s" | ||
os.Setenv(runbookURLTemplateEnv, desiredRunbookURLTemplate) | ||
|
||
promRule := createPrometheusRule("mynamespace") | ||
|
||
for _, group := range promRule.Spec.Groups { | ||
for _, rule := range group.Rules { | ||
if rule.Alert != "" { | ||
if rule.Annotations["runbook_url"] != "" { | ||
Expect(rule.Annotations["runbook_url"]).To(Equal(fmt.Sprintf(desiredRunbookURLTemplate, rule.Alert))) | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
}) |