/// <summary> /// Add a <see cref="KubeApiClient"/> to the service collection. /// </summary> /// <param name="services"> /// The service collection to configure. /// </param> /// <param name="options"> /// <see cref="KubeClientOptions"/> containing the client configuration to use. /// </param> public static void AddKubeClient(this IServiceCollection services, KubeClientOptions options) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } options.EnsureValid(); KubeApiClient ResolveWithOptions(IServiceProvider serviceProvider) { return(KubeApiClient.Create(options, loggerFactory: serviceProvider.GetService <ILoggerFactory>() )); } services.AddScoped <KubeApiClient>(ResolveWithOptions); services.AddScoped <IKubeApiClient>(ResolveWithOptions); }
/// <summary> /// Get the Kubernetes CustomResourceDefinitions (v1beta1) resource client. /// </summary> /// <param name="kubeClient"> /// The Kubernetes API client. /// </param> /// <returns> /// The resource client. /// </returns> public static CustomResourceDefinitionClientV1Beta1 CustomResourceDefinitionsV1Beta1(this KubeApiClient kubeClient) { if (kubeClient == null) { throw new ArgumentNullException(nameof(kubeClient)); } return(kubeClient.ResourceClient( client => new CustomResourceDefinitionClientV1Beta1(client) )); }