export async function getKubectlPath()

in src/kubectl-util.ts [38:74]


export async function getKubectlPath() {
   let kubectlPath = ''
   const version = core.getInput('kubectl-version', {required: false})
   if (version) {
      if (!!version && version != LATEST) {
         const cachedToolPath = toolCache.find(kubectlToolName, version)
         kubectlPath = path.join(
            cachedToolPath,
            kubectlToolName + getExecutableExtension()
         )
      }

      if (!kubectlPath) {
         kubectlPath = await installKubectl(version)
      }
   } else {
      kubectlPath = await io.which(kubectlToolName, false)
      if (!kubectlPath) {
         const allVersions = toolCache.findAllVersions(kubectlToolName)
         kubectlPath =
            allVersions.length > 0
               ? toolCache.find(kubectlToolName, allVersions[0])
               : ''
         if (!kubectlPath) {
            throw new Error(
               'Kubectl is not installed, either add install-kubectl action or provide "kubectl-version" input to download kubectl'
            )
         }
         kubectlPath = path.join(
            kubectlPath,
            `kubectl${getExecutableExtension()}`
         )
      }
   }

   return kubectlPath
}