Created
August 7, 2021 19:34
-
-
Save haodemon/5490fefdb258275c1f805d584319090b to your computer and use it in GitHub Desktop.
GKE Google Kubernetes fabric8 OAuthTokenProvider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.fabric8.kubernetes.client.OAuthTokenProvider; | |
class OAuthGoogleTokenProvider extends OAuthTokenProvider { | |
private val binary = "gcloud" | |
private val args = "config config-helper --format=json" | |
override def getToken: String = { | |
val response = (binary + " " + args).!! | |
val token = new ObjectMapper().readTree(response) | |
.get("credential") | |
.get("access_token") | |
token.getTextValue | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment