Skip to content

Commit

Permalink
example nits
Browse files Browse the repository at this point in the history
  • Loading branch information
danopia committed Aug 13, 2023
1 parent b677a3a commit 4ca2e96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/examples/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@ import { CoreV1Api } from "../builtin/core@v1/mod.ts";

const restClient = await autoDetectClient();


// Set up a client for the apps/v1 API
const appsApi = new AppsV1Api(restClient);

// Iterate thru all deployments with pagination (to handle large lists effectively)
for await (const deploy of readAllItems(t => appsApi.getDeploymentListForAllNamespaces({
limit: 5,
limit: 5, // note: tiny page size for demonstration purposes, 100-500 is common in practice
continue: t,
}))) {
console.log(deploy.metadata?.namespace, deploy.metadata?.name);
}


// Set up a client for the core v1 API
const coreApi = new CoreV1Api(restClient);

// Get the first node from the cluster node list
const {items: [node]} = await coreApi.getNodeList({limit: 1});
console.log(node.status);
2 changes: 1 addition & 1 deletion lib/examples/follow-logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ for await (const line of logStream.pipeThrough(new TextLineStream())) {
const date = new Date(line.slice(0, firstSpace));
const logLine = line.slice(firstSpace+1);
console.log(date, logLine);
}
}

0 comments on commit 4ca2e96

Please sign in to comment.