@@ -141,35 +141,6 @@ const (
141
141
noAuth
142
142
)
143
143
144
- // readFromJSONBlob sets token data in dest from the provided JSON.
145
- func (bt * bearerToken ) readFromJSONBlob (blob []byte ) error {
146
- var token struct {
147
- Token string `json:"token"`
148
- AccessToken string `json:"access_token"`
149
- ExpiresIn int `json:"expires_in"`
150
- IssuedAt time.Time `json:"issued_at"`
151
- expirationTime time.Time
152
- }
153
- if err := json .Unmarshal (blob , & token ); err != nil {
154
- return err
155
- }
156
-
157
- bt .token = token .Token
158
- if bt .token == "" {
159
- bt .token = token .AccessToken
160
- }
161
-
162
- if token .ExpiresIn < minimumTokenLifetimeSeconds {
163
- token .ExpiresIn = minimumTokenLifetimeSeconds
164
- logrus .Debugf ("Increasing token expiration to: %d seconds" , token .ExpiresIn )
165
- }
166
- if token .IssuedAt .IsZero () {
167
- token .IssuedAt = time .Now ().UTC ()
168
- }
169
- bt .expirationTime = token .IssuedAt .Add (time .Duration (token .ExpiresIn ) * time .Second )
170
- return nil
171
- }
172
-
173
144
// this is cloned from docker/go-connections because upstream docker has changed
174
145
// it and make deps here fails otherwise.
175
146
// We'll drop this once we upgrade to docker 1.13.x deps.
@@ -838,6 +809,35 @@ func (c *dockerClient) getBearerToken(ctx context.Context, dest *bearerToken, ch
838
809
return dest .readFromJSONBlob (tokenBlob )
839
810
}
840
811
812
+ // readFromJSONBlob sets token data in dest from the provided JSON.
813
+ func (bt * bearerToken ) readFromJSONBlob (blob []byte ) error {
814
+ var token struct {
815
+ Token string `json:"token"`
816
+ AccessToken string `json:"access_token"`
817
+ ExpiresIn int `json:"expires_in"`
818
+ IssuedAt time.Time `json:"issued_at"`
819
+ expirationTime time.Time
820
+ }
821
+ if err := json .Unmarshal (blob , & token ); err != nil {
822
+ return err
823
+ }
824
+
825
+ bt .token = token .Token
826
+ if bt .token == "" {
827
+ bt .token = token .AccessToken
828
+ }
829
+
830
+ if token .ExpiresIn < minimumTokenLifetimeSeconds {
831
+ token .ExpiresIn = minimumTokenLifetimeSeconds
832
+ logrus .Debugf ("Increasing token expiration to: %d seconds" , token .ExpiresIn )
833
+ }
834
+ if token .IssuedAt .IsZero () {
835
+ token .IssuedAt = time .Now ().UTC ()
836
+ }
837
+ bt .expirationTime = token .IssuedAt .Add (time .Duration (token .ExpiresIn ) * time .Second )
838
+ return nil
839
+ }
840
+
841
841
// detectPropertiesHelper performs the work of detectProperties which executes
842
842
// it at most once.
843
843
func (c * dockerClient ) detectPropertiesHelper (ctx context.Context ) error {
0 commit comments