@certd/lib-k8s 1.39.6 → 1.39.8

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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.39.8](https://github.com/certd/certd/compare/v1.39.7...v1.39.8) (2026-03-31)
7
+
8
+ ### Performance Improvements
9
+
10
+ * 支持部署证书到百度CCE ([a19ea74](https://github.com/certd/certd/commit/a19ea7489c01cdbf795fb51f804bd6d00389f604))
11
+
12
+ ## [1.39.7](https://github.com/certd/certd/compare/v1.39.6...v1.39.7) (2026-03-25)
13
+
14
+ **Note:** Version bump only for package @certd/lib-k8s
15
+
6
16
  ## [1.39.6](https://github.com/certd/certd/compare/v1.39.5...v1.39.6) (2026-03-22)
7
17
 
8
18
  **Note:** Version bump only for package @certd/lib-k8s
@@ -1,4 +1,4 @@
1
- import { CoreV1Api, KubeConfig, V1Ingress, V1Secret, KubernetesObjectApi } from "@kubernetes/client-node";
1
+ import { CoreV1Api, KubeConfig, V1Ingress, V1Secret, KubernetesObjectApi, KubernetesObject } from "@kubernetes/client-node";
2
2
  import { ILogger } from "@certd/basic";
3
3
  export type K8sClientOpts = {
4
4
  kubeConfigStr: string;
@@ -17,7 +17,8 @@ export declare class K8sClient {
17
17
  init(): void;
18
18
  getKubeConfig(): KubeConfig;
19
19
  getKubeClient(): KubernetesObjectApi;
20
- apply(manifest: string): Promise<void>;
20
+ apply(manifest: string): Promise<KubernetesObject>;
21
+ applyPatch(manifest: string): Promise<KubernetesObject>;
21
22
  /**
22
23
  *
23
24
  * @param localRecords { [domain]:{ip:'xxx.xx.xxx'} }
@@ -45,10 +45,10 @@ export class K8sClient {
45
45
  const yml = loadYaml(manifest);
46
46
  const client = this.getKubeClient();
47
47
  try {
48
+ this.logger.info("apply yaml:", yml);
48
49
  await client.create(yml);
49
50
  }
50
51
  catch (e) {
51
- this.logger.error("apply error", e.response?.body);
52
52
  if (e.response?.body?.reason === "AlreadyExists") {
53
53
  //patch
54
54
  this.logger.info("patch existing resource: ", yml.metadata?.name);
@@ -57,12 +57,24 @@ export class K8sClient {
57
57
  yml.metadata = {};
58
58
  }
59
59
  yml.metadata.resourceVersion = existing.body.metadata.resourceVersion;
60
- await client.patch(yml);
61
- return;
60
+ const res = await client.patch(yml);
61
+ return res?.body;
62
62
  }
63
63
  throw e;
64
64
  }
65
65
  }
66
+ async applyPatch(manifest) {
67
+ const yml = loadYaml(manifest);
68
+ const client = this.getKubeClient();
69
+ this.logger.info("patch yaml:", yml);
70
+ const existing = await client.read(yml);
71
+ if (!yml.metadata) {
72
+ yml.metadata = {};
73
+ }
74
+ yml.metadata.resourceVersion = existing.body.metadata.resourceVersion;
75
+ const res = await client.patch(yml);
76
+ return res?.body;
77
+ }
66
78
  /**
67
79
  *
68
80
  * @param localRecords { [domain]:{ip:'xxx.xx.xxx'} }
@@ -97,6 +109,7 @@ export class K8sClient {
97
109
  */
98
110
  async createSecret(opts) {
99
111
  const namespace = opts.namespace || "default";
112
+ this.logger.info("create secret:", opts.body.metadata);
100
113
  const created = await this.client.createNamespacedSecret(namespace, opts.body);
101
114
  this.logger.info("new secrets:", opts.body.metadata);
102
115
  return created.body;
@@ -133,6 +146,7 @@ export class K8sClient {
133
146
  this.logger.info(`secret ${secretName} 已创建`);
134
147
  return res;
135
148
  }
149
+ throw new Error(`secret ${secretName} 不存在`);
136
150
  }
137
151
  throw e;
138
152
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@certd/lib-k8s",
3
3
  "private": false,
4
- "version": "1.39.6",
4
+ "version": "1.39.8",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -14,10 +14,11 @@
14
14
  "build3": "rollup -c",
15
15
  "build2": "vue-tsc --noEmit && vite build",
16
16
  "preview": "vite preview",
17
- "pub": "npm publish"
17
+ "pub": "npm publish",
18
+ "compile": "tsc --skipLibCheck --watch"
18
19
  },
19
20
  "dependencies": {
20
- "@certd/basic": "^1.39.6",
21
+ "@certd/basic": "^1.39.8",
21
22
  "@kubernetes/client-node": "0.21.0"
22
23
  },
23
24
  "devDependencies": {
@@ -32,5 +33,5 @@
32
33
  "tslib": "^2.8.1",
33
34
  "typescript": "^5.4.2"
34
35
  },
35
- "gitHead": "b0ccab41e17cb16c87bfc0ec3b052d5e8a5d8435"
36
+ "gitHead": "de0ae14544f1c3da4923dddc6a1a3bea4db295e7"
36
37
  }