Skip to content

Conversation

@billpratt
Copy link
Contributor

Addressed #120

@brendanburns With this PR I also refactored to use the YAML helper methods you added recently.

@billpratt billpratt changed the title Made LoadKubeConfig public and refactored to use YAML helper methods Make LoadKubeConfig public and refactor to use YAML helper methods Apr 2, 2018
/// Gets or sets the path to a cert file for the certificate authority.
/// </summary>
[YamlMember(Alias = "certificate-authority")]
[YamlMember(Alias = "certificate-authority", ApplyNamingConventions = false)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ApplyNamingConventions = false is need when using naming conventions like CamelCaseNamingConvention

/// <param name="kubeconfig">String representation of kubeconfig contents, cannot be null, whitespaced or empty</param>
/// <param name="currentContext">override the context in config file, set null if do not want to override</param>
/// <param name="masterUrl">overrider kube api server endpoint, set null if do not want to override</param>
public static KubernetesClientConfiguration BuildConfigFromConfigFile(string kubeconfig,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find any references to this method. Can we deprecate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, seems reasonable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mark as [Obsolete] or remove?

/// <param name="kubeconfig">Kube config file contents</param>
/// <returns>Instance of the <see cref="K8SConfiguration"/> class</returns>
private static K8SConfiguration LoadKubeConfig(Stream kubeconfig)
public static K8SConfiguration LoadKubeConfig(FileInfo kubeconfig)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this as a stream, since we want to support loading from network streams as well as files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I'll add it back in and use Yaml.LoadFromStreamAsync. Should we keep the method with FileInfo kubeconfig?

Essentially, we would have these method signatures.

public static async Task<K8SConfiguration> LoadKubeConfigAsync(string kubeconfigPath = null) public static K8SConfiguration LoadKubeConfig(string kubeconfigPath = null) public static async Task<K8SConfiguration> LoadKubeConfigAsync(FileInfo kubeconfig) public static K8SConfiguration LoadKubeConfig(FileInfo kubeconfig) public static async Task<K8SConfiguration> LoadKubeConfigAsync(Stream kubeconfigStream) public static K8SConfiguration LoadKubeConfig(Stream kubeconfigStream) 
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your call about FileInfo. it's easy enough to turn a file name into a Stream

ConfigsEqual(expectedCfg, cfg);
}

private void ConfigsEqual(K8SConfiguration expected, K8SConfiguration actual)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is too long, I think. Factor it so there is an

assertContextEqual(...)

assertUserEqual(...)

assertClusterEqual(...)

set of methods and refactor the for loops to just call those methods?

@brendandburns
Copy link
Contributor

A few small comments, but basically LGTM.

@brendandburns
Copy link
Contributor

We just merged a file move in #134 you'll need to rebase (but it should "just work")

@billpratt
Copy link
Contributor Author

@brendanburns I believe I've addressed everything.

@brendandburns
Copy link
Contributor

LGTM, thanks!

@brendandburns brendandburns merged commit df4d5dc into kubernetes-client:master Apr 19, 2018
JonJam pushed a commit to JonJam/csharp that referenced this pull request Sep 8, 2018
…ubernetes-client#133) * Made LoadKubeConfig public and refactored to use YAML helper methods * Addressing Code review feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants