@@ -23,7 +23,6 @@ import (
23
23
"reflect"
24
24
"strconv"
25
25
26
- "github.com/appscode/go/encoding/json/types"
27
26
"github.com/davecgh/go-spew/spew"
28
27
"github.com/fatih/structs"
29
28
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -106,7 +105,7 @@ func MustAlreadyReconciled(o interface{}) bool {
106
105
}
107
106
108
107
func AlreadyReconciled (o interface {}) (bool , error ) {
109
- var generation , observedGeneration * types. IntHash
108
+ var generation , observedGeneration int64
110
109
var err error
111
110
112
111
switch obj := o .(type ) {
@@ -120,36 +119,36 @@ func AlreadyReconciled(o interface{}) (bool, error) {
120
119
if err != nil {
121
120
return false , err
122
121
}
123
- return observedGeneration . MatchGeneration ( generation ) , nil
122
+ return observedGeneration == generation , nil
124
123
}
125
124
126
- func extractGenerationFromUnstructured (obj * unstructured.Unstructured ) (* types.IntHash , * types.IntHash , error ) {
127
- generation := types .IntHashForGeneration (obj .GetGeneration ())
128
-
125
+ func extractGenerationFromUnstructured (obj * unstructured.Unstructured ) (int64 , int64 , error ) {
129
126
val , found , err := unstructured .NestedFieldNoCopy (obj .Object , "status" , "observedGeneration" )
130
127
if err != nil {
131
- return nil , nil , err
128
+ return - 1 , - 1 , err
132
129
} else if ! found {
133
- return nil , nil , fmt . Errorf ( "status.observedGeneration is missing" )
130
+ return obj . GetGeneration (), - 1 , nil
134
131
}
135
- observedGeneration , err := types .ParseIntHash (val )
136
-
137
- return generation , observedGeneration , err
132
+ observedGeneration , ok := val .(int64 )
133
+ if ! ok {
134
+ return - 1 , - 1 , fmt .Errorf ("%s %s/%s status.observedGeneration %+v is not int64" , obj .GroupVersionKind (), obj .GetNamespace (), obj .GetName (), val )
135
+ }
136
+ return obj .GetGeneration (), observedGeneration , nil
138
137
}
139
138
140
- func extractGenerationFromObject (obj metav1.Object ) (* types.IntHash , * types.IntHash , error ) {
141
- generation := types .IntHashForGeneration (obj .GetGeneration ())
142
-
139
+ func extractGenerationFromObject (obj metav1.Object ) (int64 , int64 , error ) {
143
140
st := structs .New (obj )
144
141
fieldStatus , found := st .FieldOk ("Status" )
145
142
if ! found {
146
- return nil , nil , fmt . Errorf ( "status is missing" )
143
+ return obj . GetGeneration (), - 1 , nil
147
144
}
148
145
fieldObsGen , found := fieldStatus .FieldOk ("ObservedGeneration" )
149
146
if ! found {
150
- return nil , nil , fmt . Errorf ( "status.observedGeneration is missing" )
147
+ return obj . GetGeneration (), - 1 , nil
151
148
}
152
- observedGeneration , err := types .ParseIntHash (fieldObsGen .Value ())
153
-
154
- return generation , observedGeneration , err
149
+ observedGeneration , ok := fieldObsGen .Value ().(int64 )
150
+ if ! ok {
151
+ return - 1 , - 1 , fmt .Errorf ("%s %s/%s status.observedGeneration %+v is not int64" , reflect .TypeOf (obj ).String (), obj .GetNamespace (), obj .GetName (), fieldObsGen .Value ())
152
+ }
153
+ return obj .GetGeneration (), observedGeneration , nil
155
154
}
0 commit comments