@@ -11,7 +11,6 @@ import (
11
11
"io/ioutil"
12
12
"net/http"
13
13
"os"
14
- "strconv"
15
14
"time"
16
15
17
16
log "github.com/sirupsen/logrus"
@@ -49,11 +48,11 @@ func (a *App) apiRequest(method, url string, data io.Reader) ([]byte, int) {
49
48
log .Fatal (err )
50
49
}
51
50
52
- log .WithFields (log.Fields {
53
- "method" : method ,
54
- "statusCode" : strconv .Itoa (resp .StatusCode ),
55
- "body" : string (body ),
56
- }).Debug (url )
51
+ // log.WithFields(log.Fields{
52
+ // "method": method,
53
+ // "statusCode": strconv.Itoa(resp.StatusCode),
54
+ // "body": string(body),
55
+ // }).Debug(url)
57
56
58
57
return body , resp .StatusCode
59
58
}
@@ -262,6 +261,8 @@ func (a *App) pollImageAccessEnabled(groupID int, stateDesired bool) {
262
261
groupCopiesSettings := a .getGroupCopiesSettings (groupID )
263
262
copySettings := a .getRequestedCopy (groupCopiesSettings )
264
263
for copySettings .ImageAccessInformation .ImageAccessEnabled != stateDesired {
264
+ log .Debug ("current image access enabled: " , copySettings .ImageAccessInformation .ImageAccessEnabled )
265
+ log .Debug ("current image logged access mode: " , copySettings .ImageAccessInformation .ImageInformation .Mode )
265
266
time .Sleep (time .Duration (pollDelay ) * time .Second )
266
267
groupCopiesSettings = a .getGroupCopiesSettings (groupID )
267
268
copySettings = a .getRequestedCopy (groupCopiesSettings )
@@ -271,6 +272,24 @@ func (a *App) pollImageAccessEnabled(groupID int, stateDesired bool) {
271
272
}
272
273
pollCount ++
273
274
}
275
+ if stateDesired == true {
276
+ // if the desired state is to have image access == true, we should also
277
+ // ensure that logged access is also set before continuing.
278
+ for copySettings .ImageAccessInformation .ImageInformation .Mode != "LOGGED_ACCESS" {
279
+ log .Debug ("current image access enabled: " , copySettings .ImageAccessInformation .ImageAccessEnabled )
280
+ log .Debug ("current image logged access mode: " , copySettings .ImageAccessInformation .ImageInformation .Mode )
281
+ time .Sleep (time .Duration (pollDelay ) * time .Second )
282
+ groupCopiesSettings = a .getGroupCopiesSettings (groupID )
283
+ copySettings = a .getRequestedCopy (groupCopiesSettings )
284
+ if pollCount > pollMax {
285
+ fmt .Println ("Maximum poll count reached while waiting for logged access" )
286
+ break
287
+ }
288
+ pollCount ++
289
+ }
290
+ }
291
+ log .Debug ("current image access enabled: " , copySettings .ImageAccessInformation .ImageAccessEnabled )
292
+ log .Debug ("current image logged access mode: " , copySettings .ImageAccessInformation .ImageInformation .Mode )
274
293
}
275
294
276
295
func (a * App ) directAccess (t Task ) error {
0 commit comments