mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -17,5 +17,11 @@ func GetRevision(obj *unstructured.Unstructured) int64 {
|
||||
return revision
|
||||
}
|
||||
}
|
||||
|
||||
text, ok := obj.UnstructuredContent()["revision"].(int64)
|
||||
if ok {
|
||||
return text
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user