@@ -59,31 +59,22 @@ pub enum RegistryOperation {
5959 Pull ,
6060}
6161
62- // Types to allow better naming
63- type Registry = String ;
64- type Repository = String ;
65-
6662#[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Ord ) ]
6763struct TokenCacheKey {
68- registry : Registry ,
69- repository : Repository ,
64+ registry : String ,
65+ repository : String ,
7066 operation : RegistryOperation ,
7167}
7268
73- type TokenExpiration = u64 ;
74-
7569struct TokenCacheValue {
7670 token : RegistryTokenType ,
77- expiration : TokenExpiration ,
71+ expiration : u64 ,
7872}
7973
80- // (registry, repository, scope) -> (token, expiration)
81- type CacheType = BTreeMap < TokenCacheKey , TokenCacheValue > ;
82-
8374#[ derive( Default , Clone ) ]
8475pub ( crate ) struct TokenCache {
8576 // (registry, repository, scope) -> (token, expiration)
86- tokens : Arc < RwLock < CacheType > > ,
77+ tokens : Arc < RwLock < BTreeMap < TokenCacheKey , TokenCacheValue > > > ,
8778}
8879
8980impl TokenCache {
@@ -165,15 +156,15 @@ impl TokenCache {
165156 . expect ( "Time went backwards" )
166157 . as_secs ( ) ;
167158 if epoch > * expiration {
168- debug ! ( ?key, %expiration, miss=false , expired=true , "Fetching token" ) ;
159+ debug ! ( %key . registry , %key . repository , ?key. operation , %expiration, miss=false , expired=true , "Fetching token" ) ;
169160 None
170161 } else {
171- debug ! ( ?key, %expiration, miss=false , expired=false , "Fetching token" ) ;
162+ debug ! ( %key . registry , %key . repository , ?key. operation , %expiration, miss=false , expired=false , "Fetching token" ) ;
172163 Some ( token. clone ( ) )
173164 }
174165 }
175166 None => {
176- debug ! ( ?key, miss = true , "Fetching token" ) ;
167+ debug ! ( %key . registry , %key . repository , ?key. operation , miss = true , "Fetching token" ) ;
177168 None
178169 }
179170 }
0 commit comments