@gapi/gcli 1.8.251 → 1.8.252

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.
@@ -0,0 +1,24 @@
1
+ ## 2026-10-31 - self-managed-nodes: Cluster commands call the API by cluster id; reset-machine works on platform clusters
2
+
3
+ **Feature:** self-managed-nodes · **Type:** feat
4
+
5
+ - `clusterKubeconfig`, `clusterTalosconfig`, `teardownProjectCluster` are
6
+ sent with `clusterId` only - the server checks the cluster's own project
7
+ (one API for users and admins). `cluster:reset-machine` and
8
+ `cluster:talosconfig` no longer depend on the current project (free-host
9
+ failed with missing-cluster).
10
+ - `cluster:teardown --wait`: a cluster that left the project list is
11
+ deleted, not "not found".
12
+ - Needs cluster-provisioner with the optional `projectId` deployed first.
13
+ - **Test:** `npx jest --coverage=false` (126/126); `npm run esbuild`.
14
+ - **Debug:** "This is a platform cluster - only Lambforge admins can
15
+ manage it" = the logged-in user is not an admin.
16
+ - **Verification:**
17
+ - **Real run (local stack, home-1 on the LAN, real Hetzner):** free-host
18
+ (platform): reset-machine (the command that failed with missing-cluster),
19
+ attach, detach, reset, attach again. A new single-node Talos cluster in
20
+ the owner's `test` project: attach (KubeSpan from the LAN), kubeconfig +
21
+ talosconfig by cluster id, detach, reset - home-1 left in maintenance
22
+ mode; the test cluster torn down (status deleted, machine records gone).
23
+ A plan-team USER: refused on free-host (also when sending its own
24
+ projectId) and on the test project's cluster; its own project works.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gapi/gcli",
3
- "version": "1.8.251",
3
+ "version": "1.8.252",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Stradivario/gapi.git"
package/release/index.js CHANGED
@@ -37092,29 +37092,29 @@ var init_gql_client = __esm({
37092
37092
  variables: { projectId }
37093
37093
  }).pipe((0, import_operators.map)((res) => res.projectClusters));
37094
37094
  }
