Skip to content

Commit

Permalink
feat: Displays controllerrevsion's revision in the UI. Closes argopro…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec authored Dec 17, 2019
1 parent 9783e7e commit e1c65a0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions util/resource/revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@ func GetRevision(obj *unstructured.Unstructured) int64 {
return revision
}
}

text, ok := obj.UnstructuredContent()["revision"].(int64)
if ok {
return text
}

return 0
}
1 change: 1 addition & 0 deletions util/resource/revision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e1c65a0

Please sign in to comment.