public OperatorServiceCollectionBuilder <TOperatorResource> Configure(Action <OperatorOptions> configureOptions) { var names = GroupApiVersionKind.From <TOperatorResource>(); _services = _services.Configure(names.PluralNameGroup, configureOptions); return(this); }
/// <summary> /// generate custom resource definition as an asynchronous operation. /// </summary> /// <typeparam name="TResource">The type of the resource to generate.</typeparam> /// <param name="scope">The scope indicates whether the defined custom resource is cluster- or namespace-scoped. Allowed values are `Cluster` and `Namespaced`.</param> /// <returns>The generated V1CustomResourceDefinition instance.</returns> public Task <V1CustomResourceDefinition> GenerateCustomResourceDefinitionAsync(Type resourceType, string scope, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); var names = GroupApiVersionKind.From(resourceType); var schema = GenerateJsonSchema(resourceType); return(Task.FromResult(new V1CustomResourceDefinition( apiVersion: $"{V1CustomResourceDefinition.KubeGroup}/{V1CustomResourceDefinition.KubeApiVersion}", kind: V1CustomResourceDefinition.KubeKind, metadata: new V1ObjectMeta( name: names.PluralNameGroup), spec: new V1CustomResourceDefinitionSpec( group: names.Group, names: new V1CustomResourceDefinitionNames( kind: names.Kind, plural: names.PluralName), scope: scope, versions: new List <V1CustomResourceDefinitionVersion> { new V1CustomResourceDefinitionVersion( name: names.ApiVersion, served: true, storage: true, schema: new V1CustomResourceValidation(schema)), })))); }
/// <summary> /// Initializes a new instance of the <see cref="ResourceInformer{TResource}" /> class. /// </summary> /// <param name="client">The client.</param> /// <param name="hostApplicationLifetime">The host application lifetime.</param> /// <param name="logger">The logger.</param> public ResourceInformer( IKubernetes client, IHostApplicationLifetime hostApplicationLifetime, ILogger <ResourceInformer <TResource> > logger) : base(hostApplicationLifetime, logger) { _client = client.AnyResourceKind(); _names = GroupApiVersionKind.From <TResource>(); }