/// <summary> /// Returns the <seealso cref="KubectlContext"/> instance to use for the given <paramref name="cluster"/> when /// performing Kubernetes operations. /// </summary> /// <param name="cluster">The name of the cluster for which to create credentials.</param> /// <param name="zone">The zone of the cluster.</param> /// <returns>The <seealso cref="KubectlContext"/> for the given <paramref name="cluster"/>.</returns> /// <remarks> /// Do not use this method directly. /// Use <see cref="IKubectlContextProvider.GetKubectlContextForClusterAsync"/>. /// </remarks> internal static async Task <KubectlContext> GetForClusterAsync(string cluster, string zone) { var kubctlContext = new KubectlContext(); if (!await kubctlContext.InitClusterCredentialsAsync(cluster, zone)) { throw new GCloudException($"Failed to get credentials for cluster {cluster}"); } return(kubctlContext); }
/// <summary> /// Returns the <seealso cref="KubectlContext"/> instance to use for the given <paramref name="cluster"/> when /// performing Kubernetes operations. /// </summary> /// <param name="cluster">The cluster to create credentials for.</param> /// <returns>The <seealso cref="KubectlContext"/> for the given <paramref name="cluster"/>.</returns> public async Task <IKubectlContext> GetKubectlContextForClusterAsync(Cluster cluster) { var kubectlContext = new KubectlContext(FileSystem, _processService, CredentialsStore); if (!await kubectlContext.InitClusterCredentialsAsync(cluster)) { throw new GCloudException($"Failed to get credentials for cluster {cluster.Name}"); } return(kubectlContext); }