Skip to content

Commit

Permalink
issue #53 - adding config-map support - adding secret support - using…
Browse files Browse the repository at this point in the history
… k8s api - adding drop-downs for selection of config-map or secret - fixing typescript compile issue - streamlined prompts - addressed commit feedback - updated readme - addressed second round of feedback - fixed some promise issues discovered with missing rejects - test cleanup - additional promise cleanup (#64)

Signed-off-by: Brian Fitzpatrick <bfitzpat@redhat.com>
  • Loading branch information
bfitzpat committed Aug 15, 2019
1 parent 6d51d0d commit f400df3
Show file tree
Hide file tree
Showing 24 changed files with 724 additions and 206 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ All notable changes to the "vscode-camelk" extension will be documented in this

## 0.0.6

- TBD
- Added ability to deploy integrations with associated Kubernetes ConfigMaps or Secrets
- Added ability to create Kubernetes ConfigMaps or Secrets
- Began migrating away from direct Kubectl calls in favor of using the Kubernetes API component
- Changed 'Camel-K' to 'Apache Camel K' across the board for consistency
- Added tests for ConfigMap and Secret utilities
- Added Kotlin
- Moved menus to separate group to avoid cluttering up the Explorer context menu as much

## 0.0.5

Expand Down
105 changes: 69 additions & 36 deletions README.md

Large diffs are not rendered by default.

Binary file modified images/camelk-integrations-status-bar.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/camelk-integrations-view-integrations-log.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/camelk-integrations-view-refresh-action.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/camelk-integrations-view-remove-menu.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/camelk-integrations-view-settings.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/camelk-integrations-view-status-tooltip.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/camelk-start-integration-dropdown.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/kubernetes-configmap-list.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/kubernetes-secret-name-command.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/kubernetes-view-camelk-hello-xml.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/kubernetes-view-camelk-run-xml-menu.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 54 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vscode-camelk",
"displayName": "Tooling for Apache Camel-K",
"description": "VS Code extensions to support Camel-K functionality",
"displayName": "Tooling for Apache Camel K",
"description": "VS Code support for Apache Camel K functionality",
"license": "Apache-2.0",
"version": "0.0.6",
"publisher": "redhat",
Expand All @@ -25,6 +25,7 @@
"homepage": "https://github.com/camel-tooling/vscode-camelk",
"keywords": [
"Camel",
"Camel K",
"Camel-K",
"camelk",
"kamel",
Expand All @@ -43,24 +44,24 @@
"contributes": {
"configuration": [
{
"title": "Camel-K Integration Settings",
"title": "Apache Camel K Tooling Extension Settings",
"properties": {
"camelk.integrations.useProxy": {
"type": "boolean",
"default": false,
"description": "Always use proxy: If true, always use the proxy URL instead of Minikube",
"description": "Always use proxy: If true, always use the proxy URL instead of kubectl",
"scope": "window"
},
"camelk.integrations.proxyURL": {
"type": "string",
"default": "http://localhost",
"description": "Proxy configuration: URL to the running Kube server (to be combined with port)",
"description": "Proxy configuration: URL to the running Kubernetes server (to be combined with port)",
"scope": "window"
},
"camelk.integrations.proxyPort": {
"type": "number",
"default": 8000,
"description": "Proxy configuration: Port to the running Kube server (combined with proxy URL)",
"description": "Proxy configuration: Port to the running Kubernetes server (combined with proxy URL)",
"scope": "window"
},
"camelk.integrations.proxyNamespace": {
Expand All @@ -70,7 +71,7 @@
"syndesis"
],
"default": "default",
"description": "Proxy namespace: Namespace to use for accessing the Camel-K integrations",
"description": "Proxy namespace: Namespace to use for accessing Apache Camel K integrations",
"scope": "window"
},
"camelk.integrations.showStatusBarMessages": {
Expand All @@ -85,35 +86,71 @@
"commands": [
{
"command": "camelk.startintegration",
"title": "Start Camel-K Integration"
"title": "Start Apache Camel K Integration"
},
{
"command": "camelk.integrations.refresh",
"title": "Refresh Integration List",
"title": "Refresh Apache Camel K Integration List",
"icon": {
"dark": "resources/dark/refresh.svg",
"light": "resources/light/refresh.svg"
}
},
{
"command": "camelk.integrations.remove",
"title": "Remove Camel-K Integration"
"title": "Remove Apache Camel K Integration"
},
{
"command": "camelk.integrations.log",
"title": "Follow log for Camel-K Integration"
"title": "Follow log for running Apache Camel K Integration"
},
{
"command": "camelk.integrations.startproxy",
"title": "Camel-K: Start the kubectl proxy server"
"title": "Apache Camel K: Start the Kubernetes proxy server"
},
{
"command": "camelk.integrations.createconfigmapfromfile",
"title": "Create Kubernetes Config Map From File"
},
{
"command": "camelk.integrations.createconfigmapfromfolder",
"title": "Create Kubernetes Config Map From all Files in Folder"
},
{
"command": "camelk.integrations.createsecretfromfile",
"title": "Create Kubernetes Secret From File"
},
{
"command": "camelk.integrations.createsecretfromfolder",
"title": "Create Kubernetes Secret From all Files in Folder"
}
],
"menus": {
"explorer/context": [
{
"command": "camelk.startintegration",
"when": "resourceExtname =~ /\\.(groovy|java|xml|js)$/",
"group": "navigation"
"when": "resourceExtname =~ /\\.(groovy|java|xml|js|kts)$/",
"group": "camelk.group"
},
{
"command": "camelk.integrations.createconfigmapfromfile",
"when": "resourceExtname =~ /\\.(properties)$/",
"group": "camelk.group"
},
{
"command": "camelk.integrations.createconfigmapfromfolder",
"when": "explorerResourceIsFolder",
"group": "camelk.group"
},
{
"command": "camelk.integrations.createsecretfromfile",
"when": "resourceExtname =~ /\\.(properties)$/",
"group": "camelk.group"
},
{
"command": "camelk.integrations.createsecretfromfolder",
"when": "explorerResourceIsFolder",
"group": "camelk.group"
}
],
"view/title": [
Expand All @@ -140,7 +177,7 @@
"explorer": [
{
"id": "camelk.integrations",
"name": "Camel-K Integrations"
"name": "Apache Camel K Integrations"
}
]
}
Expand Down Expand Up @@ -174,6 +211,7 @@
"child_process": "^1.0.2",
"path": "^0.12.7",
"request": "^2.88.0",
"request-promise": "^4.2.4"
"request-promise": "^4.2.4",
"vscode-kubernetes-tools-api": "^1.0.0"
}
}
120 changes: 61 additions & 59 deletions src/CamelKNodeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class CamelKNodeProvider implements vscode.TreeDataProvider<TreeNode> {
this.treeNodes = [];
}

// set up so we don't pollute test runs with camel-k integrations
// set up so we don't pollute test runs with camel k integrations
public setRetrieveIntegrations(flag:boolean) {
this.retrieveIntegrations = flag;
}
Expand Down Expand Up @@ -82,70 +82,72 @@ export class CamelKNodeProvider implements vscode.TreeDataProvider<TreeNode> {

// trigger a refresh event in VSCode
public async refresh(): Promise<void> {
let oldCount = this.treeNodes.length;
extension.setStatusLineMessage(`Refreshing Camel-K Integrations view...`);
this.resetList();
let inaccessible = false;
if (this.retrieveIntegrations) {
let retryTries = 1;
let numRetries = 10;
while (retryTries < numRetries && !inaccessible) {
this.resetList();
return new Promise<void>( async (resolve, reject) => {
let oldCount = this.treeNodes.length;
extension.setStatusLineMessage(`Refreshing Apache Camel K Integrations view...`);
this.resetList();
let inaccessible = false;
if (this.retrieveIntegrations) {
let retryTries = 1;
let numRetries = 10;
while (retryTries < numRetries && !inaccessible) {
this.resetList();

if (!this.useProxy) {
await utils.pingKamel()
.then( async () => {
await this.getIntegrationsFromCamelK().then((output) => {
this.processIntegrationList(output);
}).catch((error) => {
let errMsg : string = error;
if (errMsg.toLowerCase().trim().startsWith('error:')) {
utils.shareMessage(extension.mainOutputChannel, `Refreshing Camel-K Integrations view using kubectl failed. ${error}`);
inaccessible = true;
}
Promise.reject();
if (!this.useProxy) {
await utils.pingKamel()
.then( async () => {
await this.getIntegrationsFromCamelK().then((output) => {
this.processIntegrationList(output);
}).catch((error) => {
let errMsg : string = error;
if (errMsg.toLowerCase().trim().startsWith('error:')) {
utils.shareMessage(extension.mainOutputChannel, `Refreshing Apache Camel K Integrations view using kubectl failed. ${error}`);
inaccessible = true;
}
reject();
return;
});
}).catch( (error) => {
utils.shareMessage(extension.mainOutputChannel, `Refreshing Apache Camel K Integrations view using kubectl failed. ${error}`);
inaccessible = true;
reject();
return;
});
}).catch( (error) => {
utils.shareMessage(extension.mainOutputChannel, `Refreshing Camel-K Integrations view using kubectl failed. ${error}`);
inaccessible = true;
Promise.reject();
return;
});
} else {
await utils.pingKubernetes().then( async () => {
await this.getIntegrationsFromCamelKRest().then((output) => {
this.processIntegrationListFromJSON(output);
}).catch((error) => {
utils.shareMessage(extension.mainOutputChannel, `Refreshing Camel-K Integrations view using kubernetes Rest APIs failed. ${error}`);
} else {
await utils.pingKubernetes().then( async () => {
await this.getIntegrationsFromCamelKRest().then((output) => {
this.processIntegrationListFromJSON(output);
}).catch((error) => {
utils.shareMessage(extension.mainOutputChannel, `Refreshing Apache Camel K Integrations view using kubernetes Rest APIs failed. ${error}`);
inaccessible = true;
reject();
return;
});
}).catch( (error) => {
utils.shareMessage(extension.mainOutputChannel, `Refreshing Apache Camel K Integrations view using kubernetes Rest APIs failed. ${error}`);
inaccessible = true;
Promise.reject();
reject();
return;
});
}).catch( (error) => {
utils.shareMessage(extension.mainOutputChannel, `Refreshing Camel-K Integrations view using kubernetes Rest APIs failed. ${error}`);
inaccessible = true;
Promise.reject();
return;
});
}
if (inaccessible) {
break;
}
let newCount = this.treeNodes.length;
if (newCount !== oldCount) {
break;
}
if (inaccessible) {
break;
}
let newCount = this.treeNodes.length;
if (newCount !== oldCount) {
break;
}
retryTries++;
}
retryTries++;
}
}
extension.hideStatusLine();
this._onDidChangeTreeData.fire();
Promise.resolve();
let newCount = this.treeNodes.length;
if (newCount === 0 && !inaccessible) {
utils.shareMessage(extension.mainOutputChannel, "Refreshing Camel-K Integrations view succeeded, no published integrations available.");
}
extension.hideStatusLine();
this._onDidChangeTreeData.fire();
resolve();
let newCount = this.treeNodes.length;
if (newCount === 0 && !inaccessible) {
utils.shareMessage(extension.mainOutputChannel, "Refreshing Apache Camel K Integrations view succeeded, no published integrations available.");
}
});
}

getTreeItem(node: TreeNode): vscode.TreeItem {
Expand Down Expand Up @@ -206,7 +208,7 @@ export class CamelKNodeProvider implements vscode.TreeDataProvider<TreeNode> {
}
}

// retrieve the list of integrations running in camel-k using the kube proxy and rest API
// retrieve the list of integrations running in camel k using the kube proxy and rest API
getIntegrationsFromCamelKRest(): Promise<Object> {
return new Promise( async (resolve, reject) => {
let proxyURL = utils.createCamelKRestURL();
Expand All @@ -232,7 +234,7 @@ export class CamelKNodeProvider implements vscode.TreeDataProvider<TreeNode> {
});
}

// actually retrieve the list of integrations running in camel-k using kubectl
// actually retrieve the list of integrations running in camel k using kubectl
getIntegrationsFromCamelK(): Promise<string> {
return new Promise( (resolve, reject) => {
let commandString = 'kubectl get integration';
Expand Down
Loading

0 comments on commit f400df3

Please sign in to comment.