public static KubeConfig loadKubeConfig ( Reader input ) { Yaml yaml = new Yaml ( new SafeConstructor ( ) ) ; Object config = yaml . load ( input ) ; Map < String , Object > configMap = ( Map < String , Object > ) config ; String currentContext = ( String ) configMap . get ( "current-context" ) ; ArrayList < Object > contexts = ( ArrayList < Object > ) configMap . get ( "contexts" ) ; ArrayList < Object > clusters = ( ArrayList < Object > ) configMap . get ( "clusters" ) ; ArrayList < Object > users = ( ArrayList < Object > ) configMap . get ( "users" ) ; Object preferences = configMap . get ( "preferences" ) ; KubeConfig kubeConfig = new KubeConfig ( contexts , clusters , users ) ; kubeConfig . setContext ( currentContext ) ; kubeConfig . setPreferences ( preferences ) ; return kubeConfig ; }
Load a Kubernetes config from a Reader