-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a command to create the simplest network (#1350)
* Add a command to create the simplest network
- Loading branch information
1 parent
f89cf97
commit 561a574
Showing
5 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See LICENSE.md in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { window } from 'vscode'; | ||
import { IActionContext } from 'vscode-azureextensionui'; | ||
import { ext } from '../../extensionVariables'; | ||
import { wrapDockerodeENOENT } from '../../utils/wrapError'; | ||
|
||
export async function createNetwork(_context: IActionContext): Promise<void> { | ||
|
||
const name = await ext.ui.showInputBox({ | ||
value: '', | ||
prompt: 'Name of the network' | ||
}); | ||
|
||
const driverSelection = await ext.ui.showQuickPick( | ||
[ | ||
{ label: 'bridge' }, | ||
{ label: 'host' }, | ||
{ label: 'overlay' }, | ||
{ label: 'macvlan' } | ||
], | ||
{ | ||
canPickMany: false, | ||
placeHolder: 'Select the network driver to use (default is "bridge").' | ||
} | ||
); | ||
|
||
const result = <{ id: string }>await wrapDockerodeENOENT(() => ext.dockerode.createNetwork({ Name: name, Driver: driverSelection.label })); | ||
|
||
window.showInformationMessage(`Network Created with ID ${result.id.substr(0, 12)}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters