@@ -144,35 +144,6 @@ const (
144
144
noAuth
145
145
)
146
146
147
- // readFromJSONBlob sets token data in dest from the provided JSON.
148
- func (bt * bearerToken ) readFromJSONBlob (blob []byte ) error {
149
- var token struct {
150
- Token string `json:"token"`
151
- AccessToken string `json:"access_token"`
152
- ExpiresIn int `json:"expires_in"`
153
- IssuedAt time.Time `json:"issued_at"`
154
- expirationTime time.Time
155
- }
156
- if err := json .Unmarshal (blob , & token ); err != nil {
157
- return err
158
- }
159
-
160
- bt .token = token .Token
161
- if bt .token == "" {
162
- bt .token = token .AccessToken
163
- }
164
-
165
- if token .ExpiresIn < minimumTokenLifetimeSeconds {
166
- token .ExpiresIn = minimumTokenLifetimeSeconds
167
- logrus .Debugf ("Increasing token expiration to: %d seconds" , token .ExpiresIn )
168
- }
169
- if token .IssuedAt .IsZero () {
170
- token .IssuedAt = time .Now ().UTC ()
171
- }
172
- bt .expirationTime = token .IssuedAt .Add (time .Duration (token .ExpiresIn ) * time .Second )
173
- return nil
174
- }
175
-
176
147
// dockerCertDir returns a path to a directory to be consumed by tlsclientconfig.SetupCertificates() depending on ctx and hostPort.
177
148
func dockerCertDir (sys * types.SystemContext , hostPort string ) (string , error ) {
178
149
if sys != nil && sys .DockerCertPath != "" {
@@ -900,6 +871,35 @@ func (c *dockerClient) getBearerToken(ctx context.Context, dest *bearerToken, ch
900
871
return dest .readFromJSONBlob (tokenBlob )
901
872
}
902
873
874
+ // readFromJSONBlob sets token data in dest from the provided JSON.
875
+ func (bt * bearerToken ) readFromJSONBlob (blob []byte ) error {
876
+ var token struct {
877
+ Token string `json:"token"`
878
+ AccessToken string `json:"access_token"`
879
+ ExpiresIn int `json:"expires_in"`
880
+ IssuedAt time.Time `json:"issued_at"`
881
+ expirationTime time.Time
882
+ }
883
+ if err := json .Unmarshal (blob , & token ); err != nil {
884
+ return err
885
+ }
886
+
887
+ bt .token = token .Token
888
+ if bt .token == "" {
889
+ bt .token = token .AccessToken
890
+ }
891
+
892
+ if token .ExpiresIn < minimumTokenLifetimeSeconds {
893
+ token .ExpiresIn = minimumTokenLifetimeSeconds
894
+ logrus .Debugf ("Increasing token expiration to: %d seconds" , token .ExpiresIn )
895
+ }
896
+ if token .IssuedAt .IsZero () {
897
+ token .IssuedAt = time .Now ().UTC ()
898
+ }
899
+ bt .expirationTime = token .IssuedAt .Add (time .Duration (token .ExpiresIn ) * time .Second )
900
+ return nil
901
+ }
902
+
903
903
// detectPropertiesHelper performs the work of detectProperties which executes
904
904
// it at most once.
905
905
func (c * dockerClient ) detectPropertiesHelper (ctx context.Context ) error {
0 commit comments