37095
- static teardownProjectCluster(projectId, clusterId) {
37095
+ // Cluster operations are keyed by the cluster alone: the server checks the
37096
+ // cluster's own project (one API for users and admins - a platform cluster
37097
+ // has no project).
37098
+ static teardownProjectCluster(clusterId) {
37096
37099
  return this.query({
37097
37100
  query: gql`
37098
- mutation teardownProjectCluster(
37099
- $projectId: String!
37100
- $clusterId: String!
37101
- ) {
37102
- teardownProjectCluster(projectId: $projectId, clusterId: $clusterId) {
37101
+ mutation teardownProjectCluster($clusterId: String!) {
37102
+ teardownProjectCluster(clusterId: $clusterId) {
37103
37103
  ${ClusterFragment}
37104
37104
  }
37105
37105
  }
37106
37106
  `,
37107
- variables: { projectId, clusterId }
37107
+ variables: { clusterId }
37108
37108
  }).pipe((0, import_operators.map)((res) => res.teardownProjectCluster));
37109
37109
  }
37110
- static clusterKubeconfig(projectId, clusterId) {
37110
+ static clusterKubeconfig(clusterId) {
37111
37111
  return this.query({
37112
37112
  query: gql`
37113
- query clusterKubeconfig($projectId: String!, $clusterId: String!) {
37114
- clusterKubeconfig(projectId: $projectId, clusterId: $clusterId)
37113
+ query clusterKubeconfig($clusterId: String!) {
37114
+ clusterKubeconfig(clusterId: $clusterId)
37115
37115
  }
37116
37116
  `,
37117
- variables: { projectId, clusterId }
37117
+ variables: { clusterId }
37118
37118
  }).pipe((0, import_operators.map)((res) => res.clusterKubeconfig));
37119
37119
  }
37120
37120
  // Cluster scaling, topology, load balancer and health (cluster-provisioner;
@@ -37294,19 +37294,11 @@ var init_gql_client = __esm({
37294
37294
  variables: { clusterId, includeCloud }
37295
37295
  }).pipe((0, import_operators.map)((res) => res.clusterNodes ?? []));
37296
37296
  }
37297
- static clusterTalosconfig(projectId, clusterId, ttlMinutes) {
37297
+ static clusterTalosconfig(clusterId, ttlMinutes) {
37298
37298
  return this.query({
37299
37299
  query: gql`
37300
- query clusterTalosconfig(
37301
- $projectId: String!
37302
- $clusterId: String!
37303
- $ttlMinutes: Int
37304
- ) {
37305
- clusterTalosconfig(
37306
- projectId: $projectId
37307
- clusterId: $clusterId
37308
- ttlMinutes: $ttlMinutes
37309
- ) {
37300
+ query clusterTalosconfig($clusterId: String!, $ttlMinutes: Int) {
37301
+ clusterTalosconfig(clusterId: $clusterId, ttlMinutes: $ttlMinutes) {
37310
37302
  talosconfig
37311
37303
  expiresAt
37312
37304
  endpoint
@@ -37314,7 +37306,7 @@ var init_gql_client = __esm({
37314
37306
  }
37315
37307
  }
37316
37308
  `,
37317
- variables: { projectId, clusterId, ttlMinutes }
37309
+ variables: { clusterId, ttlMinutes }
37318
37310
  }).pipe((0, import_operators.map)((res) => res.clusterTalosconfig));
37319
37311
  }
37320
37312
  static setClusterNodePaused(clusterId, name2, paused) {
@@ -254858,12 +254850,21 @@ var init_build = __esm({
254858
254850
  });
254859
254851
 
254860
254852
  // src/commands/cluster/helpers/poll-until-ready.ts
254861
- function pollUntilReady(projectId, clusterId, { intervalMs = 5e3, timeoutMs = 20 * 60 * 1e3 } = {}) {
254853
+ function pollUntilReady(projectId, clusterId, {
254854
+ intervalMs = 5e3,
254855
+ timeoutMs = 20 * 60 * 1e3,
254856
+ /** watching a teardown: a cluster no longer listed is deleted (the
254857
+ project's list leaves deleted clusters out) */
254858
+ goneMeansDeleted = false
254859
+ } = {}) {
254862
254860
  return (0, import_rxjs7.firstValueFrom)(
254863
254861
  (0, import_rxjs7.timer)(0, intervalMs).pipe(
254864
254862
  (0, import_operators6.switchMap)(() => GraphqlClienAPI.projectClusters(projectId)),
254865
254863
  (0, import_operators6.switchMap)((clusters) => {
254866
254864
  const cluster = (clusters || []).find((c) => c.id === clusterId);
254865
+ if (!cluster && goneMeansDeleted) {
254866
+ return [{ id: clusterId, status: "deleted" }];
254867
+ }
254867
254868
  if (!cluster) {
254868
254869
  throw new Error(`cluster ${clusterId} not found`);
254869
254870
  }
@@ -255494,7 +255495,7 @@ var init_teardown = __esm({
255494
255495
  const { projectId, cluster } = await (0, import_rxjs14.lastValueFrom)(
255495
255496
  parseProjectId(cmd.project).pipe(
255496
255497
  (0, import_operators10.switchMap)(
255497
- (projectId2) => GraphqlClienAPI.teardownProjectCluster(projectId2, cmd.cluster).pipe(
255498
+ (projectId2) => GraphqlClienAPI.teardownProjectCluster(cmd.cluster).pipe(
255498
255499
  (0, import_operators10.map)((cluster2) => ({ projectId: projectId2, cluster: cluster2 }))
255499
255500
  )
255500
255501
  ),
@@ -255515,7 +255516,9 @@ var init_teardown = __esm({
255515
255516
  return cluster;
255516
255517
  }
255517
255518
  Logger.info(`Waiting for cluster ${cluster.id} to finish tearing down...`);
255518
- const finalCluster = await pollUntilReady(projectId, cluster.id);
255519
+ const finalCluster = await pollUntilReady(projectId, cluster.id, {
255520
+ goneMeansDeleted: true
255521
+ });
255519
255522
  Logger.log(
255520
255523
  `[Action][teardownProjectCluster] final status: ${finalCluster.status}`
255521
255524
  );
@@ -255534,15 +255537,11 @@ var init_kubeconfig = __esm({
255534
255537
  "src/commands/cluster/kubeconfig.ts"() {
255535
255538
  import_rxjs15 = __toESM(require_cjs());
255536
255539
  import_operators11 = __toESM(require_operators());
255537
- init_helpers();
255538
255540
  init_gql_client();
255539
255541
  init_log();
255540
255542
  init_read_file();
255541
255543
  kubeconfig_default = (cmd) => (0, import_rxjs15.lastValueFrom)(
255542
- parseProjectId(cmd.project).pipe(
255543
- (0, import_operators11.switchMap)(
255544
- (projectId) => GraphqlClienAPI.clusterKubeconfig(projectId, cmd.cluster)
255545
- ),
255544
+ GraphqlClienAPI.clusterKubeconfig(cmd.cluster).pipe(
255546
255545
  (0, import_operators11.switchMap)(
255547
255546
  (kubeconfig) => cmd.output ? writeFileAsObservable(cmd.output, kubeconfig).pipe(
255548
255547
  (0, import_operators11.tap)(() => Logger.info(`Wrote kubeconfig to ${cmd.output}`))
@@ -256030,7 +256029,7 @@ var init_reset_machine = __esm({
256030
256029
  "--node-ip is required: the machine's address on your network"
256031
256030
  );
256032
256031
  }
256033
- const { projectId, clusterId } = await resolveClusterTarget(cmd);
256032
+ const { clusterId } = await resolveClusterTarget(cmd);
256034
256033
  const node = (await (0, import_rxjs20.lastValueFrom)(GraphqlClienAPI.clusterNodes(clusterId, true))).find((n) => n.name === name2);
256035
256034
  if (node?.source === "hetzner") {
256036
256035
  throw new Error(
@@ -256043,7 +256042,7 @@ var init_reset_machine = __esm({
256043
256042
  );
256044
256043
  }
256045
256044
  const access = await (0, import_rxjs20.lastValueFrom)(
256046
- GraphqlClienAPI.clusterTalosconfig(projectId, clusterId, 15)
256045
+ GraphqlClienAPI.clusterTalosconfig(clusterId, 15)
256047
256046
  );
256048
256047
  const binary = access.talosVersion ? await ensureTalosctl(access.talosVersion) : "talosctl";
256049
256048
  const dir = await (0, import_promises3.mkdtemp)((0, import_path3.join)((0, import_os3.tmpdir)(), "gcli-reset-"));
@@ -256132,9 +256131,9 @@ var init_talosconfig = __esm({
256132
256131
  if (ttl !== void 0 && (!Number.isInteger(ttl) || ttl < 5 || ttl > 1440)) {
256133
256132
  throw new Error("--ttl is in minutes, 5 to 1440");
256134
256133
  }
256135
- const { projectId, clusterId } = await resolveClusterTarget(cmd);
256134
+ const { clusterId } = await resolveClusterTarget(cmd);
256136
256135
  const res = await (0, import_rxjs21.lastValueFrom)(
256137
- GraphqlClienAPI.clusterTalosconfig(projectId, clusterId, ttl)
256136
+ GraphqlClienAPI.clusterTalosconfig(clusterId, ttl)
256138
256137
  );
256139
256138
  if (!cmd.output) {
256140
256139
  process.stdout.write(res.talosconfig);