mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-04-04 15:58:49 +02:00
22 lines
423 B
Go
22 lines
423 B
Go
package resource
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
|
)
|
|
|
|
func GetRevision(obj *unstructured.Unstructured) int64 {
|
|
if obj == nil {
|
|
return 0
|
|
}
|
|
for _, name := range []string{"deployment.kubernetes.io/revision", "rollout.argoproj.io/revision"} {
|
|
text, ok := obj.GetAnnotations()[name]
|
|
if ok {
|
|
revision, _ := strconv.ParseInt(text, 10, 64)
|
|
return revision
|
|
}
|
|
}
|
|
return 0
|
|
}
|