@@ -63,7 +63,6 @@ func CreateGCPSnapClient(project, snapPrefix string, zones []string, labels mode
63
63
}
64
64
}
65
65
66
- // Helper function
67
66
// In case of a gcp link it returns the target (final part after /)
68
67
func formatLinkString (in string ) string {
69
68
@@ -187,6 +186,21 @@ func (gsc *GCPSnapClient) DeleteSnapshot(snapName string) (string, error) {
187
186
return resp .SelfLink , nil
188
187
}
189
188
189
+ func parseOperationOut (operation * compute.Operation ) (string , error ) {
190
+
191
+ // Get status (Possible values: "DONE", "PENDING", "RUNNING") and errors
192
+ status := operation .Status
193
+ if operation .Error != nil {
194
+ var err_msgs []string
195
+ for _ , err := range operation .Error .Errors {
196
+ err_msgs = append (err_msgs , err .Message )
197
+ }
198
+ return status , errors .New (strings .Join (err_msgs , "," ))
199
+ }
200
+ return status , nil
201
+
202
+ }
203
+
190
204
func (gsc * GCPSnapClient ) GetZonalOperationStatus (operation , zone string ) (string , error ) {
191
205
192
206
// Format in case of link
@@ -198,16 +212,7 @@ func (gsc *GCPSnapClient) GetZonalOperationStatus(operation, zone string) (strin
198
212
return "" , errors .Wrap (err , "error getting zonal operation:" )
199
213
}
200
214
201
- // Get status (Possible values: "DONE", "PENDING", "RUNNING") and errors
202
- status := op .Status
203
- if op .Error != nil {
204
- var err_msgs []string
205
- for _ , err := range op .Error .Errors {
206
- err_msgs = append (err_msgs , err .Message )
207
- }
208
- return status , errors .New (strings .Join (err_msgs , "," ))
209
- }
210
- return status , nil
215
+ return parseOperationOut (op )
211
216
}
212
217
213
218
func (gsc * GCPSnapClient ) GetGlobalOperationStatus (operation string ) (string , error ) {
@@ -220,14 +225,5 @@ func (gsc *GCPSnapClient) GetGlobalOperationStatus(operation string) (string, er
220
225
return "" , errors .Wrap (err , "error getting global operation:" )
221
226
}
222
227
223
- // Get status (Possible values: "DONE", "PENDING", "RUNNING") and errors
224
- status := op .Status
225
- if op .Error != nil {
226
- var err_msgs []string
227
- for _ , err := range op .Error .Errors {
228
- err_msgs = append (err_msgs , err .Message )
229
- }
230
- return status , errors .New (strings .Join (err_msgs , "," ))
231
- }
232
- return status , nil
228
+ return parseOperationOut (op )
233
229
}
0 commit comments