Docker CLI gRPC JavaScript SDK
Перейти к файлу
Djordje Lukic bd9a9eba64 Add license
Fixes #14

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2020-07-06 15:41:19 +02:00
.github/workflows Update protos to latest, adds inspect command 2020-07-01 12:27:29 +02:00
dist Add license 2020-07-06 15:41:19 +02:00
examples Add license 2020-07-06 15:41:19 +02:00
scripts Add exec example 2020-06-12 15:41:56 +02:00
src Add license 2020-07-06 15:41:19 +02:00
test Update protos to latest, adds inspect command 2020-07-01 12:27:29 +02:00
.dockerignore Add exec example 2020-06-12 15:41:56 +02:00
.eslintrc.js Add eslint config 2020-06-09 18:26:54 +02:00
.gitignore Build with typescript 2020-06-10 16:11:15 +02:00
Dockerfile Use docker cli if the docker-linux-amd64 is not present 2020-06-12 16:33:36 +02:00
LICENSE Add license 2020-07-06 15:41:19 +02:00
NOTICE Add license 2020-07-06 15:41:19 +02:00
README.md Fix the usage, console.log the contexts 2020-06-15 14:29:04 +02:00
babel.config.js Add exec example 2020-06-12 15:41:56 +02:00
package.json Add license 2020-07-06 15:41:19 +02:00
protos.sh Initial commit 2020-06-09 13:08:34 +02:00
tsconfig.json Build with typescript 2020-06-10 16:11:15 +02:00
yarn.lock Update protos to latest, adds inspect command 2020-07-01 12:27:29 +02:00

README.md

Docker CLI JavaScript SDK

CI

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.