com.avito.k8s.CustomGCPAuthenticator.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kubernetes Show documentation
Show all versions of kubernetes Show documentation
Collection of infrastructure libraries and gradle plugins of Avito Android project
package com.avito.k8s
import com.google.auth.oauth2.GoogleCredentials
import io.kubernetes.client.util.authenticators.GCPAuthenticator
/**
* Default [GCPAuthenticator] doesn't able to refresh token
* https://github.com/kubernetes-client/java/issues/290#issuecomment-480205118
*/
internal class CustomGCPAuthenticator : GCPAuthenticator() {
private val credentials: GoogleCredentials by lazy { GoogleCredentials.getApplicationDefault() }
override fun refresh(config: MutableMap): MutableMap {
val accessToken = credentials.refreshAccessToken()
config["access-token"] = accessToken.tokenValue
config["expiry"] = accessToken.expirationTime
return config
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy