@c6o/kubeclient-contracts
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -6,2 +6,23 @@ # Change Log | ||
## [0.0.8](https://github.com/c6o/kubeclient/compare/v0.0.7...v0.0.8) (2021-02-02) | ||
### ✨ Features | ||
* Added impersonation to get and create requests ([#16](https://github.com/c6o/kubeclient/issues/16)) ([18e7a9c](https://github.com/c6o/kubeclient/commit/18e7a9c79b9a9d48740495b15015433c5cba4902)) | ||
### 📦 Code Refactoring | ||
* Split kubeclient into client and contracts ([#13](https://github.com/c6o/kubeclient/issues/13)) ([fa40762](https://github.com/c6o/kubeclient/commit/fa4076238edc8239be05b344f6b4f459e348bcbe)) | ||
### ♻️ Chores | ||
* Implemented mergeDocument on crud ([#15](https://github.com/c6o/kubeclient/issues/15)) ([b2737b8](https://github.com/c6o/kubeclient/commit/b2737b8fcddff1597d0ec7d10a0ef68768c693e3)) | ||
## [0.0.7](https://github.com/c6o/kubeclient/compare/v0.0.6...v0.0.7) (2021-01-01) | ||
@@ -8,0 +29,0 @@ |
/// <reference types="node" /> | ||
import { KubeObject, KubeDocument, KubeObjectAddress } from './kubeObject'; | ||
import { KubeDocument, KubeObjectAddress } from './kubeObject'; | ||
import { Result } from './result'; | ||
@@ -15,5 +15,11 @@ import { Processor } from './processor'; | ||
} | ||
export interface readOptions { | ||
impersonate?: string; | ||
} | ||
export interface putOptions { | ||
subResource?: string; | ||
} | ||
export interface createOptions { | ||
impersonate?: string; | ||
} | ||
export interface Cluster { | ||
@@ -25,6 +31,6 @@ begin(stageName?: string): Processor; | ||
list(document: KubeDocument, options?: listOptions): Promise<Result>; | ||
read(document: KubeDocument): Promise<Result>; | ||
create(document: KubeDocument, owners?: Array<KubeDocument>): Promise<Result>; | ||
read(document: KubeDocument, options?: readOptions): Promise<Result>; | ||
create(document: KubeDocument, owners?: Array<KubeDocument>, options?: createOptions): Promise<Result>; | ||
put(document: KubeDocument, newDoc: KubeDocument, params?: putOptions): Promise<Result>; | ||
patch(document: KubeDocument, patch: Partial<KubeObject>): Promise<Result>; | ||
patch(document: KubeDocument, patch: Partial<KubeDocument>): Promise<Result>; | ||
delete(document: KubeDocument): Promise<Result>; | ||
@@ -31,0 +37,0 @@ upsert(document: KubeDocument, owners?: Array<KubeDocument>): Promise<Result>; |
@@ -1,8 +0,11 @@ | ||
export declare class Metadata { | ||
export declare type keyValue = { | ||
[key: string]: string; | ||
}; | ||
export declare class Metadata<L extends keyValue = keyValue, A extends keyValue = keyValue> { | ||
namespace?: string; | ||
name?: string; | ||
resourceVersion?: string; | ||
labels?: any; | ||
annotations?: any; | ||
deletionTimestamp?: string; | ||
labels?: L; | ||
annotations?: A; | ||
deletionTimestamp?: string | Date; | ||
finalizers?: string[]; | ||
@@ -17,8 +20,7 @@ uid?: string; | ||
} | ||
export declare type KubeDocument = Pick<KubeObject, 'apiVersion' | 'kind' | 'metadata' | 'spec' | 'items' | 'status' | 'data'>; | ||
export declare class KubeObject implements KubeDocument { | ||
export interface KubeDocument<L extends keyValue = keyValue, A extends keyValue = keyValue, S = any> { | ||
apiVersion?: string; | ||
kind?: string; | ||
metadata?: Metadata; | ||
spec?: any; | ||
metadata?: Metadata<L, A>; | ||
spec?: S; | ||
data?: any; | ||
@@ -28,6 +30,7 @@ status?: any; | ||
[key: string]: any; | ||
get toDocument(): KubeDocument; | ||
static ensureInstance(fields?: KubeDocument): KubeObject; | ||
constructor(fields?: KubeDocument); | ||
} | ||
export declare class KubeObject<T extends KubeDocument = KubeDocument> { | ||
document?: T; | ||
constructor(document?: T); | ||
toString(): string; | ||
} |
@@ -11,30 +11,12 @@ "use strict"; | ||
class KubeObject { | ||
constructor(fields) { | ||
if (fields) | ||
Object.assign(this, fields); | ||
if (!this.apiVersion) | ||
this.apiVersion = 'v1'; | ||
if (!this.metadata) | ||
this.metadata = new Metadata(); | ||
constructor(document) { | ||
this.document = document; | ||
this.document.apiVersion = this.document.apiVersion || 'v1'; | ||
this.document.metadata = this.document.metadata || new Metadata(); | ||
} | ||
get toDocument() { | ||
return { | ||
apiVersion: this.apiVersion, | ||
kind: this.kind, | ||
metadata: this.metadata, | ||
spec: this.spec, | ||
items: this.items | ||
}; | ||
} | ||
static ensureInstance(fields) { | ||
if (fields instanceof KubeObject) { | ||
return fields; | ||
} | ||
return new KubeObject(fields); | ||
} | ||
toString() { | ||
var _a, _b, _c; | ||
return ((_a = this.metadata) === null || _a === void 0 ? void 0 : _a.namespace) ? | ||
`${this.kind} ${((_b = this.metadata) === null || _b === void 0 ? void 0 : _b.name) || ''} in namespace ${this.metadata.namespace}` : | ||
`${this.kind} ${((_c = this.metadata) === null || _c === void 0 ? void 0 : _c.name) || ''}`; | ||
return ((_a = this.document.metadata) === null || _a === void 0 ? void 0 : _a.namespace) ? | ||
`${this.document.kind} ${((_b = this.document.metadata) === null || _b === void 0 ? void 0 : _b.name) || ''} in namespace ${this.document.metadata.namespace}` : | ||
`${this.document.kind} ${((_c = this.document.metadata) === null || _c === void 0 ? void 0 : _c.name) || ''}`; | ||
} | ||
@@ -41,0 +23,0 @@ } |
@@ -18,2 +18,5 @@ /// <reference types="node" /> | ||
clearOwners(): this; | ||
mergeDocument: KubeDocument; | ||
mergeWith(document: KubeDocument): this; | ||
clearMergeWith(): this; | ||
list(object: KubeDocument): this; | ||
@@ -20,0 +23,0 @@ read(object: KubeDocument): this; |
@@ -1,4 +0,4 @@ | ||
import { KubeObject } from './kubeObject'; | ||
import { KubeDocument } from './kubeObject'; | ||
export declare class Result { | ||
object: KubeObject; | ||
object: KubeDocument; | ||
suppress: boolean; | ||
@@ -5,0 +5,0 @@ error: any; |
@@ -5,3 +5,2 @@ "use strict"; | ||
const ts_try_1 = require("ts-try"); | ||
const kubeObject_1 = require("./kubeObject"); | ||
class Result { | ||
@@ -16,3 +15,3 @@ constructor(result) { | ||
if (result.kind) | ||
this.object = kubeObject_1.KubeObject.ensureInstance(result); | ||
this.object = result; | ||
else | ||
@@ -19,0 +18,0 @@ this.other = result; |
export declare type itemType = Stage | Event; | ||
export declare type metaType = { | ||
[key: string]: string; | ||
}; | ||
export declare class Event { | ||
@@ -22,2 +25,3 @@ is: string; | ||
name: string; | ||
meta: metaType; | ||
startTime: Date; | ||
@@ -41,3 +45,3 @@ endTime: Date; | ||
end(): void; | ||
push(stageName: any): void; | ||
push(stageName: string, stageIdOrMeta?: string | metaType, meta?: metaType): void; | ||
pop(skipped?: boolean): void; | ||
@@ -44,0 +48,0 @@ info(message: any, ...args: any[]): void; |
@@ -53,6 +53,11 @@ "use strict"; | ||
} | ||
push(stageName) { | ||
push(stageName, stageIdOrMeta, meta = undefined) { | ||
if (typeof stageIdOrMeta === 'object') | ||
meta = stageIdOrMeta; | ||
else if (stageIdOrMeta && this.findStage(stageIdOrMeta)) | ||
throw new Error(`Stage Id ${stageIdOrMeta} already exists`); | ||
const stage = this.newStage(); | ||
stage.id = ulid_1.ulid(); | ||
stage.id = stageIdOrMeta || ulid_1.ulid(); | ||
stage.name = stageName; | ||
stage.meta = meta; | ||
this.addStage(stage); | ||
@@ -59,0 +64,0 @@ if (this.condition !== 'running') |
{ | ||
"name": "@c6o/kubeclient-contracts", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "A simple Kubernetes client", | ||
@@ -48,3 +48,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "9376da24c0fb65d88dadb614a6dcaa23d200d0cb" | ||
"gitHead": "80a6a3be20a5a5b191fdda217740d77876ef848f" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
28339
37
472