├── .gitignore ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── workflows │ └── ci.yaml ├── samples ├── oauth-sample │ ├── ui │ │ ├── .env │ │ ├── .browserslistrc │ │ ├── src │ │ │ ├── vite-env.d.ts │ │ │ ├── main.tsx │ │ │ └── App.tsx │ │ ├── tsconfig.node.json │ │ ├── vite.config.ts │ │ ├── index.html │ │ ├── tsconfig.json │ │ └── package.json │ ├── .dockerignore │ ├── .gitignore │ ├── metadata.json │ ├── Dockerfile │ ├── Makefile │ ├── docker.svg │ └── README.md ├── react │ ├── .dockerignore │ ├── client │ │ ├── .env │ │ ├── src │ │ │ ├── react-app-env.d.ts │ │ │ ├── index.tsx │ │ │ └── App.tsx │ │ ├── .prettierrc.json │ │ ├── .editorconfig │ │ ├── public │ │ │ └── index.html │ │ ├── .gitignore │ │ ├── .browserslistrc │ │ ├── tsconfig.json │ │ └── package.json │ ├── metadata.json │ ├── docker.svg │ ├── Makefile │ └── Dockerfile ├── vm-service │ ├── .gitignore │ ├── vm │ │ ├── internal │ │ │ ├── socket │ │ │ │ ├── socket_darwin.go │ │ │ │ ├── socket_linux.go │ │ │ │ ├── socket_windows.go │ │ │ │ ├── socket_unix_test.go │ │ │ │ ├── socket.go │ │ │ │ └── socket_unix.go │ │ │ └── version │ │ │ │ └── version.go │ │ ├── go.mod │ │ ├── main.go │ │ └── go.sum │ ├── docker-compose.yaml │ ├── ui │ │ └── src │ │ │ ├── script.js │ │ │ └── index.html │ ├── metadata.json │ ├── docker.svg │ ├── Makefile │ └── Dockerfile ├── kubernetes-sample-extension │ ├── .dockerignore │ ├── ui │ │ ├── .env │ │ ├── src │ │ │ ├── react-app-env.d.ts │ │ │ ├── index.tsx │ │ │ ├── helper │ │ │ │ └── kubernetes.ts │ │ │ └── App.tsx │ │ ├── public │ │ │ └── index.html │ │ ├── tsconfig.json │ │ └── package.json │ ├── .gitignore │ ├── docs │ │ └── images │ │ │ └── kubernetes-sample-extension.png │ ├── README.md │ ├── metadata.json │ ├── Makefile │ ├── Dockerfile │ └── docker.svg ├── minimal-backend │ ├── hello.sh │ ├── client │ │ ├── .env │ │ ├── src │ │ │ ├── react-app-env.d.ts │ │ │ ├── index.tsx │ │ │ └── App.tsx │ │ ├── .prettierrc.json │ │ ├── .editorconfig │ │ ├── public │ │ │ └── index.html │ │ ├── .gitignore │ │ ├── .browserslistrc │ │ ├── tsconfig.json │ │ └── package.json │ ├── metadata.json │ ├── Makefile │ └── Dockerfile ├── minimal-docker-cli │ ├── client │ │ ├── .env │ │ ├── src │ │ │ ├── react-app-env.d.ts │ │ │ ├── index.tsx │ │ │ └── App.tsx │ │ ├── .prettierrc.json │ │ ├── .editorconfig │ │ ├── public │ │ │ └── index.html │ │ ├── .gitignore │ │ ├── .browserslistrc │ │ ├── tsconfig.json │ │ └── package.json │ ├── metadata.json │ ├── Makefile │ └── Dockerfile └── minimal-frontend │ ├── metadata.json │ ├── ui │ └── index.html │ ├── Dockerfile │ └── Makefile ├── .editorconfig ├── NOTICE ├── .prettierrc.json5 ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @docker/extensions 2 | -------------------------------------------------------------------------------- /samples/oauth-sample/ui/.env: -------------------------------------------------------------------------------- 1 | BROWSER=none -------------------------------------------------------------------------------- /samples/oauth-sample/.dockerignore: -------------------------------------------------------------------------------- 1 | ui/node_modules -------------------------------------------------------------------------------- /samples/react/.dockerignore: -------------------------------------------------------------------------------- 1 | client/node_modules 2 | -------------------------------------------------------------------------------- /samples/vm-service/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | .vscode 3 | -------------------------------------------------------------------------------- /samples/oauth-sample/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | ui/build 3 | -------------------------------------------------------------------------------- /samples/oauth-sample/ui/.browserslistrc: -------------------------------------------------------------------------------- 1 | Electron 17.1.1 2 | -------------------------------------------------------------------------------- /samples/react/client/.env: -------------------------------------------------------------------------------- 1 | BUILD_PATH=dist 2 | PUBLIC_URL=. 3 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/.dockerignore: -------------------------------------------------------------------------------- 1 | ui/node_modules -------------------------------------------------------------------------------- /samples/minimal-backend/hello.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "Hello, $1!" 3 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/ui/.env: -------------------------------------------------------------------------------- 1 | PUBLIC_URL=. 2 | BROWSER=none -------------------------------------------------------------------------------- /samples/minimal-backend/client/.env: -------------------------------------------------------------------------------- 1 | BUILD_PATH=dist 2 | PUBLIC_URL=. 3 | -------------------------------------------------------------------------------- /samples/minimal-docker-cli/client/.env: -------------------------------------------------------------------------------- 1 | BUILD_PATH=dist 2 | PUBLIC_URL=. 3 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/.gitignore: -------------------------------------------------------------------------------- 1 | /ui/node_modules/ 2 | .idea/ 3 | -------------------------------------------------------------------------------- /samples/oauth-sample/ui/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | -------------------------------------------------------------------------------- /samples/react/client/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /samples/minimal-backend/client/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/ui/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// -------------------------------------------------------------------------------- /samples/minimal-docker-cli/client/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /samples/react/client/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } 5 | -------------------------------------------------------------------------------- /samples/minimal-backend/client/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } 5 | -------------------------------------------------------------------------------- /samples/minimal-docker-cli/client/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } 5 | -------------------------------------------------------------------------------- /samples/vm-service/vm/internal/socket/socket_darwin.go: -------------------------------------------------------------------------------- 1 | package socket 2 | 3 | const maxUnixSocketPathLen = 104 - 1 // NULL 4 | -------------------------------------------------------------------------------- /samples/vm-service/vm/internal/socket/socket_linux.go: -------------------------------------------------------------------------------- 1 | package socket 2 | 3 | const maxUnixSocketPathLen = 108 - 1 // NULL 4 | -------------------------------------------------------------------------------- /samples/react/client/.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | root = true 3 | end_of_line = lf 4 | 5 | indent_size = 2 6 | indent_style = space 7 | -------------------------------------------------------------------------------- /samples/minimal-backend/client/.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | root = true 3 | end_of_line = lf 4 | 5 | indent_size = 2 6 | indent_style = space 7 | -------------------------------------------------------------------------------- /samples/minimal-docker-cli/client/.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | root = true 3 | end_of_line = lf 4 | 5 | indent_size = 2 6 | indent_style = space 7 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Docker Extensions SDK 2 | Copyright Docker Inc. 3 | 4 | This product includes software developed at 5 | Docker Inc. (http://www.docker.com/). -------------------------------------------------------------------------------- /samples/vm-service/vm/internal/version/version.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | // Version is the version tag, set at build time 4 | var Version = "dev" 5 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/docs/images/kubernetes-sample-extension.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/extensions-sdk/main/samples/kubernetes-sample-extension/docs/images/kubernetes-sample-extension.png -------------------------------------------------------------------------------- /samples/minimal-docker-cli/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "ui": { 3 | "dashboard-tab": { 4 | "title": "Minimal Docker CLI", 5 | "root": "/ui", 6 | "src": "index.html" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/react/client/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | -------------------------------------------------------------------------------- /samples/minimal-frontend/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "ui": { 3 | "dashboard-tab": { 4 | "title": "Min FrontEnd Extension", 5 | "root": "/ui", 6 | "src": "index.html" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/minimal-backend/client/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | -------------------------------------------------------------------------------- /samples/react/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "icon": "docker.svg", 3 | "ui": { 4 | "dashboard-tab": { 5 | "title": "UI Extension", 6 | "root": "/ui", 7 | "src": "index.html" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /samples/minimal-docker-cli/client/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | -------------------------------------------------------------------------------- /samples/vm-service/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | devenv-volumes: 3 | image: ${DESKTOP_PLUGIN_IMAGE} 4 | cap_add: 5 | - DAC_OVERRIDE 6 | - FOWNER 7 | volumes: 8 | - /var/lib/docker:/var/lib/docker 9 | -------------------------------------------------------------------------------- /samples/vm-service/ui/src/script.js: -------------------------------------------------------------------------------- 1 | window.ddClient.extension.vm.service.get("/ls").then((volumes) => { 2 | document.body.innerHTML += ` 3 |
    4 | ${volumes.map((v) => `
  • ${v}
  • `).join("")} 5 |
