All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.avito.k8s.CustomGCPAuthenticator.kt Maven / Gradle / Ivy

Go to download

Collection of infrastructure libraries and gradle plugins of Avito Android project

There is a newer version: 2023.22
Show newest version
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