/******************************************************************************* * Copyright (c) 2021. Rex Isaac Raphael * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files * (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * File name: kubernetes-config.source.ts * Last modified: 28/03/2021, 17:35 ******************************************************************************/ import { OnModuleInit } from '@nestjs/common'; import { BaseConfigOptions, ConfigSource, IConfigSource, IConfigStore } from '@ultimate-backend/common'; import * as k8s from '@kubernetes/client-node'; import { KubernetesClient } from '../kubernetes.client'; export interface KubernetesConfigOptions extends BaseConfigOptions { source: ConfigSource.Kubernetes; key: string; name: string; namespace?: string; } /** * This is a client implementation of config for ETCD * @packageDocumentation */ export declare class KubernetesConfigSource implements IConfigSource, OnModuleInit { private readonly kubernetes; private readonly options; private readonly store; private watchers; private logger; private defaultNamespace; constructor(kubernetes: KubernetesClient, options: any, store: IConfigStore); onModuleInit(): Promise; /** * get config by path. Supports dot notation for example (name.firstname) * @param path * @param defaultValue * @typeParam T Return type `T` * @return T It returns a `Promise` or just `T` * * @example * ```typescript * const config = EtcdConfigSource(...); * config.get('name.firstname', 'Johny); * ``` */ get(path: string, defaultValue: T): Promise | T | undefined; get(path: string): Promise | T | undefined; set(path: string, value: any): Promise; private watchAllConfigs; watchK8s(name: string, key: string, namespace: string, callback: (value: T) => void): Promise; private addToStore; watch(name: string, callback: (value: T) => void): Promise; }