6 | `; 7 | }); 8 | -------------------------------------------------------------------------------- /samples/oauth-sample/ui/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "module": "ESNext", 5 | "moduleResolution": "Node", 6 | "allowSyntheticDefaultImports": true 7 | }, 8 | "include": ["vite.config.ts"] 9 | } 10 | -------------------------------------------------------------------------------- /samples/minimal-backend/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "vm": { 3 | "image": "${DESKTOP_PLUGIN_IMAGE}" 4 | }, 5 | "ui": { 6 | "dashboard-tab": { 7 | "title": "Hello Backend Extension", 8 | "root": "/ui", 9 | "src": "index.html" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /samples/oauth-sample/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "icon": "docker.svg", 3 | "ui": { 4 | "dashboard-tab": { 5 | "title": "Oauth sample", 6 | "src": "index.html", 7 | "root": "ui", 8 | "backend": { 9 | "socket": "backend.sock" 10 | } 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /.prettierrc.json5: -------------------------------------------------------------------------------- 1 | // This file explicitly configures prettier to use its default settings if no 2 | // more specific config file is found. It prevents it from detecting config files 3 | // in ancestor directories, to ensure that the formatting is consistent regardless 4 | // of the user's directory structure. 5 | {} 6 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/README.md: -------------------------------------------------------------------------------- 1 | # Kubernetes Sample Extension 2 | 3 | This is a sample Docker Extension that shows how to interact with a Kubernetes cluster by shipping the `kubectl` command line too to read the `kubeconfig` file from your host filesystem. 4 | 5 | ![kubernetes-sample-extension](./docs/images/kubernetes-sample-extension.png) 6 | -------------------------------------------------------------------------------- /samples/oauth-sample/ui/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite"; 2 | import react from "@vitejs/plugin-react"; 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | base: "./", 8 | build: { 9 | outDir: "build", 10 | }, 11 | server: { 12 | port: 3000, 13 | strictPort: true, 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/ui/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /samples/oauth-sample/ui/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /samples/vm-service/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "icon": "docker.svg", 3 | "vm": { 4 | "composefile": "docker-compose.yaml", 5 | "exposes": { "socket": "extension-volumes.sock" } 6 | }, 7 | "ui": { 8 | "dashboard-tab": { 9 | "title": "Volumes", 10 | "root": "/ui", 11 | "src": "index.html", 12 | "backend": { "socket": "extension-volumes.sock" } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/vm-service/ui/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Volumes extension sample

9 | 10 |

11 | click to fake an error 12 |

13 | 14 |

Here are your volumes!

15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/minimal-frontend/ui/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 16 | Docker Extension 17 | 18 | 19 |

Hello, World!

20 | 21 | 22 | -------------------------------------------------------------------------------- /samples/react/client/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import CssBaseline from '@mui/material/CssBaseline'; 4 | import { DockerMuiThemeProvider } from '@docker/docker-mui-theme'; 5 | import { App } from './App'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | 11 | 12 | 13 | , 14 | document.getElementById('root'), 15 | ); 16 | -------------------------------------------------------------------------------- /samples/minimal-backend/client/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import CssBaseline from '@mui/material/CssBaseline'; 4 | import { DockerMuiThemeProvider } from '@docker/docker-mui-theme'; 5 | import { App } from './App'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | 11 | 12 | 13 | , 14 | document.getElementById('root'), 15 | ); 16 | -------------------------------------------------------------------------------- /samples/minimal-docker-cli/client/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import CssBaseline from '@mui/material/CssBaseline'; 4 | import { DockerMuiThemeProvider } from '@docker/docker-mui-theme'; 5 | import { App } from './App'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | 11 | 12 | 13 | , 14 | document.getElementById('root'), 15 | ); 16 | -------------------------------------------------------------------------------- /samples/react/client/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | /dist 14 | 15 | # misc 16 | .DS_Store 17 | .env.local 18 | .env.development.local 19 | .env.test.local 20 | .env.production.local 21 | 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | 26 | # Yarn-related 27 | .yarn/* 28 | !.yarn/patches 29 | !.yarn/releases 30 | !.yarn/plugins 31 | !.yarn/sdks 32 | !.yarn/versions 33 | .pnp.* 34 | -------------------------------------------------------------------------------- /samples/minimal-backend/client/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | /dist 14 | 15 | # misc 16 | .DS_Store 17 | .env.local 18 | .env.development.local 19 | .env.test.local 20 | .env.production.local 21 | 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | 26 | # Yarn-related 27 | .yarn/* 28 | !.yarn/patches 29 | !.yarn/releases 30 | !.yarn/plugins 31 | !.yarn/sdks 32 | !.yarn/versions 33 | .pnp.* 34 | -------------------------------------------------------------------------------- /samples/minimal-docker-cli/client/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | /dist 14 | 15 | # misc 16 | .DS_Store 17 | .env.local 18 | .env.development.local 19 | .env.test.local 20 | .env.production.local 21 | 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | 26 | # Yarn-related 27 | .yarn/* 28 | !.yarn/patches 29 | !.yarn/releases 30 | !.yarn/plugins 31 | !.yarn/sdks 32 | !.yarn/versions 33 | .pnp.* 34 | -------------------------------------------------------------------------------- /samples/react/client/src/App.tsx: -------------------------------------------------------------------------------- 1 | import { Box, Button } from '@mui/material'; 2 | import { createDockerDesktopClient } from '@docker/extension-api-client'; 3 | 4 | export function App() { 5 | const ddClient = createDockerDesktopClient(); 6 | 7 | function sayHello() { 8 | ddClient.desktopUI.toast.success('Hello, World!'); 9 | } 10 | 11 | return ( 12 | 19 | 22 | 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /samples/react/client/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This is automatically converted to a Chromium version 2 | # See: https://github.com/kilian/electron-to-chromium 3 | 4 | # One day, we could distribute a config package from pinata with a Chrome version derived by 5 | # feeding `require("electron").version` into an up-to-date `electron-to-chromium`. 6 | # https://github.com/browserslist/browserslist#shareable-configs 7 | 8 | Chrome 91 9 | 10 | # Ideally we'd do (at time of writing) "Electron 13.1.4", but the version of electron-to-chromium 11 | # in our dependency tree is a bit outdated 12 | # See https://github.com/Kilian/electron-to-chromium/blob/master/versions.js for full list 13 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "icon": "docker.svg", 3 | "ui": { 4 | "dashboard-tab": { 5 | "title": "Kubernetes Sample", 6 | "src": "index.html", 7 | "root": "ui" 8 | } 9 | }, 10 | "host": { 11 | "binaries": [ 12 | { 13 | "darwin": [ 14 | { 15 | "path": "/darwin/kubectl" 16 | } 17 | ], 18 | "windows": [ 19 | { 20 | "path": "/windows/kubectl.exe" 21 | } 22 | ], 23 | "linux": [ 24 | { 25 | "path": "/linux/kubectl" 26 | } 27 | ] 28 | } 29 | ] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /samples/minimal-backend/client/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This is automatically converted to a Chromium version 2 | # See: https://github.com/kilian/electron-to-chromium 3 | 4 | # One day, we could distribute a config package from pinata with a Chrome version derived by 5 | # feeding `require("electron").version` into an up-to-date `electron-to-chromium`. 6 | # https://github.com/browserslist/browserslist#shareable-configs 7 | 8 | Chrome 91 9 | 10 | # Ideally we'd do (at time of writing) "Electron 13.1.4", but the version of electron-to-chromium 11 | # in our dependency tree is a bit outdated 12 | # See https://github.com/Kilian/electron-to-chromium/blob/master/versions.js for full list 13 | -------------------------------------------------------------------------------- /samples/oauth-sample/ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react-jsx" 18 | }, 19 | "include": ["src"], 20 | "references": [{ "path": "./tsconfig.node.json" }] 21 | } 22 | -------------------------------------------------------------------------------- /samples/react/client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /samples/minimal-docker-cli/client/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This is automatically converted to a Chromium version 2 | # See: https://github.com/kilian/electron-to-chromium 3 | 4 | # One day, we could distribute a config package from pinata with a Chrome version derived by 5 | # feeding `require("electron").version` into an up-to-date `electron-to-chromium`. 6 | # https://github.com/browserslist/browserslist#shareable-configs 7 | 8 | Chrome 91 9 | 10 | # Ideally we'd do (at time of writing) "Electron 13.1.4", but the version of electron-to-chromium 11 | # in our dependency tree is a bit outdated 12 | # See https://github.com/Kilian/electron-to-chromium/blob/master/versions.js for full list 13 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } -------------------------------------------------------------------------------- /samples/minimal-backend/client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /samples/minimal-docker-cli/client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "" 5 | labels: enhancement 6 | assignees: "" 7 | --- 8 | 9 | **Is your feature request related to a problem? Please describe.** 10 | A clear and concise description of what the problem is. For example. 'I'm always frustrated when [...]' 11 | 12 | **Describe the solution you'd like** 13 | A clear and concise description of what you want to happen. 14 | 15 | **Describe alternatives you've considered** 16 | A clear and concise description of any alternative solutions or features you've considered. 17 | 18 | **Additional context** 19 | Add any other context or screenshots about the feature request here. 20 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/ui/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import CssBaseline from "@mui/material/CssBaseline"; 4 | import { DockerMuiThemeProvider } from "@docker/docker-mui-theme"; 5 | 6 | import { App } from "./App"; 7 | 8 | ReactDOM.render( 9 | 10 | {/* 11 | If you eject from MUI (which we don't recommend!), you should add 12 | the `dockerDesktopTheme` class to your root element to get 13 | some minimal Docker theming. 14 | */} 15 | 16 | 17 | 18 | 19 | , 20 | document.getElementById("root") 21 | ); 22 | -------------------------------------------------------------------------------- /samples/oauth-sample/ui/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | import CssBaseline from "@mui/material/CssBaseline"; 4 | import { DockerMuiThemeProvider } from "@docker/docker-mui-theme"; 5 | 6 | import { App } from './App'; 7 | 8 | ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( 9 | 10 | {/* 11 | If you eject from MUI (which we don't recommend!), you should add 12 | the `dockerDesktopTheme` class to your root element to get 13 | some minimal Docker theming. 14 | */} 15 | 16 | 17 | 18 | 19 | 20 | ); 21 | -------------------------------------------------------------------------------- /samples/vm-service/vm/internal/socket/socket_windows.go: -------------------------------------------------------------------------------- 1 | package socket 2 | 3 | import ( 4 | "net" 5 | "time" 6 | 7 | "github.com/Microsoft/go-winio" 8 | ) 9 | 10 | // ListenUnix wraps `winio.ListenUnix`. 11 | // It provides API compatibility for named pipes with the Unix domain socket API. 12 | func ListenUnix(path string) (net.Listener, error) { 13 | return winio.ListenPipe(path, &winio.PipeConfig{ 14 | MessageMode: true, // Use message mode so that CloseWrite() is supported 15 | InputBufferSize: 65536, // Use 64KB buffers to improve performance 16 | OutputBufferSize: 65536, 17 | }) 18 | } 19 | 20 | func DialSocket(socket string) (net.Conn, error) { 21 | timeout := 1 * time.Second 22 | return winio.DialPipe(socket, &timeout) 23 | } 24 | -------------------------------------------------------------------------------- /samples/react/docker.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/vm-service/docker.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/react/client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@docker/react-extension", 3 | "version": "0.2.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "react-scripts start", 7 | "build": "react-scripts build" 8 | }, 9 | "dependencies": { 10 | "@types/react": "^17.0.0", 11 | "@types/react-dom": "^17.0.0", 12 | "@docker/docker-mui-theme": "<0.1.0", 13 | "@docker/extension-api-client": "^0.3.0", 14 | "@emotion/react": "^11.7.1", 15 | "@emotion/styled": "^11.6.0", 16 | "@mui/icons-material": "^5.4.1", 17 | "@mui/material": "^5.4.1", 18 | "react": "^17.0.2", 19 | "react-dom": "^17.0.2", 20 | "react-scripts": "5.0.0", 21 | "typescript": "^4.1.2" 22 | }, 23 | "devDependencies": { 24 | "@docker/extension-api-client-types": "^0.3.0" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/minimal-backend/client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@docker/react-extension", 3 | "version": "0.2.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "react-scripts start", 7 | "build": "react-scripts build" 8 | }, 9 | "dependencies": { 10 | "@types/react": "^17.0.0", 11 | "@types/react-dom": "^17.0.0", 12 | "@docker/docker-mui-theme": "<0.1.0", 13 | "@docker/extension-api-client": "^0.3.0", 14 | "@emotion/react": "^11.7.1", 15 | "@emotion/styled": "^11.6.0", 16 | "@mui/icons-material": "^5.4.1", 17 | "@mui/material": "^5.4.1", 18 | "react": "^17.0.2", 19 | "react-dom": "^17.0.2", 20 | "react-scripts": "5.0.0", 21 | "typescript": "^4.1.2" 22 | }, 23 | "devDependencies": { 24 | "@docker/extension-api-client-types": "^0.3.0" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/minimal-docker-cli/client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@docker/react-extension", 3 | "version": "0.2.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "react-scripts start", 7 | "build": "react-scripts build" 8 | }, 9 | "dependencies": { 10 | "@types/react": "^17.0.0", 11 | "@types/react-dom": "^17.0.0", 12 | "@docker/docker-mui-theme": "<0.1.0", 13 | "@docker/extension-api-client": "^0.3.0", 14 | "@emotion/react": "^11.7.1", 15 | "@emotion/styled": "^11.6.0", 16 | "@mui/icons-material": "^5.4.1", 17 | "@mui/material": "^5.4.1", 18 | "react": "^17.0.2", 19 | "react-dom": "^17.0.2", 20 | "react-scripts": "5.0.0", 21 | "typescript": "^4.1.2" 22 | }, 23 | "devDependencies": { 24 | "@docker/extension-api-client-types": "^0.3.0" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/oauth-sample/ui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ui", 3 | "version": "0.1.0", 4 | "private": true, 5 | "type": "module", 6 | "dependencies": { 7 | "@docker/docker-mui-theme": "<0.1.0", 8 | "@docker/extension-api-client": "0.3.2", 9 | "@emotion/react": "11.10.4", 10 | "@emotion/styled": "11.10.4", 11 | "@mui/material": "5.10.8", 12 | "react": "^18.2.0", 13 | "react-dom": "^18.2.0" 14 | }, 15 | "scripts": { 16 | "dev": "vite", 17 | "build": "tsc && vite build", 18 | "test": "jest src" 19 | }, 20 | "devDependencies": { 21 | "@docker/extension-api-client-types": "0.3.2", 22 | "@types/jest": "^29.1.2", 23 | "@types/node": "^18.7.18", 24 | "@types/react": "^18.0.17", 25 | "@types/react-dom": "^18.0.6", 26 | "@vitejs/plugin-react": "^2.1.0", 27 | "jest": "^29.1.2", 28 | "typescript": "^4.8.3", 29 | "vite": "^3.2.10" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /samples/vm-service/vm/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/docker/vm-service-extension 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/Microsoft/go-winio v0.5.0 7 | github.com/labstack/echo v3.3.10+incompatible 8 | github.com/pkg/errors v0.9.1 9 | github.com/sirupsen/logrus v1.8.1 10 | github.com/stretchr/testify v1.7.0 11 | ) 12 | 13 | require ( 14 | github.com/davecgh/go-spew v1.1.1 // indirect 15 | github.com/labstack/gommon v0.3.0 // indirect 16 | github.com/mattn/go-colorable v0.1.2 // indirect 17 | github.com/mattn/go-isatty v0.0.9 // indirect 18 | github.com/pmezard/go-difflib v1.0.0 // indirect 19 | github.com/valyala/bytebufferpool v1.0.0 // indirect 20 | github.com/valyala/fasttemplate v1.0.1 // indirect 21 | golang.org/x/crypto v0.21.0 // indirect 22 | golang.org/x/net v0.23.0 // indirect 23 | golang.org/x/sys v0.18.0 // indirect 24 | golang.org/x/text v0.14.0 // indirect 25 | gopkg.in/yaml.v3 v3.0.0 // indirect 26 | ) 27 | -------------------------------------------------------------------------------- /samples/vm-service/vm/internal/socket/socket_unix_test.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package socket 4 | 5 | import ( 6 | "fmt" 7 | "io/ioutil" 8 | "net" 9 | "os" 10 | "path" 11 | "testing" 12 | 13 | "github.com/stretchr/testify/assert" 14 | "github.com/stretchr/testify/require" 15 | ) 16 | 17 | func TestMaxPathLength(t *testing.T) { 18 | dir, err := ioutil.TempDir("", "test-max-path-length") 19 | require.Nil(t, err) 20 | defer func() { 21 | assert.Nil(t, os.RemoveAll(dir)) 22 | }() 23 | path := path.Join(dir, "socket") 24 | for { 25 | l, err := net.Listen("unix", path) 26 | if err != nil { 27 | if len(path) > maxUnixSocketPathLen { 28 | return 29 | } 30 | fmt.Printf("path length %d is <= maximum %d\n", len(path), maxUnixSocketPathLen) 31 | t.Fail() 32 | return 33 | } 34 | if len(path) > maxUnixSocketPathLen { 35 | fmt.Printf("path length %d is > maximum %d\n", len(path), maxUnixSocketPathLen) 36 | t.Fail() 37 | } 38 | require.Nil(t, l.Close()) 39 | path = path + "1" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | directories: 11 | name: List child folders to build 12 | runs-on: ubuntu-latest 13 | outputs: 14 | dir: ${{ steps.set-dirs.outputs.dir }} 15 | steps: 16 | - uses: actions/checkout@v2 17 | - id: set-dirs # Give it an id to handle to get step outputs in the outputs key above 18 | run: echo "::set-output name=dir::$(ls -d samples/*/ | jq -R -s -c 'split("\n")[:-1]')" 19 | build: 20 | name: Build extensions 21 | runs-on: ubuntu-latest 22 | needs: [directories] 23 | strategy: 24 | matrix: 25 | dir: ${{fromJson(needs.directories.outputs.dir)}} # List matrix strategy from directories dynamically 26 | steps: 27 | - name: Checkout code 28 | uses: actions/checkout@v2 29 | 30 | - name: Build sample ${{ matrix.dir }} 31 | run: cd ${{ matrix.dir }} ; make build-extension 32 | env: 33 | DOCKER_BUILDKIT: 1 34 | -------------------------------------------------------------------------------- /samples/oauth-sample/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM --platform=$BUILDPLATFORM node:18.12-alpine3.16 AS client-builder 2 | WORKDIR /ui 3 | # cache packages in layer 4 | COPY ui/package.json /ui/package.json 5 | COPY ui/package-lock.json /ui/package-lock.json 6 | RUN --mount=type=cache,target=/usr/src/app/.npm \ 7 | npm set cache /usr/src/app/.npm && \ 8 | npm ci 9 | # install 10 | COPY ui /ui 11 | RUN npm run build 12 | 13 | FROM alpine 14 | LABEL org.opencontainers.image.title="Oauth sample" \ 15 | org.opencontainers.image.description="Sample extension logging in with github OAuth service" \ 16 | org.opencontainers.image.vendor="Awesome Inc." \ 17 | com.docker.desktop.extension.api.version="0.3.3" \ 18 | com.docker.extension.screenshots="" \ 19 | com.docker.extension.detailed-description="" \ 20 | com.docker.extension.publisher-url="" \ 21 | com.docker.extension.additional-urls="" \ 22 | com.docker.extension.changelog="" 23 | 24 | COPY metadata.json . 25 | COPY docker.svg . 26 | COPY --from=client-builder /ui/build ui 27 | -------------------------------------------------------------------------------- /samples/minimal-backend/client/src/App.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Stack, TextField, Typography } from '@mui/material'; 2 | import { createDockerDesktopClient } from '@docker/extension-api-client'; 3 | import { useState } from 'react'; 4 | 5 | export function App() { 6 | const ddClient = createDockerDesktopClient(); 7 | const [backendInfo, setBackendInfo] = useState(); 8 | 9 | async function runExtensionBackend(inputText: string) { 10 | const result = await ddClient.extension.vm?.cli.exec('./hello.sh', [ 11 | inputText, 12 | ]); 13 | setBackendInfo(result?.stdout); 14 | } 15 | 16 | return ( 17 | 24 | runExtensionBackend(event.target.value)} 27 | > 28 | 29 | {backendInfo ? {backendInfo} : ''} 30 | 31 | ); 32 | } 33 | -------------------------------------------------------------------------------- /samples/minimal-docker-cli/client/src/App.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Stack, Typography } from '@mui/material'; 2 | import { createDockerDesktopClient } from '@docker/extension-api-client'; 3 | import { useState } from 'react'; 4 | 5 | export function App() { 6 | const ddClient = createDockerDesktopClient(); 7 | const [dockerInfo, setDockerInfo] = useState(null); 8 | 9 | async function runDockerInfo() { 10 | const result = await ddClient.docker.cli.exec('info', [ 11 | '--format', 12 | '"{{json .}}"', 13 | ]); 14 | setDockerInfo(result.parseJsonObject()); 15 | } 16 | 17 | return ( 18 | 25 | 28 | 29 | {dockerInfo ? ( 30 |
31 | Allocated CPUs: {dockerInfo?.NCPU} 32 | Allocated Memory: {dockerInfo?.MemTotal} 33 |
34 | ) : ( 35 | '' 36 | )} 37 |
38 | ); 39 | } 40 | -------------------------------------------------------------------------------- /samples/minimal-frontend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM scratch 2 | 3 | LABEL org.opencontainers.image.title="Minimal FrontEnd" \ 4 | org.opencontainers.image.description="A sample extension that displays a Hello World message from an HTML page." \ 5 | org.opencontainers.image.vendor="Docker Inc." \ 6 | com.docker.desktop.extension.api.version=">= 0.3.0" \ 7 | com.docker.desktop.extension.icon="https://www.docker.com/wp-content/uploads/2022/03/Moby-logo.png" \ 8 | com.docker.extension.screenshots='[{"alt":"hello world light mode", "url":"https://docker-extension-screenshots.s3.amazonaws.com/minimal-frontend/hello-world-light.png"}, {"alt":"hello world dark mode", "url":"https://docker-extension-screenshots.s3.amazonaws.com/minimal-frontend/hello-world-dark.png"}]' \ 9 | com.docker.extension.detailed-description="

Description

This is a sample extension that displays the content of an index.html page inside Docker Desktop.

" \ 10 | com.docker.extension.publisher-url="https://www.docker.com" \ 11 | com.docker.extension.additional-urls='[{"title":"SDK Documentation","url":"https://docs.docker.com/desktop/extensions-sdk"}]' \ 12 | com.docker.extension.changelog="
  • Added metadata to provide more information about the extension.
" 13 | 14 | COPY ui ./ui 15 | COPY metadata.json . 16 | -------------------------------------------------------------------------------- /samples/oauth-sample/Makefile: -------------------------------------------------------------------------------- 1 | IMAGE?=samples/oauth-extension 2 | TAG?=latest 3 | 4 | BUILDER=buildx-multi-arch 5 | 6 | INFO_COLOR = \033[0;36m 7 | NO_COLOR = \033[m 8 | 9 | build-extension: ## Build service image to be deployed as a desktop extension 10 | docker build --tag=$(IMAGE):$(TAG) . 11 | 12 | install-extension: build-extension ## Install the extension 13 | docker extension install $(IMAGE):$(TAG) 14 | 15 | update-extension: build-extension ## Update the extension 16 | docker extension update $(IMAGE):$(TAG) 17 | 18 | prepare-buildx: ## Create buildx builder for multi-arch build, if not exists 19 | docker buildx inspect $(BUILDER) || docker buildx create --name=$(BUILDER) --driver=docker-container --driver-opt=network=host 20 | 21 | push-extension: prepare-buildx ## Build & Upload extension image to hub. Do not push if tag already exists: make push-extension tag=0.1 22 | docker pull $(IMAGE):$(TAG) && echo "Failure: Tag already exists" || docker buildx build --push --builder=$(BUILDER) --platform=linux/amd64,linux/arm64 --build-arg TAG=$(TAG) --tag=$(IMAGE):$(TAG) . 23 | 24 | help: ## Show this help 25 | @echo Please specify a build target. The choices are: 26 | @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "$(INFO_COLOR)%-30s$(NO_COLOR) %s\n", $$1, $$2}' 27 | 28 | .PHONY: help 29 | -------------------------------------------------------------------------------- /samples/react/Makefile: -------------------------------------------------------------------------------- 1 | IMAGE?=docker/react-extension 2 | TAG?=latest 3 | 4 | BUILDER=buildx-multi-arch 5 | 6 | INFO_COLOR = \033[0;36m 7 | NO_COLOR = \033[m 8 | 9 | build-extension: ## Build service image to be deployed as a desktop extension 10 | docker build --tag=$(IMAGE):$(TAG) . 11 | 12 | install-extension: build-extension ## Install the extension 13 | docker extension install $(IMAGE):$(TAG) 14 | 15 | update-extension: build-extension ## Update the extension 16 | docker extension update $(IMAGE):$(TAG) 17 | 18 | prepare-buildx: ## Create buildx builder for multi-arch build, if not exists 19 | docker buildx inspect $(BUILDER) || docker buildx create --name=$(BUILDER) --driver=docker-container --driver-opt=network=host 20 | 21 | push-extension: prepare-buildx ## Build & Upload extension image to hub. Do not push if tag already exists: make push-extension tag=0.1 22 | docker pull $(IMAGE):$(TAG) && echo "Failure: Tag already exists" || docker buildx build --push --builder=$(BUILDER) --platform=linux/amd64,linux/arm64 --build-arg TAG=$(TAG) --tag=$(IMAGE):$(TAG) . 23 | 24 | help: ## Show this help 25 | @echo Please specify a build target. The choices are: 26 | @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "$(INFO_COLOR)%-30s$(NO_COLOR) %s\n", $$1, $$2}' 27 | 28 | .PHONY: build-extension push-extension help 29 | -------------------------------------------------------------------------------- /samples/minimal-backend/Makefile: -------------------------------------------------------------------------------- 1 | IMAGE?=docker/minimal-backend-extension 2 | TAG?=latest 3 | 4 | BUILDER=buildx-multi-arch 5 | 6 | INFO_COLOR = \033[0;36m 7 | NO_COLOR = \033[m 8 | 9 | build-extension: ## Build service image to be deployed as a desktop extension 10 | docker build --tag=$(IMAGE):$(TAG) . 11 | 12 | install-extension: build-extension ## Install the extension 13 | docker extension install $(IMAGE):$(TAG) 14 | 15 | update-extension: build-extension ## Update the extension 16 | docker extension update $(IMAGE):$(TAG) 17 | 18 | prepare-buildx: ## Create buildx builder for multi-arch build, if not exists 19 | docker buildx inspect $(BUILDER) || docker buildx create --name=$(BUILDER) --driver=docker-container --driver-opt=network=host 20 | 21 | push-extension: prepare-buildx ## Build & Upload extension image to hub. Do not push if tag already exists: make push-extension tag=0.1 22 | docker pull $(IMAGE):$(TAG) && echo "Failure: Tag already exists" || docker buildx build --push --builder=$(BUILDER) --platform=linux/amd64,linux/arm64 --build-arg TAG=$(TAG) --tag=$(IMAGE):$(TAG) . 23 | 24 | help: ## Show this help 25 | @echo Please specify a build target. The choices are: 26 | @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "$(INFO_COLOR)%-30s$(NO_COLOR) %s\n", $$1, $$2}' 27 | 28 | .PHONY: build-extension push-extension help 29 | -------------------------------------------------------------------------------- /samples/minimal-frontend/Makefile: -------------------------------------------------------------------------------- 1 | IMAGE?=docker/minimal-frontend-extension 2 | TAG?=latest 3 | 4 | BUILDER=buildx-multi-arch 5 | 6 | INFO_COLOR = \033[0;36m 7 | NO_COLOR = \033[m 8 | 9 | build-extension: ## Build service image to be deployed as a desktop extension 10 | docker build --tag=$(IMAGE):$(TAG) . 11 | 12 | install-extension: build-extension ## Install the extension 13 | docker extension install $(IMAGE):$(TAG) 14 | 15 | update-extension: build-extension ## Update the extension 16 | docker extension update $(IMAGE):$(TAG) 17 | 18 | prepare-buildx: ## Create buildx builder for multi-arch build, if not exists 19 | docker buildx inspect $(BUILDER) || docker buildx create --name=$(BUILDER) --driver=docker-container --driver-opt=network=host 20 | 21 | push-extension: prepare-buildx ## Build & Upload extension image to hub. Do not push if tag already exists: make push-extension tag=0.1 22 | docker pull $(IMAGE):$(TAG) && echo "Failure: Tag already exists" || docker buildx build --push --builder=$(BUILDER) --platform=linux/amd64,linux/arm64 --build-arg TAG=$(TAG) --tag=$(IMAGE):$(TAG) . 23 | 24 | help: ## Show this help 25 | @echo Please specify a build target. The choices are: 26 | @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "$(INFO_COLOR)%-30s$(NO_COLOR) %s\n", $$1, $$2}' 27 | 28 | .PHONY: build-extension push-extension help 29 | -------------------------------------------------------------------------------- /samples/minimal-docker-cli/Makefile: -------------------------------------------------------------------------------- 1 | IMAGE?=docker/minimal-docker-cli-extension 2 | TAG?=latest 3 | 4 | BUILDER=buildx-multi-arch 5 | 6 | INFO_COLOR = \033[0;36m 7 | NO_COLOR = \033[m 8 | 9 | build-extension: ## Build service image to be deployed as a desktop extension 10 | docker build --tag=$(IMAGE):$(TAG) . 11 | 12 | install-extension: build-extension ## Install the extension 13 | docker extension install $(IMAGE):$(TAG) 14 | 15 | update-extension: build-extension ## Update the extension 16 | docker extension update $(IMAGE):$(TAG) 17 | 18 | prepare-buildx: ## Create buildx builder for multi-arch build, if not exists 19 | docker buildx inspect $(BUILDER) || docker buildx create --name=$(BUILDER) --driver=docker-container --driver-opt=network=host 20 | 21 | push-extension: prepare-buildx ## Build & Upload extension image to hub. Do not push if tag already exists: make push-extension tag=0.1 22 | docker pull $(IMAGE):$(TAG) && echo "Failure: Tag already exists" || docker buildx build --push --builder=$(BUILDER) --platform=linux/amd64,linux/arm64 --build-arg TAG=$(TAG) --tag=$(IMAGE):$(TAG) . 23 | 24 | help: ## Show this help 25 | @echo Please specify a build target. The choices are: 26 | @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "$(INFO_COLOR)%-30s$(NO_COLOR) %s\n", $$1, $$2}' 27 | 28 | .PHONY: build-extension push-extension help 29 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/Makefile: -------------------------------------------------------------------------------- 1 | IMAGE?=felipecruz/kubernetes-sample-extension 2 | TAG?=latest 3 | 4 | BUILDER=buildx-multi-arch 5 | 6 | INFO_COLOR = \033[0;36m 7 | NO_COLOR = \033[m 8 | 9 | build-extension: ## Build service image to be deployed as a desktop extension 10 | docker buildx build --tag=$(IMAGE):$(TAG) . --load 11 | 12 | install-extension: build-extension ## Install the extension 13 | docker extension install $(IMAGE):$(TAG) 14 | 15 | update-extension: build-extension ## Update the extension 16 | docker extension update $(IMAGE):$(TAG) 17 | 18 | prepare-buildx: ## Create buildx builder for multi-arch build, if not exists 19 | docker buildx inspect $(BUILDER) || docker buildx create --name=$(BUILDER) --driver=docker-container --driver-opt=network=host 20 | 21 | push-extension: prepare-buildx ## Build & Upload extension image to hub. Do not push if tag already exists: make push-extension tag=0.1 22 | docker pull $(IMAGE):$(TAG) && echo "Failure: Tag already exists" || docker buildx build --push --builder=$(BUILDER) --platform=linux/amd64,linux/arm64 --build-arg TAG=$(TAG) --tag=$(IMAGE):$(TAG) . 23 | 24 | help: ## Show this help 25 | @echo Please specify a build target. The choices are: 26 | @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "$(INFO_COLOR)%-30s$(NO_COLOR) %s\n", $$1, $$2}' 27 | 28 | .PHONY: bin extension push-extension help 29 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/ui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ui", 3 | "version": "0.1.0", 4 | "private": true, 5 | "homepage": ".", 6 | "dependencies": { 7 | "@docker/docker-mui-theme": "<0.1.0", 8 | "@docker/extension-api-client": "0.3.0", 9 | "@emotion/react": "^11.9.0", 10 | "@emotion/styled": "^11.8.1", 11 | "@mui/icons-material": "^5.10.9", 12 | "@mui/lab": "^5.0.0-alpha.103", 13 | "@mui/material": "^5.6.1", 14 | "@mui/x-data-grid": "^5.17.7", 15 | "react": "^17.0.2", 16 | "react-dom": "^17.0.2", 17 | "react-scripts": "5.0.1" 18 | }, 19 | "scripts": { 20 | "start": "react-scripts start", 21 | "build": "react-scripts build", 22 | "test": "react-scripts test", 23 | "eject": "react-scripts eject" 24 | }, 25 | "eslintConfig": { 26 | "extends": [ 27 | "react-app", 28 | "react-app/jest" 29 | ] 30 | }, 31 | "devDependencies": { 32 | "@docker/extension-api-client-types": "0.3.0", 33 | "@types/jest": "^29.0.3", 34 | "@types/node": "^18.7.18", 35 | "@types/react-dom": "^17.0.2", 36 | "typescript": "^4.8.3" 37 | }, 38 | "browserslist": { 39 | "production": [ 40 | ">0.2%", 41 | "not dead", 42 | "not op_mini all" 43 | ], 44 | "development": [ 45 | "last 1 chrome version", 46 | "last 1 firefox version", 47 | "last 1 safari version" 48 | ] 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /samples/vm-service/Makefile: -------------------------------------------------------------------------------- 1 | EXTENSION:= 2 | ifeq ($(OS),Windows_NT) 3 | EXTENSION:=.exe 4 | endif 5 | 6 | IMAGE?=docker/vm-service-extension 7 | TAG?=latest 8 | BUILDER=buildx-multi-arch 9 | 10 | INFO_COLOR = \033[0;36m 11 | NO_COLOR = \033[m 12 | 13 | build-extension: ## Build service image to be deployed as a desktop extension 14 | docker build --tag=$(IMAGE):$(TAG) . 15 | 16 | install-extension: build-extension ## Install the extension 17 | docker extension install $(IMAGE):$(TAG) 18 | 19 | update-extension: build-extension ## Update the extension 20 | docker extension update $(IMAGE):$(TAG) 21 | 22 | prepare-buildx: ## Create buildx builder for multi-arch build, if not exists 23 | docker buildx inspect $(BUILDER) || docker buildx create --name=$(BUILDER) --driver=docker-container --driver-opt=network=host 24 | 25 | push-extension: prepare-buildx ## Build & Upload extension image to hub. Do not push if tag already exists: make push-extension tag=0.1 26 | docker pull $(IMAGE):$(TAG) && echo "Failure: Tag already exists" || docker buildx build --push --builder=$(BUILDER) --platform=linux/amd64,linux/arm64 --build-arg TAG=$(TAG) --tag=$(IMAGE):$(TAG) . 27 | 28 | help: ## Show this help 29 | @echo Please specify a build target. The choices are: 30 | @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "$(INFO_COLOR)%-30s$(NO_COLOR) %s\n", $$1, $$2}' 31 | 32 | .PHONY: build-extension push-extension help 33 | -------------------------------------------------------------------------------- /samples/vm-service/vm/internal/socket/socket.go: -------------------------------------------------------------------------------- 1 | package socket 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "net" 7 | "net/http" 8 | "os" 9 | "strconv" 10 | "strings" 11 | 12 | "github.com/pkg/errors" 13 | ) 14 | 15 | // ListenFD listens to a file descriptor. 16 | func ListenFD(filedes string) (net.Listener, error) { 17 | fd, err := strconv.Atoi(filedes) 18 | if err != nil { 19 | return nil, errors.Wrapf(err, "cannot parse file descriptor: %s", filedes) 20 | } 21 | file := os.NewFile(uintptr(fd), fmt.Sprintf("fd:%v", filedes)) 22 | res, err := net.FileListener(file) 23 | if err != nil { 24 | return nil, errors.Wrapf(err, "cannot convert fd %v to net.Listener", fd) 25 | } 26 | return res, nil 27 | } 28 | 29 | // Listen wraps net.Listen, preferring ListenUnix when applicable, and 30 | // offers support for the "fd" network type, in which case address is 31 | // a file descriptor. 32 | func Listen(network, address string) (net.Listener, error) { 33 | switch network { 34 | case "fd": 35 | return ListenFD(address) 36 | case "unix": 37 | return ListenUnix(address) 38 | default: 39 | return net.Listen(network, address) 40 | } 41 | } 42 | 43 | // ListenOn splits a "network:address" string to invoke Listen. 44 | func ListenOn(addr string) (net.Listener, error) { 45 | ss := strings.SplitN(addr, ":", 2) 46 | if len(ss) < 2 { 47 | return nil, errors.Errorf("invalid listener address: %v", addr) 48 | } 49 | return Listen(ss[0], ss[1]) 50 | } 51 | 52 | // Client Creates a client connected to the specified socket 53 | func Client(addr string) *http.Client { 54 | return &http.Client{ 55 | Transport: &http.Transport{ 56 | DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { 57 | return DialSocket(addr) 58 | }, 59 | }, 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /samples/minimal-backend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM --platform=$BUILDPLATFORM node:18.9-alpine3.15 AS client-builder 2 | WORKDIR /app/client 3 | # cache packages in layer 4 | COPY client/package.json /app/client/package.json 5 | COPY client/yarn.lock /app/client/yarn.lock 6 | ARG TARGETARCH 7 | RUN yarn config set cache-folder /usr/local/share/.cache/yarn-${TARGETARCH} 8 | RUN --mount=type=cache,target=/usr/local/share/.cache/yarn-${TARGETARCH} yarn 9 | # install 10 | COPY client /app/client 11 | RUN --mount=type=cache,target=/usr/local/share/.cache/yarn-${TARGETARCH} yarn build 12 | 13 | FROM alpine:3.15 14 | 15 | LABEL org.opencontainers.image.title="HelloBackend" \ 16 | org.opencontainers.image.description="A sample extension that runs a shell script inside a container's Desktop VM." \ 17 | org.opencontainers.image.vendor="Docker Inc." \ 18 | com.docker.desktop.extension.api.version=">= 0.3.0" \ 19 | com.docker.desktop.extension.icon="https://www.docker.com/wp-content/uploads/2022/03/Moby-logo.png" \ 20 | com.docker.extension.screenshots='[{"alt":"Hello, Moby", "url":"https://docker-extension-screenshots.s3.amazonaws.com/minimal-backend/1-hello-moby.png"}]' \ 21 | com.docker.extension.detailed-description="

Description

This is a sample extension that displays the text introduced in a textbox.

" \ 22 | com.docker.extension.publisher-url="https://www.docker.com" \ 23 | com.docker.extension.additional-urls='[{"title":"SDK Documentation","url":"https://docs.docker.com/desktop/extensions-sdk"}]' \ 24 | com.docker.extension.changelog="
  • Added metadata to provide more information about the extension.
" 25 | 26 | COPY hello.sh . 27 | COPY metadata.json . 28 | COPY --from=client-builder /app/client/dist ui 29 | 30 | CMD [ "sleep", "infinity" ] 31 | -------------------------------------------------------------------------------- /samples/minimal-docker-cli/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM --platform=$BUILDPLATFORM node:18.9-alpine3.15 AS client-builder 2 | WORKDIR /app/client 3 | # cache packages in layer 4 | COPY client/package.json /app/client/package.json 5 | COPY client/yarn.lock /app/client/yarn.lock 6 | ARG TARGETARCH 7 | RUN yarn config set cache-folder /usr/local/share/.cache/yarn-${TARGETARCH} 8 | RUN --mount=type=cache,target=/usr/local/share/.cache/yarn-${TARGETARCH} yarn 9 | # install 10 | COPY client /app/client 11 | RUN --mount=type=cache,target=/usr/local/share/.cache/yarn-${TARGETARCH} yarn build 12 | 13 | FROM scratch 14 | 15 | LABEL org.opencontainers.image.title="Minimal Docker CLI" \ 16 | org.opencontainers.image.description="A sample extension to show how to run docker commands from an extension." \ 17 | org.opencontainers.image.vendor="Docker Inc." \ 18 | com.docker.desktop.extension.api.version=">= 0.3.0" \ 19 | com.docker.desktop.extension.icon="https://www.docker.com/wp-content/uploads/2022/03/Moby-logo.png" \ 20 | com.docker.extension.screenshots='[{"alt":"docker info", "url":"https://docker-extension-screenshots.s3.amazonaws.com/minimal-docker-cli/1-get-docker-info.png"}]' \ 21 | com.docker.extension.detailed-description="

Description

This is a sample extension that uses the docker info command to display the number of allocated CPUs and allocated memory by the Docker Desktop VM.

" \ 22 | com.docker.extension.publisher-url="https://www.docker.com" \ 23 | com.docker.extension.additional-urls='[{"title":"SDK Documentation","url":"https://docs.docker.com/desktop/extensions-sdk"}]' \ 24 | com.docker.extension.changelog="
  • Added metadata to provide more information about the extension.
" 25 | 26 | COPY --from=client-builder /app/client/dist ui 27 | COPY metadata.json . 28 | -------------------------------------------------------------------------------- /samples/vm-service/vm/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "io/ioutil" 7 | "log" 8 | "net/http" 9 | 10 | "github.com/labstack/echo" 11 | "github.com/sirupsen/logrus" 12 | 13 | "github.com/docker/vm-service-extension/internal/socket" 14 | ) 15 | 16 | var volumesRoot = flag.String("volumesRoot", "/var/lib/docker/volumes", "Root folder for volumes") 17 | 18 | func main() { 19 | var socketPath = flag.String("socket", "/run/guest/volumes-service.sock", "Unix domain socket to listen on") 20 | var testPort = flag.Int("testPort", 0, "Test port to expose instead of socket") 21 | flag.Parse() 22 | unixSocket := "unix:" + *socketPath 23 | logrus.New().Infof("Starting listening on %s\n", unixSocket) 24 | router := echo.New() 25 | router.HideBanner = true 26 | 27 | startURL := "" 28 | 29 | if *testPort != 0 { 30 | startURL = fmt.Sprintf(":%d", *testPort) 31 | } else { 32 | ln, err := socket.ListenOn(unixSocket) 33 | if err != nil { 34 | log.Fatal(err) 35 | } 36 | router.Listener = ln 37 | } 38 | 39 | router.GET("/ls", listVolumes) 40 | router.GET("/version", getVersion) 41 | 42 | log.Fatal(router.Start(startURL)) 43 | } 44 | 45 | func getVersion(ctx echo.Context) error { 46 | return ctx.JSON(http.StatusOK, "1.0") 47 | } 48 | 49 | func listVolumes(ctx echo.Context) error { 50 | files, err := ioutil.ReadDir(*volumesRoot) 51 | if err != nil { 52 | return internalError(ctx, err) 53 | } 54 | res := []string{} 55 | for _, file := range files { 56 | res = append(res, file.Name()) 57 | } 58 | return ctx.JSON(http.StatusOK, res) 59 | } 60 | 61 | func internalError(ctx echo.Context, err error) error { 62 | logrus.Error(err) 63 | return ctx.JSON(http.StatusInternalServerError, HTTPMessageBody{Message: err.Error()}) 64 | } 65 | 66 | type HTTPMessageBody struct { 67 | Message string 68 | } 69 | -------------------------------------------------------------------------------- /samples/react/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM --platform=$BUILDPLATFORM node:18.9-alpine3.15 AS client-builder 2 | WORKDIR /app/client 3 | # cache packages in layer 4 | COPY client/package.json /app/client/package.json 5 | COPY client/yarn.lock /app/client/yarn.lock 6 | ARG TARGETARCH 7 | RUN yarn config set cache-folder /usr/local/share/.cache/yarn-${TARGETARCH} 8 | RUN --mount=type=cache,target=/usr/local/share/.cache/yarn-${TARGETARCH} yarn 9 | # install 10 | COPY client /app/client 11 | RUN --mount=type=cache,target=/usr/local/share/.cache/yarn-${TARGETARCH} yarn build 12 | 13 | FROM debian:bullseye-slim 14 | LABEL org.opencontainers.image.title="React Docker Extension" \ 15 | org.opencontainers.image.description="A sample extension that contains a ReactJS application." \ 16 | org.opencontainers.image.vendor="Docker Inc." \ 17 | com.docker.desktop.extension.api.version=">= 0.3.0" \ 18 | com.docker.desktop.extension.icon="https://www.docker.com/wp-content/uploads/2022/03/Moby-logo.png" \ 19 | com.docker.extension.screenshots='[{"alt":"hello world light mode", "url":"https://docker-extension-screenshots.s3.amazonaws.com/react/hello-world-light.png"}, {"alt":"hello world dark mode", "url":"https://docker-extension-screenshots.s3.amazonaws.com/react/hello-world-dark.png"}]' \ 20 | com.docker.extension.detailed-description="

Description

This is a sample extension that contains a ReactJS application.

" \ 21 | com.docker.extension.publisher-url="https://www.docker.com" \ 22 | com.docker.extension.additional-urls='[{"title":"SDK Documentation","url":"https://docs.docker.com/desktop/extensions-sdk"}]' \ 23 | com.docker.extension.changelog="
  • Added metadata to provide more information about the extension.
" 24 | 25 | COPY --from=client-builder /app/client/dist ui 26 | COPY docker.svg . 27 | COPY metadata.json . 28 | -------------------------------------------------------------------------------- /samples/vm-service/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.17-alpine AS builder 2 | ENV CGO_ENABLED=0 3 | WORKDIR /backend 4 | COPY vm/go.* . 5 | RUN --mount=type=cache,target=/go/pkg/mod \ 6 | --mount=type=cache,target=/root/.cache/go-build \ 7 | go mod download 8 | COPY vm/. . 9 | RUN --mount=type=cache,target=/go/pkg/mod \ 10 | --mount=type=cache,target=/root/.cache/go-build \ 11 | go build -trimpath -ldflags="-s -w" -o bin/service 12 | 13 | FROM alpine 14 | 15 | LABEL org.opencontainers.image.title="VM service" \ 16 | org.opencontainers.image.description="A sample extension that uses a VM service to list all the Docker volumes." \ 17 | org.opencontainers.image.vendor="Docker Inc." \ 18 | com.docker.desktop.extension.api.version=">= 0.2.0" \ 19 | com.docker.desktop.extension.icon="https://www.docker.com/wp-content/uploads/2022/03/Moby-logo.png" \ 20 | com.docker.extension.screenshots='[{"alt":"volumes list light mode", "url":"https://docker-extension-screenshots.s3.amazonaws.com/vm-service/vm-service-light.png"}, {"alt":"volumes list dark mode", "url":"https://docker-extension-screenshots.s3.amazonaws.com/vm-service/vm-service-dark.png"}]' \ 21 | com.docker.extension.detailed-description="

Description

This is a sample extension that uses a VM service to list all the Docker volumes.

" \ 22 | com.docker.extension.publisher-url="https://www.docker.com" \ 23 | com.docker.extension.additional-urls='[{"title":"SDK Documentation","url":"https://docs.docker.com/desktop/extensions-sdk"}]' \ 24 | com.docker.extension.changelog="
  • Added metadata to provide more information about the extension.
" 25 | 26 | COPY --from=builder /backend/bin/service / 27 | COPY docker-compose.yaml . 28 | COPY metadata.json . 29 | COPY docker.svg . 30 | COPY ui/src ./ui 31 | CMD /service -socket /run/guest-services/extension-volumes.sock 32 | -------------------------------------------------------------------------------- /samples/vm-service/vm/internal/socket/socket_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package socket 4 | 5 | import ( 6 | "fmt" 7 | "net" 8 | "os" 9 | "path/filepath" 10 | ) 11 | 12 | // ListenUnix wraps `net.ListenUnix`. 13 | func ListenUnix(path string) (*net.UnixListener, error) { 14 | if err := os.Remove(path); err != nil && !os.IsNotExist(err) { 15 | return nil, err 16 | } 17 | // Make sure the parent directory exists. 18 | dir := filepath.Dir(path) 19 | if err := os.MkdirAll(dir, 0755); err != nil { 20 | return nil, err 21 | } 22 | short, err := shortenUnixSocketPath(path) 23 | if err != nil { 24 | return nil, err 25 | } 26 | return net.ListenUnix("unix", &net.UnixAddr{Name: short, Net: "unix"}) 27 | } 28 | 29 | func DialSocket(socket string) (net.Conn, error) { 30 | return net.Dial("unix", socket) 31 | } 32 | 33 | func shortenUnixSocketPath(path string) (string, error) { 34 | if len(path) <= maxUnixSocketPathLen { 35 | return path, nil 36 | } 37 | // absolute path is too long, attempt to use a relative path 38 | p, err := relative(path) 39 | if err != nil { 40 | return "", err 41 | } 42 | 43 | if len(p) > maxUnixSocketPathLen { 44 | return "", fmt.Errorf("absolute and relative socket path %s longer than %d characters", p, maxUnixSocketPathLen) 45 | } 46 | return p, nil 47 | } 48 | 49 | func relative(p string) (string, error) { 50 | // Assume the parent directory exists already but the child (the socket) 51 | // hasn't been created. 52 | path2, err := filepath.EvalSymlinks(filepath.Dir(p)) 53 | if err != nil { 54 | return "", err 55 | } 56 | dir, err := os.Getwd() 57 | if err != nil { 58 | return "", err 59 | } 60 | dir2, err := filepath.EvalSymlinks(dir) 61 | if err != nil { 62 | return "", err 63 | } 64 | rel, err := filepath.Rel(dir2, path2) 65 | if err != nil { 66 | return "", err 67 | } 68 | return filepath.Join(rel, filepath.Base(p)), nil 69 | } 70 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "" 5 | labels: bug 6 | title: "" 7 | --- 8 | 9 | 15 | 16 | **Describe the bug** 17 | A clear and concise description of what the bug is. 18 | 19 | **Add the steps to reproduce** 20 | Steps to reproduce the behavior: 21 | 22 | 1. Go to '...' 23 | 2. Click on '....' 24 | 3. Scroll down to '....' 25 | 4. See error 26 | 27 | **Describe the expected behavior** 28 | A clear and concise description of what you expected to happen. 29 | 30 | **Optional: Add screenshots** 31 | If applicable, add screenshots to help explain your problem. 32 | 33 | **Output of `docker extension version`:** 34 | 35 | ``` 36 | (paste your output here) 37 | ``` 38 | 39 | **Output of `docker version`:** 40 | 41 | ``` 42 | (paste your output here) 43 | ``` 44 | 45 | **Include the Diagnostics ID** 46 | 47 | 56 | 57 | ``` 58 | (paste your output here) 59 | ``` 60 | 61 | **Additional context** 62 | Add any other context about the problem here. 63 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM --platform=$BUILDPLATFORM node:18.3.0-alpine3.16 AS client-builder 2 | 3 | WORKDIR /ui 4 | 5 | # cache packages in layer 6 | COPY ui/package.json /ui/package.json 7 | COPY ui/package-lock.json /ui/package-lock.json 8 | 9 | RUN --mount=type=cache,target=/usr/src/app/.npm \ 10 | npm set cache /usr/src/app/.npm && \ 11 | npm ci 12 | 13 | # install 14 | COPY ui /ui 15 | RUN npm run build 16 | 17 | FROM alpine 18 | LABEL org.opencontainers.image.title="Kubernetes Sample" \ 19 | org.opencontainers.image.description="This is a sample Docker Extension that shows how to interact with a Kubernetes cluster by shipping the kubectl command line too to read the kubeconfig file from your host filesystem." \ 20 | org.opencontainers.image.vendor="Docker" \ 21 | org.opencontainers.image.licenses="Apache-2.0" \ 22 | com.docker.desktop.extension.icon="" \ 23 | com.docker.desktop.extension.api.version=">= 0.2.3" \ 24 | com.docker.extension.screenshots="" \ 25 | com.docker.extension.detailed-description="" \ 26 | com.docker.extension.publisher-url="" \ 27 | com.docker.extension.additional-urls="" \ 28 | com.docker.extension.changelog="" 29 | 30 | RUN apk add curl 31 | RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \ 32 | && chmod +x ./kubectl && mv ./kubectl /usr/local/bin/kubectl \ 33 | && mkdir /linux \ 34 | && cp /usr/local/bin/kubectl /linux/ 35 | 36 | RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl" \ 37 | && mkdir /darwin \ 38 | && chmod +x ./kubectl && mv ./kubectl /darwin/ 39 | 40 | RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/windows/amd64/kubectl.exe" \ 41 | && mkdir /windows \ 42 | && chmod +x ./kubectl.exe && mv ./kubectl.exe /windows/ 43 | 44 | COPY metadata.json . 45 | COPY docker.svg . 46 | COPY --from=client-builder /ui/build ui 47 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/ui/src/helper/kubernetes.ts: -------------------------------------------------------------------------------- 1 | import { v1 } from "@docker/extension-api-client-types"; 2 | 3 | export const DockerDesktop = "docker-desktop"; 4 | export const CurrentExtensionContext = "currentExtensionContext"; 5 | export const IsK8sEnabled = "isK8sEnabled"; 6 | 7 | export const listHostContexts = async (ddClient: v1.DockerDesktopClient) => { 8 | const output = await ddClient.extension.host?.cli.exec("kubectl", [ 9 | "config", 10 | "view", 11 | "-o", 12 | "jsonpath='{.contexts}'", 13 | ]); 14 | console.log(output); 15 | if (output?.stderr) { 16 | console.log(output.stderr); 17 | return output.stderr; 18 | } 19 | 20 | return output?.stdout; 21 | }; 22 | 23 | export const setDockerDesktopContext = async ( 24 | ddClient: v1.DockerDesktopClient 25 | ) => { 26 | const output = await ddClient.extension.host?.cli.exec("kubectl", [ 27 | "config", 28 | "use-context", 29 | "docker-desktop", 30 | ]); 31 | console.log(output); 32 | if (output?.stderr) { 33 | return output.stderr; 34 | } 35 | return output?.stdout; 36 | }; 37 | 38 | export const getCurrentHostContext = async ( 39 | ddClient: v1.DockerDesktopClient 40 | ) => { 41 | const output = await ddClient.extension.host?.cli.exec("kubectl", [ 42 | "config", 43 | "view", 44 | "-o", 45 | "jsonpath='{.current-context}'", 46 | ]); 47 | console.log(output); 48 | if (output?.stderr) { 49 | return output.stderr; 50 | } 51 | return output?.stdout; 52 | }; 53 | 54 | export const checkK8sConnection = async (ddClient: v1.DockerDesktopClient) => { 55 | try { 56 | let output = await ddClient.extension.host?.cli.exec("kubectl", [ 57 | "cluster-info", 58 | "--request-timeout", 59 | "2s", 60 | ]); 61 | console.log(output); 62 | if (output?.stderr) { 63 | console.log(output.stderr); 64 | return "false"; 65 | } 66 | return "true"; 67 | } catch (e: any) { 68 | console.log("[checkK8sConnection] error : ", e); 69 | return "false"; 70 | } 71 | }; 72 | 73 | export const listNamespaces = async (ddClient: v1.DockerDesktopClient) => { 74 | const output = await ddClient.extension.host?.cli.exec("kubectl", [ 75 | "get", 76 | "namespaces", 77 | "--no-headers", 78 | "-o", 79 | 'custom-columns=":metadata.name"', 80 | "--context", 81 | "docker-desktop", 82 | ]); 83 | console.log(output); 84 | if (output?.stderr) { 85 | return output.stderr; 86 | } 87 | return output?.stdout; 88 | }; 89 | -------------------------------------------------------------------------------- /samples/oauth-sample/ui/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Button from "@mui/material/Button"; 3 | import { createDockerDesktopClient } from "@docker/extension-api-client"; 4 | import { Stack, TextField, Typography } from "@mui/material"; 5 | 6 | const client = createDockerDesktopClient(); 7 | 8 | const client_id = "xxxx"; 9 | const client_secret = "xxxx"; 10 | 11 | function useDockerDesktopClient() { 12 | return client; 13 | } 14 | 15 | export function App() { 16 | const [response, setResponse] = React.useState(); 17 | const [loggedIn, setLoggedIn] = React.useState(false); 18 | const ddClient = useDockerDesktopClient(); 19 | 20 | const queryParams = new URLSearchParams(window.location.search); 21 | console.log("query: " + queryParams.toString()); 22 | 23 | if (!loggedIn && queryParams.get("code")) { 24 | console.log("processing POST with code " + queryParams.get("code")); 25 | const requestOptions = { 26 | method: "POST", 27 | }; 28 | fetch( 29 | `https://github.com/login/oauth/access_token?client_id=${client_id}&client_secret=${client_secret}&code=${queryParams.get( 30 | "code" 31 | )}`, 32 | requestOptions 33 | ) 34 | .then((response) => response.text()) 35 | .then((data) => { 36 | setLoggedIn(true); 37 | setResponse(data); 38 | }); 39 | } 40 | 41 | const login = async () => { 42 | ddClient.host.openExternal( 43 | `https://github.com/login/oauth/authorize?client_id=${client_id}` 44 | ); 45 | }; 46 | 47 | return ( 48 | <> 49 | Docker extension Oauth demo 50 | 51 | This is a basic page using OAuth to login in using GitHub OAuth as an 52 | example. 53 | 54 | 55 | Pressing the below button will trigger a login flow and retrieve a 56 | GitHub authentication token once the user is authenticated. 57 | 58 | 59 | 62 | 71 | 72 | 73 | ); 74 | } 75 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/ui/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Button from "@mui/material/Button"; 3 | import { createDockerDesktopClient } from "@docker/extension-api-client"; 4 | import { Grid, Stack, TextField, Typography } from "@mui/material"; 5 | import { 6 | checkK8sConnection, 7 | getCurrentHostContext, 8 | listHostContexts, 9 | listNamespaces, 10 | setDockerDesktopContext, 11 | } from "./helper/kubernetes"; 12 | 13 | // Note: This line relies on Docker Desktop's presence as a host application. 14 | // If you're running this React app in a browser, it won't work properly. 15 | const client = createDockerDesktopClient(); 16 | 17 | function useDockerDesktopClient() { 18 | return client; 19 | } 20 | 21 | export function App() { 22 | const [response, setResponse] = React.useState(); 23 | const ddClient = useDockerDesktopClient(); 24 | 25 | return ( 26 | <> 27 | Kubernetes Sample extension 28 | 29 | This is a sample Docker Extension that shows how to interact with a 30 | Kubernetes cluster by shipping the kubectl command line too to read the 31 | kubeconfig file from your host filesystem. 32 | 33 | 34 | 35 | 36 | 45 | 46 | 55 | 56 | 65 | 66 | 75 | 76 | 85 | 86 | 87 | 88 | 97 | 98 | 99 | 100 | ); 101 | } 102 | -------------------------------------------------------------------------------- /samples/oauth-sample/docker.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | -------------------------------------------------------------------------------- /samples/kubernetes-sample-extension/docker.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | -------------------------------------------------------------------------------- /samples/oauth-sample/README.md: -------------------------------------------------------------------------------- 1 | # My extension 2 | 3 | This sample shows how to implement oauth login with extensions. 4 | 5 | This extension is composed of a [frontend](./ui) app in React that shows a login button. When clicked, it will open the browsser to perform a github login, and obtain a oauth token (that will be displayed for the sake of this example). 6 | 7 | 8 | 9 | ## Prepare oauth configuration 10 | 11 | In order to run this example, you needed to create a GitHub OAuth app. See details at https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app 12 | 13 | You can then get a client ID and client secret from the OAuth app, and set the values in /ui/src/App.tsx 14 | 15 | In the OAuth app, you can also set the Authorization callback URL to `docker-desktop://dashboard/extension-tab?extensionId=samples/oauth-extension`. This tells GitHub to redirect to the extension in Docker Desktop at the end of the login process. (Note: this can be configured in code as well, options are dependent on the OAuth provider) 16 | 17 | See details about the overall OAuth flow in the [Extension OAuth documentation](https://docs.docker.com/desktop/extensions-sdk/guides/oauth2-flow/) 18 | 19 | ## Local development 20 | 21 | You can use `docker` to build, install and push your extension. Also, we provide an opinionated [Makefile](Makefile) that could be convenient for you. There isn't a strong preference of using one over the other, so just use the one you're most comfortable with. 22 | 23 | To build the extension, use `make build-extension` **or**: 24 | 25 | ```shell 26 | docker buildx build -t my/awesome-extension:latest . --load 27 | ``` 28 | 29 | To install the extension, use `make install-extension` **or**: 30 | 31 | ```shell 32 | docker extension install my/awesome-extension:latest 33 | ``` 34 | 35 | > If you want to automate this command, use the `-f` or `--force` flag to accept the warning message. 36 | 37 | To preview the extension in Docker Desktop, open Docker Dashboard once the installation is complete. The left-hand menu displays a new tab with the name of your extension. You can also use `docker extension ls` to see that the extension has been installed successfully. 38 | 39 | ### Frontend development 40 | 41 | During the development of the frontend part, it's helpful to use hot reloading to test your changes without rebuilding your entire extension. To do this, you can configure Docker Desktop to load your UI from a development server. 42 | Assuming your app runs on the default port, start your UI app and then run: 43 | 44 | ```shell 45 | cd ui 46 | npm install 47 | npm run dev 48 | ``` 49 | 50 | This starts a development server that listens on port `3000`. 51 | 52 | You can now tell Docker Desktop to use this as the frontend source. In another terminal run: 53 | 54 | ```shell 55 | docker extension dev ui-source my/awesome-extension:latest http://localhost:3000 56 | ``` 57 | 58 | In order to open the Chrome Dev Tools for your extension when you click on the extension tab, run: 59 | 60 | ```shell 61 | docker extension dev debug my/awesome-extension:latest 62 | ``` 63 | 64 | Each subsequent click on the extension tab will also open Chrome Dev Tools. To stop this behaviour, run: 65 | 66 | ```shell 67 | docker extension dev reset my/awesome-extension:latest 68 | ``` 69 | 70 | ### Clean up 71 | 72 | To remove the extension: 73 | 74 | ```shell 75 | docker extension rm my/awesome-extension:latest 76 | ``` 77 | 78 | ## What's next? 79 | 80 | - To learn more about how to build your extension refer to the Extension SDK docs at https://docs.docker.com/desktop/extensions-sdk/. 81 | - To publish your extension in the Marketplace visit https://www.docker.com/products/extensions/submissions/. 82 | - To report issues and feedback visit https://github.com/docker/extensions-sdk/issues. 83 | - To look for other ideas of new extensions, or propose new ideas of extensions you would like to see, visit https://github.com/docker/extension-ideas/discussions. 84 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker Extensions 2 | 3 | This repository includes the Extensions CLI and samples to create Docker Extensions. 4 | 5 | ## Prerequisites 6 | 7 | To get started with Docker Extensions you will need the [latest version of Docker Desktop](https://docs.docker.com/desktop/release-notes/). The Docker extension CLI is bundled by default with Docker Desktop version 4.10.0 and higher. 8 | 9 | ## Tutorials 10 | 11 | - [Create a minimal frontend extension](https://docs.docker.com/desktop/extensions-sdk/build/set-up/minimal-frontend-extension/) - a minimal Desktop Extension containing only a UI part based on HTML. 12 | - [Create a minimal backend extension](https://docs.docker.com/desktop/extensions-sdk/build/set-up/minimal-backend-extension/) - a Desktop Extension containing a UI part connecting to a minimal backend. 13 | - [Create a minimal Docker CLI extension](https://docs.docker.com/desktop/extensions-sdk/build/set-up/minimal-frontend-using-docker-cli/) - a minimal Desktop Extension containing only a UI part that invokes Docker CLI commands. 14 | - [Create a ReactJS-based extension](https://docs.docker.com/desktop/extensions-sdk/build/set-up/react-extension/) - a minimal Desktop Extension containing only a UI part based on ReactJS. 15 | 16 | ## Extensions SDK documentation 17 | 18 | Documentation about the Extensions SDK and creating your own extensions can be found [here](https://docs.docker.com/desktop/extensions-sdk/). 19 | 20 | [Contributions](https://github.com/docker/docker.github.io/blob/master/CONTRIBUTING.md) are welcome to update/improve documentation content (see extensions SDK under [desktop/extensions-sdk folder](https://github.com/docker/docker.github.io/tree/master/desktop/extensions-sdk)) 21 | 22 | ## Docker Extension Model 23 | 24 | Desktop Extensions are packaged and distributed as Docker images. 25 | Development of extensions can be done locally without the need to push the extension to Docker Hub. 26 | This is described in [Extension Distribution](https://docs.docker.com/desktop/extensions-sdk/extensions/DISTRIBUTION/). 27 | 28 | The extension image must have some specific content as described in [Extension Metadata](https://docs.docker.com/desktop/extensions-sdk/extensions/METADATA/). 29 | 30 | ## Developing Docker Extensions 31 | 32 | The [Extensions CLI](https://docs.docker.com/desktop/extensions-sdk/dev/usage/) is an extension development tool that can be used to manage Docker extensions. 33 | 34 | This repository contains multiple extensions, each one is defined in an individual directories at the root of the repository. 35 | These are Docker developed samples that are not meant to be final products. 36 | 37 | To try one of them, navigate to the directory of the extension then [use the CLI to build and install the extension](https://docs.docker.com/desktop/extensions-sdk/build/build-install/) on Docker Desktop. 38 | 39 | The [Quickstart guide](https://docs.docker.com/desktop/extensions-sdk/quickstart/) describes how to get started developing your custom Docker Extension. It also covers how to open the Chrome Dev Tools and show the extension containers. 40 | 41 | The extension UI has access to an extension API to invoke backend operations from the UI, e.g. listing running containers, images, etc. 42 | Furthermore, you can communicate with your extension backend service or invoke a binary on the host or in the VM. 43 | 44 | ### UI Guidelines 45 | 46 | We are currently in the process of developing our design system but in the meantime, here are some [UI guidelines](https://www.figma.com/file/U7pLWfEf6IQKUHLhdateBI/Docker-Design-Guidelines?node-id=1%3A28771). Docker Desktop's UI is written in React and [Material UI](https://mui.com/), and we strongly recommend adopting this combination in your extensions as well. This brings the benefit of using our [Material UI Theme](https://www.npmjs.com/package/@docker/docker-mui-theme) to easily replicate Docker Desktop's look & feel, and we'll continue to release libraries and utilities targeting this combination. 47 | 48 | You can read more about our design guidelines [here](https://docs.docker.com/desktop/extensions-sdk/design/design-guidelines/). 49 | -------------------------------------------------------------------------------- /samples/vm-service/vm/go.sum: -------------------------------------------------------------------------------- 1 | github.com/Microsoft/go-winio v0.5.0 h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXGjwU= 2 | github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= 3 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 4 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 5 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 6 | github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= 7 | github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= 8 | github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0= 9 | github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= 10 | github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= 11 | github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= 12 | github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 13 | github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg= 14 | github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= 15 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 16 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 17 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 18 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 19 | github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= 20 | github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= 21 | github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= 22 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 23 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 24 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 25 | github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= 26 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 27 | github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= 28 | github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= 29 | github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8= 30 | github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= 31 | github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= 32 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 33 | golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 34 | golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= 35 | golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= 36 | golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= 37 | golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= 38 | golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= 39 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 40 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 41 | golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= 42 | golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= 43 | golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= 44 | golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= 45 | golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= 46 | golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= 47 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 48 | golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 49 | golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 50 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 51 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 52 | golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 53 | golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 54 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 55 | golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 56 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 57 | golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 58 | golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 59 | golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 60 | golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 61 | golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 62 | golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= 63 | golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 64 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 65 | golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= 66 | golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= 67 | golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= 68 | golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= 69 | golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= 70 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 71 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 72 | golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 73 | golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= 74 | golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= 75 | golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= 76 | golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= 77 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 78 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 79 | golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= 80 | golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= 81 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 82 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 83 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 84 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 85 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 86 | gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA= 87 | gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 88 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. --------------------------------------------------------------------------------