import * as core from "@actions/core" ; import * as fs from "fs" ; import { KubeConfig } from "@kubernetes/client-node" ; import { getDefaultKubeconfig } from "./kubeconfigs/default" ; import { getArcKubeconfig } from "./kubeconfigs/arc" ; import { Cluster } from "./types/cluster" ; param type returns export async function getKubeconfig ( type ) { switch ( type ) { case Cluster . ARC : { return await getArcKubeconfig ( ) ; } case undefined : { core . warning ( "Cluster type not recognized. Defaulting to generic." ) ; } default : { return getDefaultKubeconfig ( ) ; } } } param kubeconfig returns export function setContext ( kubeconfig ) { const context = core . getInput ( "context" ) ; if ( ! context ) { core . debug ( "Can't set context because context is unspecified." ) ; return kubeconfig ; } const kc = new KubeConfig ( ) ; kc . loadFromString ( kubeconfig ) ; kc . setCurrentContext ( context ) ; return kc . exportConfig ( ) ; }