github.com/argoproj/argo-cd@v1.8.7/util/resource/revision.go (about) 1 package resource 2 3 import ( 4 "strconv" 5 6 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 7 ) 8 9 func GetRevision(obj *unstructured.Unstructured) int64 { 10 if obj == nil { 11 return 0 12 } 13 for _, name := range []string{"deployment.kubernetes.io/revision", "rollout.argoproj.io/revision"} { 14 text, ok := obj.GetAnnotations()[name] 15 if ok { 16 revision, _ := strconv.ParseInt(text, 10, 64) 17 return revision 18 } 19 } 20 21 text, ok := obj.UnstructuredContent()["revision"].(int64) 22 if ok { 23 return text 24 } 25 26 return 0 27 }