Interface: ExtensionHost
Interface: ExtensionHost
Docker Desktop 확장 SDK의 ExtensionHost 인터페이스예요. 백엔드 호스트에서 확장과 관련된 명령을 실행하는 API를 제공해요.
출처: 문서
본문
Interface: ExtensionHost
Since
0.2.0
속성
cli
• Readonly cli: ExtensionCliExtensionCli)
Executes a command in the host.
For example, execute the shipped binary kubectl -h command in the host:
await ddClient.extension.host.cli.exec("kubectl", ["-h"]);
Streams the output of the command executed in the backend container or in the host.
Provided the kubectl binary is shipped as part of your extension, you can spawn the kubectl -h command in the host:
await ddClient.extension.host.cli.exec("kubectl", ["-h"], {
stream: {
onOutput(data): void {
// As we can receive both `stdout` and `stderr`, we wrap them in a JSON object
JSON.stringify(
{
stdout: data.stdout,
stderr: data.stderr,
},
null,
" "
);
},
onError(error: any): void {
console.error(error);
},
onClose(exitCode: number): void {
console.log("onClose with exit code " + exitCode);
},
},
});