зеркало из https://github.com/docker/node-sdk.git
bd9a9eba64
Fixes #14 Signed-off-by: Djordje Lukic <djordje.lukic@docker.com> |
||
---|---|---|
.github/workflows | ||
dist | ||
examples | ||
scripts | ||
src | ||
test | ||
.dockerignore | ||
.eslintrc.js | ||
.gitignore | ||
Dockerfile | ||
LICENSE | ||
NOTICE | ||
README.md | ||
babel.config.js | ||
package.json | ||
protos.sh | ||
tsconfig.json | ||
yarn.lock |
README.md
Docker CLI JavaScript SDK
This repository contains the source code for the Docker CLI JavaScript SDK. You can find the NPM module here.
⚠️ This SDK is in beta, expect things to change or break!
Getting started
Add node-sdk
to the dependencies
yarn add git+https://github.com/docker/node-sdk.git
You can then use the SDK:
// import the contexts client
import { Contexts } from "@docker/sdk";
// Import the request/response types for contexts.
// Note: While this is not released on npm you will need to import these
// as `@docker/sdk/dist/contexts`. Once the library is released the import path
// will be `@docker/sdk/contexts`.
import {
ListRequest,
ListResponse,
} from "@docker/sdk/dist/contexts";
const client = new Contexts();
// Get the list of contexts
client.list(new ListRequest(), (err: any, resp: ListResponse) => {
if (err) {
console.error(err);
return;
}
const contexts = resp
.getContextsList()
.map((c) => new Context(c.getName()));
console.log(contexts);
});
When you run this code you should see a list of contexts, for example:
$ ts-node example.ts
aci-context
default
Examples
You can find examples for how to use this SDK in the examples directory.