kubernetes-fluent-client 3.0.4 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/e2e/cli.e2e.test.ts +11 -7
- package/package.json +6 -6
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -68
- package/dist/fetch.d.ts +0 -22
- package/dist/fetch.d.ts.map +0 -1
- package/dist/fetch.js +0 -82
- package/dist/fetch.test.d.ts +0 -2
- package/dist/fetch.test.d.ts.map +0 -1
- package/dist/fetch.test.js +0 -97
- package/dist/fileSystem.d.ts +0 -11
- package/dist/fileSystem.d.ts.map +0 -1
- package/dist/fileSystem.js +0 -42
- package/dist/fileSystem.test.d.ts +0 -2
- package/dist/fileSystem.test.d.ts.map +0 -1
- package/dist/fileSystem.test.js +0 -75
- package/dist/fluent/index.d.ts +0 -12
- package/dist/fluent/index.d.ts.map +0 -1
- package/dist/fluent/index.js +0 -228
- package/dist/fluent/index.test.d.ts +0 -2
- package/dist/fluent/index.test.d.ts.map +0 -1
- package/dist/fluent/index.test.js +0 -193
- package/dist/fluent/types.d.ts +0 -187
- package/dist/fluent/types.d.ts.map +0 -1
- package/dist/fluent/types.js +0 -16
- package/dist/fluent/utils.d.ts +0 -41
- package/dist/fluent/utils.d.ts.map +0 -1
- package/dist/fluent/utils.js +0 -153
- package/dist/fluent/utils.test.d.ts +0 -2
- package/dist/fluent/utils.test.d.ts.map +0 -1
- package/dist/fluent/utils.test.js +0 -215
- package/dist/fluent/watch.d.ts +0 -86
- package/dist/fluent/watch.d.ts.map +0 -1
- package/dist/fluent/watch.js +0 -425
- package/dist/fluent/watch.spec.d.ts +0 -2
- package/dist/fluent/watch.spec.d.ts.map +0 -1
- package/dist/fluent/watch.spec.js +0 -261
- package/dist/generate.d.ts +0 -84
- package/dist/generate.d.ts.map +0 -1
- package/dist/generate.js +0 -208
- package/dist/generate.test.d.ts +0 -2
- package/dist/generate.test.d.ts.map +0 -1
- package/dist/generate.test.js +0 -320
- package/dist/helpers.d.ts +0 -33
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js +0 -103
- package/dist/helpers.test.d.ts +0 -2
- package/dist/helpers.test.d.ts.map +0 -1
- package/dist/helpers.test.js +0 -37
- package/dist/index.d.ts +0 -14
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -60
- package/dist/kinds.d.ts +0 -16
- package/dist/kinds.d.ts.map +0 -1
- package/dist/kinds.js +0 -570
- package/dist/kinds.test.d.ts +0 -2
- package/dist/kinds.test.d.ts.map +0 -1
- package/dist/kinds.test.js +0 -155
- package/dist/patch.d.ts +0 -7
- package/dist/patch.d.ts.map +0 -1
- package/dist/patch.js +0 -2
- package/dist/postProcessing.d.ts +0 -246
- package/dist/postProcessing.d.ts.map +0 -1
- package/dist/postProcessing.js +0 -497
- package/dist/postProcessing.test.d.ts +0 -2
- package/dist/postProcessing.test.d.ts.map +0 -1
- package/dist/postProcessing.test.js +0 -550
- package/dist/types.d.ts +0 -32
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -16
- package/dist/upstream.d.ts +0 -4
- package/dist/upstream.d.ts.map +0 -1
- package/dist/upstream.js +0 -56
package/dist/helpers.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
// SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.fromEnv = fromEnv;
|
|
6
|
-
exports.waitForCluster = waitForCluster;
|
|
7
|
-
exports.hasLogs = hasLogs;
|
|
8
|
-
const client_node_1 = require("@kubernetes/client-node");
|
|
9
|
-
/**
|
|
10
|
-
* Sleep for a number of seconds.
|
|
11
|
-
*
|
|
12
|
-
* @param seconds The number of seconds to sleep.
|
|
13
|
-
* @returns A promise that resolves after the specified number of seconds.
|
|
14
|
-
*/
|
|
15
|
-
function sleep(seconds) {
|
|
16
|
-
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Get an environment variable (Node, Deno or Bun), or throw an error if it's not set.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* const value = fromEnv("MY_ENV_VAR");
|
|
23
|
-
* console.log(value);
|
|
24
|
-
* // => "my-value"
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* const value = fromEnv("MY_MISSING_ENV_VAR");
|
|
28
|
-
* // => Error: Environment variable MY_MISSING_ENV_VAR is not set
|
|
29
|
-
*
|
|
30
|
-
* @param name The name of the environment variable to get.
|
|
31
|
-
* @returns The value of the environment variable.
|
|
32
|
-
* @throws An error if the environment variable is not set.
|
|
33
|
-
*/
|
|
34
|
-
function fromEnv(name) {
|
|
35
|
-
let envValue;
|
|
36
|
-
// Check for Node.js or Bun
|
|
37
|
-
if (typeof process !== "undefined" && typeof process.env !== "undefined") {
|
|
38
|
-
envValue = process.env[name];
|
|
39
|
-
}
|
|
40
|
-
// Check for Deno
|
|
41
|
-
else if (typeof Deno !== "undefined") {
|
|
42
|
-
envValue = Deno.env.get(name);
|
|
43
|
-
}
|
|
44
|
-
// Otherwise, throw an error
|
|
45
|
-
else {
|
|
46
|
-
throw new Error("Unknown runtime environment");
|
|
47
|
-
}
|
|
48
|
-
if (typeof envValue === "undefined") {
|
|
49
|
-
throw new Error(`Environment variable ${name} is not set`);
|
|
50
|
-
}
|
|
51
|
-
return envValue;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Wait for the Kubernetes cluster to be ready.
|
|
55
|
-
*
|
|
56
|
-
* @param seconds The number of seconds to wait for the cluster to be ready.
|
|
57
|
-
* @returns The current cluster.
|
|
58
|
-
*/
|
|
59
|
-
async function waitForCluster(seconds = 30) {
|
|
60
|
-
const kubeConfig = new client_node_1.KubeConfig();
|
|
61
|
-
kubeConfig.loadFromDefault();
|
|
62
|
-
const cluster = kubeConfig.getCurrentCluster();
|
|
63
|
-
if (!cluster) {
|
|
64
|
-
await sleep(1);
|
|
65
|
-
if (seconds > 0) {
|
|
66
|
-
return await waitForCluster(seconds - 1);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
throw new Error("Cluster not ready");
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return cluster;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Determines if object has logs.
|
|
76
|
-
*
|
|
77
|
-
* @param kind The kind of Kubernetes object.
|
|
78
|
-
* @returns boolean.
|
|
79
|
-
*/
|
|
80
|
-
function hasLogs(kind) {
|
|
81
|
-
let hasSelector = false;
|
|
82
|
-
switch (kind) {
|
|
83
|
-
case "Pod":
|
|
84
|
-
hasSelector = true;
|
|
85
|
-
break;
|
|
86
|
-
case "DaemonSet":
|
|
87
|
-
hasSelector = true;
|
|
88
|
-
break;
|
|
89
|
-
case "ReplicaSet":
|
|
90
|
-
hasSelector = true;
|
|
91
|
-
break;
|
|
92
|
-
case "Service":
|
|
93
|
-
hasSelector = true;
|
|
94
|
-
break;
|
|
95
|
-
case "StatefulSet":
|
|
96
|
-
hasSelector = true;
|
|
97
|
-
break;
|
|
98
|
-
case "Deployment":
|
|
99
|
-
hasSelector = true;
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
return hasSelector;
|
|
103
|
-
}
|
package/dist/helpers.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.test.d.ts","sourceRoot":"","sources":["../src/helpers.test.ts"],"names":[],"mappings":""}
|
package/dist/helpers.test.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
// SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
const globals_1 = require("@jest/globals");
|
|
6
|
-
const helpers_1 = require("./helpers");
|
|
7
|
-
(0, globals_1.describe)("helpers", () => {
|
|
8
|
-
(0, globals_1.test)("fromEnv for NodeJS", () => {
|
|
9
|
-
(0, globals_1.expect)(() => {
|
|
10
|
-
(0, helpers_1.fromEnv)("MY_MISSING_ENV_VAR");
|
|
11
|
-
}).toThrowError("Environment variable MY_MISSING_ENV_VAR is not set");
|
|
12
|
-
process.env.MY_ENV_VAR = "my-value";
|
|
13
|
-
(0, globals_1.expect)((0, helpers_1.fromEnv)("MY_ENV_VAR")).toEqual("my-value");
|
|
14
|
-
delete process.env.MY_ENV_VAR;
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
(0, globals_1.describe)("Cluster Wait Function", () => {
|
|
18
|
-
(0, globals_1.it)("should resolve if the cluster is already ready", async () => {
|
|
19
|
-
const cluster = await (0, helpers_1.waitForCluster)(5);
|
|
20
|
-
(0, globals_1.expect)(cluster).toEqual({ server: "http://jest-test:8080" });
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
(0, globals_1.describe)("hasLogs function", () => {
|
|
24
|
-
(0, globals_1.it)("should return true for known kinds", () => {
|
|
25
|
-
(0, globals_1.expect)((0, helpers_1.hasLogs)("Pod")).toBe(true);
|
|
26
|
-
(0, globals_1.expect)((0, helpers_1.hasLogs)("DaemonSet")).toBe(true);
|
|
27
|
-
(0, globals_1.expect)((0, helpers_1.hasLogs)("ReplicaSet")).toBe(true);
|
|
28
|
-
(0, globals_1.expect)((0, helpers_1.hasLogs)("Service")).toBe(true);
|
|
29
|
-
(0, globals_1.expect)((0, helpers_1.hasLogs)("StatefulSet")).toBe(true);
|
|
30
|
-
(0, globals_1.expect)((0, helpers_1.hasLogs)("Deployment")).toBe(true);
|
|
31
|
-
});
|
|
32
|
-
(0, globals_1.it)("should return false for unknown kinds", () => {
|
|
33
|
-
(0, globals_1.expect)((0, helpers_1.hasLogs)("Unknown")).toBe(false);
|
|
34
|
-
(0, globals_1.expect)((0, helpers_1.hasLogs)("")).toBe(false);
|
|
35
|
-
(0, globals_1.expect)((0, helpers_1.hasLogs)("RandomKind")).toBe(false);
|
|
36
|
-
});
|
|
37
|
-
});
|
package/dist/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "./patch";
|
|
2
|
-
import * as kind from "./upstream";
|
|
3
|
-
/** kind is a collection of K8s types to be used within a K8s call: `K8s(kind.Secret).Apply({})`. */
|
|
4
|
-
export { kind };
|
|
5
|
-
export { fetch } from "./fetch";
|
|
6
|
-
export { StatusCodes as fetchStatus } from "http-status-codes";
|
|
7
|
-
export { WatchCfg, WatchEvent } from "./fluent/watch";
|
|
8
|
-
export { K8s } from "./fluent";
|
|
9
|
-
export { RegisterKind, modelToGroupVersionKind } from "./kinds";
|
|
10
|
-
export { GenericKind } from "./types";
|
|
11
|
-
export * from "./types";
|
|
12
|
-
export * as models from "@kubernetes/client-node/dist/gen/models/all";
|
|
13
|
-
export { fromEnv, waitForCluster } from "./helpers";
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,SAAS,CAAC;AAGjB,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AAEnC,oGAAoG;AACpG,OAAO,EAAE,IAAI,EAAE,CAAC;AAGhB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,OAAO,EAAE,WAAW,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG/D,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGtD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAG/B,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,cAAc,SAAS,CAAC;AAGxB,OAAO,KAAK,MAAM,MAAM,6CAA6C,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
// SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
|
|
4
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
-
if (k2 === undefined) k2 = k;
|
|
6
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
-
}
|
|
10
|
-
Object.defineProperty(o, k2, desc);
|
|
11
|
-
}) : (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
o[k2] = m[k];
|
|
14
|
-
}));
|
|
15
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
-
}) : function(o, v) {
|
|
18
|
-
o["default"] = v;
|
|
19
|
-
});
|
|
20
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
-
if (mod && mod.__esModule) return mod;
|
|
22
|
-
var result = {};
|
|
23
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
-
__setModuleDefault(result, mod);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
28
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
29
|
-
};
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.waitForCluster = exports.fromEnv = exports.models = exports.GenericKind = exports.modelToGroupVersionKind = exports.RegisterKind = exports.K8s = exports.WatchEvent = exports.fetchStatus = exports.kind = void 0;
|
|
32
|
-
require("./patch");
|
|
33
|
-
// Export kinds as a single object
|
|
34
|
-
const kind = __importStar(require("./upstream"));
|
|
35
|
-
exports.kind = kind;
|
|
36
|
-
// Export the node-fetch wrapper
|
|
37
|
-
var fetch_1 = require("./fetch");
|
|
38
|
-
Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return fetch_1.fetch; } });
|
|
39
|
-
// Export the HTTP status codes
|
|
40
|
-
var http_status_codes_1 = require("http-status-codes");
|
|
41
|
-
Object.defineProperty(exports, "fetchStatus", { enumerable: true, get: function () { return http_status_codes_1.StatusCodes; } });
|
|
42
|
-
// Export the Watch Config and Event types
|
|
43
|
-
var watch_1 = require("./fluent/watch");
|
|
44
|
-
Object.defineProperty(exports, "WatchEvent", { enumerable: true, get: function () { return watch_1.WatchEvent; } });
|
|
45
|
-
// Export the fluent API entrypoint
|
|
46
|
-
var fluent_1 = require("./fluent");
|
|
47
|
-
Object.defineProperty(exports, "K8s", { enumerable: true, get: function () { return fluent_1.K8s; } });
|
|
48
|
-
// Export helpers for working with K8s types
|
|
49
|
-
var kinds_1 = require("./kinds");
|
|
50
|
-
Object.defineProperty(exports, "RegisterKind", { enumerable: true, get: function () { return kinds_1.RegisterKind; } });
|
|
51
|
-
Object.defineProperty(exports, "modelToGroupVersionKind", { enumerable: true, get: function () { return kinds_1.modelToGroupVersionKind; } });
|
|
52
|
-
// Export the GenericKind interface for CRD registration
|
|
53
|
-
var types_1 = require("./types");
|
|
54
|
-
Object.defineProperty(exports, "GenericKind", { enumerable: true, get: function () { return types_1.GenericKind; } });
|
|
55
|
-
__exportStar(require("./types"), exports);
|
|
56
|
-
// Export the upstream raw models
|
|
57
|
-
exports.models = __importStar(require("@kubernetes/client-node/dist/gen/models/all"));
|
|
58
|
-
var helpers_1 = require("./helpers");
|
|
59
|
-
Object.defineProperty(exports, "fromEnv", { enumerable: true, get: function () { return helpers_1.fromEnv; } });
|
|
60
|
-
Object.defineProperty(exports, "waitForCluster", { enumerable: true, get: function () { return helpers_1.waitForCluster; } });
|
package/dist/kinds.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { GenericClass, GroupVersionKind } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Converts a model name to a GroupVersionKind
|
|
4
|
-
*
|
|
5
|
-
* @param key The name of the model
|
|
6
|
-
* @returns The GroupVersionKind for the model
|
|
7
|
-
*/
|
|
8
|
-
export declare function modelToGroupVersionKind(key: string): GroupVersionKind;
|
|
9
|
-
/**
|
|
10
|
-
* Registers a new model and GroupVersionKind to be used within the fluent API.
|
|
11
|
-
*
|
|
12
|
-
* @param model Used to match the GroupVersionKind and define the type-data for the request
|
|
13
|
-
* @param groupVersionKind Contains the match parameters to determine the request should be handled
|
|
14
|
-
*/
|
|
15
|
-
export declare const RegisterKind: (model: GenericClass, groupVersionKind: GroupVersionKind) => void;
|
|
16
|
-
//# sourceMappingURL=kinds.d.ts.map
|
package/dist/kinds.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../src/kinds.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAqkBzD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAErE;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAAW,YAAY,oBAAoB,gBAAgB,SAUnF,CAAC"}
|