feat: Displays controllerrevsion's revision in the UI. Closes #2306 (#2702)

This commit is contained in:
Alex Collins
2019-12-17 14:12:13 -08:00
committed by GitHub
parent 9783e7e2bf
commit e1c65a0190
3 changed files with 21 additions and 0 deletions

View File

@@ -47,6 +47,20 @@ func NewPod() *unstructured.Unstructured {
return Unstructured(PodManifest)
}
func NewControllerRevision() *unstructured.Unstructured {
return Unstructured(`
kind: ControllerRevision
apiVersion: metacontroller.k8s.io/v1alpha1
metadata:
labels:
app: nginx
controller.kubernetes.io/hash: c7cd8d57f
name: web-c7cd8d57f
namespace: statefulset
revision: 2
`)
}
func NewCRD() *unstructured.Unstructured {
return Unstructured(`apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition

View File

@@ -17,5 +17,11 @@ func GetRevision(obj *unstructured.Unstructured) int64 {
return revision
}
}
text, ok := obj.UnstructuredContent()["revision"].(int64)
if ok {
return text
}
return 0
}

View File

@@ -23,6 +23,7 @@ func TestGetRevision(t *testing.T) {
{"Garbage", args{obj: revisionExample("garbage.kubernetes.io/revision", "1")}, 0},
{"Deployments", args{obj: revisionExample("deployment.kubernetes.io/revision", "1")}, 1},
{"Rollouts", args{obj: revisionExample("rollout.argoproj.io/revision", "1")}, 1},
{"ControllerRevision", args{obj: test.NewControllerRevision()}, 2},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {