kubernetes-fluent-client 2.6.1 → 2.6.3

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/README.md CHANGED
@@ -7,6 +7,12 @@
7
7
 
8
8
  The Kubernetes Fluent Client for Node is a fluent API for the [Kubernetes JavaScript Client](https://github.com/kubernetes-client/javascript) with some additional logic for [Server Side Apply](https://kubernetes.io/docs/reference/using-api/server-side-apply/), [Watch](https://kubernetes.io/docs/reference/using-api/api-concepts/#efficient-detection-of-changes) with retry/signal control, and [Field Selectors](https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/). In addition to providing a human-friendly API, it also provides a simple way to create and manage resources in the cluster and integrate with K8s in a type-safe way.
9
9
 
10
+ To install the Kubernetes Fluent Client, run the following command:
11
+
12
+ ```bash
13
+ npm install kubernetes-fluent-client
14
+ ```
15
+
10
16
  See below for some example uses of the library.
11
17
 
12
18
  ```typescript
@@ -98,3 +104,7 @@ Promise.all([
98
104
  console.error(err);
99
105
  });
100
106
  ```
107
+
108
+ ### Community
109
+
110
+ To chat with other users & see some examples of the fluent client in active use, go to [Kubernetes Slack](https://communityinviter.com/apps/kubernetes/community) and join `#pepr` channel.
package/dist/fetch.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { RequestInfo, RequestInit } from "node-fetch";
3
2
  export type FetchResponse<T> = {
4
3
  data: T;
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":";AAIA,OAAiB,EAAc,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE5E,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;IAC7B,IAAI,EAAE,CAAC,CAAC;IACR,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAsB,KAAK,CAAC,CAAC,EAC3B,GAAG,EAAE,GAAG,GAAG,WAAW,EACtB,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAwC3B"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAIA,OAAiB,EAAc,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE5E,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;IAC7B,IAAI,EAAE,CAAC,CAAC;IACR,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAsB,KAAK,CAAC,CAAC,EAC3B,GAAG,EAAE,GAAG,GAAG,WAAW,EACtB,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAwC3B"}
package/dist/fetch.js CHANGED
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  return result;
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.fetch = void 0;
28
+ exports.fetch = fetch;
29
29
  const http_status_codes_1 = require("http-status-codes");
30
30
  const node_fetch_1 = __importStar(require("node-fetch"));
31
31
  /**
@@ -80,4 +80,3 @@ async function fetch(url, init) {
80
80
  };
81
81
  }
82
82
  }
83
- exports.fetch = fetch;
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.K8s = void 0;
5
+ exports.K8s = K8s;
6
6
  const http_status_codes_1 = require("http-status-codes");
7
7
  const fetch_1 = require("../fetch");
8
8
  const kinds_1 = require("../kinds");
@@ -117,7 +117,7 @@ function K8s(model, filters = {}) {
117
117
  }
118
118
  }
119
119
  catch (e) {
120
- throw new Error(e);
120
+ throw new Error(`Failed to get logs in KFC Logs function`);
121
121
  }
122
122
  const podModel = { ...model, name: "V1Pod" };
123
123
  const logPromises = podList.map(po => (0, utils_1.k8sExec)(podModel, { ...filters, name: po.metadata.name }, "LOG"));
@@ -226,4 +226,3 @@ function K8s(model, filters = {}) {
226
226
  }
227
227
  return { InNamespace, Apply, Create, Patch, PatchStatus, Raw, ...withFilters };
228
228
  }
229
- exports.K8s = K8s;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { URL } from "url";
3
2
  import { GenericClass } from "../types";
4
3
  import { ApplyCfg, FetchMethods, Filters } from "./types";
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/fluent/utils.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAI1B,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAI1D;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,YAAY,EAChD,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,OAAO,EAChB,WAAW,UAAQ,OAwDpB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,MAAM,CAAC,MAAM,EAAE,YAAY;;;GAwBhD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,OAAO,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,EACrD,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,EACrB,QAAQ,GAAE,QAA2B,cAwDtC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/fluent/utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAI1B,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAI1D;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,YAAY,EAChD,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,OAAO,EAChB,WAAW,UAAQ,OAwDpB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,MAAM,CAAC,MAAM,EAAE,YAAY;;;GAwBhD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,OAAO,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,EACrD,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,EACrB,QAAQ,GAAE,QAA2B,cAwDtC"}
@@ -2,7 +2,9 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.k8sExec = exports.k8sCfg = exports.pathBuilder = void 0;
5
+ exports.pathBuilder = pathBuilder;
6
+ exports.k8sCfg = k8sCfg;
7
+ exports.k8sExec = k8sExec;
6
8
  const client_node_1 = require("@kubernetes/client-node");
7
9
  const url_1 = require("url");
8
10
  const fetch_1 = require("../fetch");
@@ -59,7 +61,6 @@ function pathBuilder(serverUrl, model, filters, excludeName = false) {
59
61
  }
60
62
  return url;
61
63
  }
62
- exports.pathBuilder = pathBuilder;
63
64
  /**
64
65
  * Sets up the kubeconfig and https agent for a request
65
66
  *
@@ -92,7 +93,6 @@ async function k8sCfg(method) {
92
93
  opts.compress = true;
93
94
  return { opts, serverUrl: cluster.server };
94
95
  }
95
- exports.k8sCfg = k8sCfg;
96
96
  /**
97
97
  * Execute a request against the Kubernetes API server.
98
98
  *
@@ -151,4 +151,3 @@ async function k8sExec(model, filters, method, payload, applyCfg = { force: fals
151
151
  }
152
152
  throw resp;
153
153
  }
154
- exports.k8sExec = k8sExec;
@@ -1,6 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
1
  import { EventEmitter } from "events";
5
2
  import { GenericClass } from "../types";
6
3
  import { Filters, WatchAction } from "./types";
@@ -1 +1 @@
1
- {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/fluent/watch.ts"],"names":[],"mappings":";;;AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAItC,OAAO,EAAE,YAAY,EAAwB,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,WAAW,EAAc,MAAM,SAAS,CAAC;AAG3D,oBAAY,UAAU;IACpB,sCAAsC;IACtC,OAAO,YAAY;IACnB,2BAA2B;IAC3B,aAAa,kBAAkB;IAC/B,kDAAkD;IAClD,UAAU,eAAe;IACzB,0BAA0B;IAC1B,SAAS,cAAc;IACvB,8BAA8B;IAC9B,OAAO,YAAY;IACnB,sBAAsB;IACtB,KAAK,UAAU;IACf,mCAAmC;IACnC,IAAI,SAAS;IACb,wCAAwC;IACxC,oBAAoB,yBAAyB;IAC7C,qCAAqC;IACrC,iBAAiB,sBAAsB;IACvC,kCAAkC;IAClC,IAAI,SAAS;IACb,2BAA2B;IAC3B,UAAU,eAAe;CAC1B;AAED,4CAA4C;AAC5C,MAAM,MAAM,QAAQ,GAAG;IACrB,+HAA+H;IAC/H,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+FAA+F;IAC/F,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0GAA0G;IAC1G,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC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FAA+F;IAC/F,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0GAA0G;IAC1G,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAKF,iDAAiD;AACjD,qBAAa,OAAO,CAAC,CAAC,SAAS,YAAY;;IAwBzC,YAAY,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;IAc9B;;;;;;;;;;;OAWG;gBACS,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,GAAE,QAAa;IAgCzF;;;;OAIG;IACU,KAAK,IAAI,OAAO,CAAC,eAAe,CAAC;IAK9C,gGAAgG;IACzF,KAAK;IAOZ;;;;;OAKG;IACI,UAAU;IAWjB;;;;;;OAMG;IACH,IAAW,MAAM,IAAI,YAAY,CAEhC;CAyTF"}
package/dist/generate.js CHANGED
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  return result;
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.generate = void 0;
28
+ exports.generate = generate;
29
29
  const client_node_1 = require("@kubernetes/client-node");
30
30
  const fs = __importStar(require("fs"));
31
31
  const path = __importStar(require("path"));
@@ -153,7 +153,7 @@ async function readOrFetchCrd(opts) {
153
153
  catch (e) {
154
154
  // If invalid, ignore the error
155
155
  if (e.code !== "ERR_INVALID_URL") {
156
- throw new Error(e);
156
+ throw new Error(`Error parsing URL ${source}`);
157
157
  }
158
158
  }
159
159
  // Finally, if the source is not a file or URL, try to read it as a CustomResourceDefinition from the cluster
@@ -193,4 +193,3 @@ async function generate(opts) {
193
193
  }
194
194
  return results;
195
195
  }
196
- exports.generate = generate;
package/dist/helpers.js CHANGED
@@ -2,7 +2,9 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.hasLogs = exports.waitForCluster = exports.fromEnv = void 0;
5
+ exports.fromEnv = fromEnv;
6
+ exports.waitForCluster = waitForCluster;
7
+ exports.hasLogs = hasLogs;
6
8
  const client_node_1 = require("@kubernetes/client-node");
7
9
  /**
8
10
  * Sleep for a number of seconds.
@@ -48,7 +50,6 @@ function fromEnv(name) {
48
50
  }
49
51
  return envValue;
50
52
  }
51
- exports.fromEnv = fromEnv;
52
53
  /**
53
54
  * Wait for the Kubernetes cluster to be ready.
54
55
  *
@@ -70,7 +71,6 @@ async function waitForCluster(seconds = 30) {
70
71
  }
71
72
  return cluster;
72
73
  }
73
- exports.waitForCluster = waitForCluster;
74
74
  /**
75
75
  * Determines if object has logs.
76
76
  *
@@ -101,4 +101,3 @@ function hasLogs(kind) {
101
101
  }
102
102
  return hasSelector;
103
103
  }
104
- exports.hasLogs = hasLogs;
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
28
28
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
29
29
  };
30
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.fetch = exports.kind = void 0;
31
+ exports.waitForCluster = exports.fromEnv = exports.models = exports.GenericKind = exports.modelToGroupVersionKind = exports.RegisterKind = exports.K8s = exports.WatchEvent = exports.fetchStatus = exports.kind = void 0;
32
32
  require("./patch");
33
33
  // Export kinds as a single object
34
34
  const kind = __importStar(require("./upstream"));
package/dist/kinds.js CHANGED
@@ -2,7 +2,8 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.RegisterKind = exports.modelToGroupVersionKind = void 0;
5
+ exports.RegisterKind = void 0;
6
+ exports.modelToGroupVersionKind = modelToGroupVersionKind;
6
7
  const gvkMap = {
7
8
  /**
8
9
  * Represents a K8s Event resource (new Event in the events.k8s.io API)
@@ -551,7 +552,6 @@ const gvkMap = {
551
552
  function modelToGroupVersionKind(key) {
552
553
  return gvkMap[key];
553
554
  }
554
- exports.modelToGroupVersionKind = modelToGroupVersionKind;
555
555
  /**
556
556
  * Registers a new model and GroupVersionKind to be used within the fluent API.
557
557
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kubernetes-fluent-client",
3
- "version": "2.6.1",
3
+ "version": "2.6.3",
4
4
  "description": "A @kubernetes/client-node fluent API wrapper that leverages K8s Server Side Apply.",
5
5
  "bin": "./dist/cli.js",
6
6
  "main": "dist/index.js",
@@ -35,13 +35,13 @@
35
35
  },
36
36
  "homepage": "https://github.com/defenseunicorns/kubernetes-fluent-client#readme",
37
37
  "dependencies": {
38
- "@kubernetes/client-node": "1.0.0-rc4",
38
+ "@kubernetes/client-node": "1.0.0-rc6",
39
39
  "byline": "5.0.0",
40
40
  "fast-json-patch": "3.1.1",
41
41
  "http-status-codes": "2.3.0",
42
42
  "node-fetch": "2.7.0",
43
- "quicktype-core": "23.0.168",
44
- "type-fest": "4.18.2",
43
+ "quicktype-core": "23.0.170",
44
+ "type-fest": "4.20.1",
45
45
  "yargs": "17.7.2"
46
46
  },
47
47
  "devDependencies": {
@@ -52,15 +52,15 @@
52
52
  "@types/readable-stream": "4.0.14",
53
53
  "@types/urijs": "^1.19.25",
54
54
  "@types/yargs": "17.0.32",
55
- "@typescript-eslint/eslint-plugin": "7.10.0",
56
- "@typescript-eslint/parser": "7.10.0",
57
- "eslint-plugin-jsdoc": "48.2.5",
55
+ "@typescript-eslint/eslint-plugin": "7.15.0",
56
+ "@typescript-eslint/parser": "7.15.0",
57
+ "eslint-plugin-jsdoc": "48.5.0",
58
58
  "jest": "29.7.0",
59
59
  "nock": "13.5.4",
60
- "prettier": "3.2.5",
61
- "semantic-release": "23.1.1",
62
- "ts-jest": "29.1.3",
63
- "typescript": "5.4.5"
60
+ "prettier": "3.3.2",
61
+ "semantic-release": "24.0.0",
62
+ "ts-jest": "29.1.5",
63
+ "typescript": "5.5.2"
64
64
  },
65
65
  "release": {
66
66
  "branches": [
@@ -139,7 +139,7 @@ export function K8s<T extends GenericClass, K extends KubernetesObject = Instanc
139
139
  podList.push(object);
140
140
  }
141
141
  } catch (e) {
142
- throw new Error(e);
142
+ throw new Error(`Failed to get logs in KFC Logs function`);
143
143
  }
144
144
 
145
145
  const podModel = { ...model, name: "V1Pod" };
package/src/generate.ts CHANGED
@@ -183,7 +183,7 @@ async function readOrFetchCrd(opts: GenerateOptions): Promise<CustomResourceDefi
183
183
  } catch (e) {
184
184
  // If invalid, ignore the error
185
185
  if (e.code !== "ERR_INVALID_URL") {
186
- throw new Error(e);
186
+ throw new Error(`Error parsing URL ${source}`);
187
187
  }
188
188
  }
189
189