Skip to content

Commit 6df0ca0

Browse files
committed
add to deployments
1 parent 5a41bb3 commit 6df0ca0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pkg/templates/deployment.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type templateParameterDeployment struct {
3131
Criticality string
3232
Sensitivity string
3333
Deployment *apps.Deployment
34+
Priority string
3435
}
3536

3637
// CreateFromDeployment
@@ -74,6 +75,8 @@ func (a *PrometheusRuleTemplateManager) CreateFromDeployment(deployment *apps.De
7475
continue
7576
}
7677

78+
params.Priority = deployment.GetAnnotations()[priorityAnnotation]
79+
7780
templateName := strings.TrimLeft(k, fmt.Sprintf("%s/", heimPrefix))
7881
logger.Infow("template selected", "template", templateName)
7982
template, ok := a.templates[templateName]

pkg/templates/deployment_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var (
2424
environmentAnnotation: "testing",
2525
criticalityAnnotation: "low",
2626
sensitivityAnnotation: "public",
27+
priorityAnnotation: "p1",
2728
"com.uswitch.heimdall/replicas-availability-deployment": "1",
2829
},
2930
OwnerReferences: []metav1.OwnerReference{},
@@ -51,4 +52,8 @@ kube_deployment_spec_replicas{namespace="testNamespace", deployment="testApp"} <
5152
assert.Assert(t, is.Len(promrules, 1))
5253
assert.Equal(t, promrules[0].Spec.Groups[0].Rules[0].Expr.StrVal, expr)
5354
assert.Equal(t, promrules[0].Spec.Groups[0].Rules[0].Labels["owner"], "testDeploymentOwner")
55+
assert.Equal(t, promrules[0].Spec.Groups[0].Rules[0].Labels["environment"], "testing")
56+
assert.Equal(t, promrules[0].Spec.Groups[0].Rules[0].Labels["criticality"], "low")
57+
assert.Equal(t, promrules[0].Spec.Groups[0].Rules[0].Labels["sensitivity"], "public")
58+
assert.Equal(t, promrules[0].Spec.Groups[0].Rules[0].Labels["priority"], "p1")
5459
}

0 commit comments

Comments
 (0)