Skip to content

Commit

Permalink
3.13 (#218)
Browse files Browse the repository at this point in the history
* diag rule tweak

* version bump and deps update

* #206 tweaks

* teem tweak

* remoteCommand #211

* next api disable

* final 3.13 update

* test tweaks
  • Loading branch information
DumpySquare authored Jun 21, 2023
1 parent dc381de commit 9a0dc6c
Show file tree
Hide file tree
Showing 10 changed files with 302 additions and 176 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,32 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

### Added

- [RFE] Can't delete tmsh scripts #214

### Changed


### Fixed

- [RFE] Config Explorer doesn't include cipher groups with the applications #213

---

## [3.13.0] - (06-20-2023)

### Added

- [RFE] add history to remote command execute #211

### Fixed

- f5-corkscrew v1.3.0
- [BUG] Monitor no more display in Config explorer #217
- deps updates
- [BUG] Error running command f5.addHost: command 'f5.addHost' not found. #206
- [BUG] Error connecting to BIG-IP --- TypeError: Cannot read properties of undefined (reading 'paths') #215


---

## [3.12.1] - (05-24-2022)
Expand Down
2 changes: 1 addition & 1 deletion diagRules/tmosXcRules.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"code": "9929",
"severity": "Warning",
"title": "TMOS Route Domain not supported",
"message": "Route domains are note support in XC",
"message": "Route domains are not support in XC",
"regex": "destination [\\S]+%(\\d{1,2}):\\d{1,5}"
},
{
Expand Down
194 changes: 97 additions & 97 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "The F5 Extension",
"description": "Supercharge your F5 automation development",
"publisher": "F5DevCentral",
"version": "3.12.2",
"version": "3.13.0",
"keywords": [
"F5",
"F5Networks",
Expand Down Expand Up @@ -58,8 +58,8 @@
"@types/mocha": "^7.0.1",
"@types/node": "^14.18.1",
"@types/vscode": "^1.63.0",
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"@vscode/test-electron": "^2.2.1",
"eslint": "^8.12.0",
"glob": "^7.1.6",
Expand All @@ -73,7 +73,7 @@
"@f5devcentral/f5-fast-core": "^0.19.1",
"ajv": "^8.11.2",
"f5-conx-core": "^0.17.2",
"f5-corkscrew": "^1.1.3",
"f5-corkscrew": "^1.2.0",
"js-yaml": "^4.0.0",
"keytar": "^7.9.0",
"openapi-data-validator": "^2.0.44"
Expand All @@ -99,7 +99,7 @@
"activationEvents": [
"*"
],
"main": "./out/extLoader.js",
"main": "./out/extension.js",
"contributes": {
"snippets": [
{
Expand Down Expand Up @@ -206,7 +206,7 @@
{
"id": "nxtApiView",
"name": "NEXT API",
"when": "f5.preview"
"when": "false"
},
{
"id": "fastView",
Expand Down Expand Up @@ -643,6 +643,7 @@
{
"command": "f5.refreshNextApiTree",
"title": "Refresh NEXT OPENAPI View",
"enablement": "false",
"category": "F5",
"icon": "$(refresh)"
},
Expand Down
5 changes: 4 additions & 1 deletion src/extLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ const perfStats: PerfStats = {
// Object.defineProperty(exports, "__esModule", { value: true });

import { ExtensionContext } from 'vscode';
import { activateInternal, deactivateInternal } from './extension';
import {
activate as activateInternal,
deactivate as deactivateInternal
} from './extension';

// while this may load the code/references, it will be empty
import { ext } from './extensionVariables';
Expand Down
158 changes: 130 additions & 28 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
Range,
Position,
languages,
ThemeIcon,
} from 'vscode';
import jsYaml from 'js-yaml';
import * as path from 'path';
Expand Down Expand Up @@ -64,6 +65,7 @@ import { Telemetry } from './telemetry';
import { XcDiag } from './tmosXcDiag';
import { NextApi } from './nextApi';
import { CodeLensProvider } from './codeLens';
import { createRequire } from 'module';

// turn off console logging
logger.console = false;
Expand All @@ -78,7 +80,7 @@ logger.output = function (log: string) {


// provide extension functions for activation
export async function activateInternal(context: ExtensionContext) {
export async function activate(context: ExtensionContext) {

process.on('unhandledRejection', error => {
logger.error('--- unhandledRejection ---', error);
Expand Down Expand Up @@ -141,7 +143,7 @@ export async function activateInternal(context: ExtensionContext) {

new CfCore(context);

new NextApi(context, ext.eventEmitterGlobal);
// new NextApi(context, ext.eventEmitterGlobal);

languages.registerCodeLensProvider({
language: 'json',
Expand Down Expand Up @@ -932,32 +934,132 @@ export async function activateInternal(context: ExtensionContext) {

ext.telemetry.capture({ command: 'f5.remoteCommand' });

// todo: add a setting to hold the command and future history
await window.showQuickPick(
[
'cat /config/bigip.conf',
'cat bigip.license',
'tail -100 /var/log/ltm',
'tmsh show /apm license'
],{
ignoreFocusOut: true,
title: 'Enter command to execute on the BIG-IP'
})
.then(async cmd => {

if (cmd) {

await ext.f5Client?.https(`/mgmt/tm/util/bash`, {
method: 'POST',
data: {
command: 'run',
utilCmdArgs: `-c '${cmd}'`
}
})
.then(resp => ext.panel.render(resp.data.commandResult))
.catch(err => logger.error('bash command failed:', err));
// get the cmd history from vscode global state
const histary: string[] = context.globalState.get('f5-rc-history', []);

const historyDefaults = [
'cat /config/bigip.conf',
'cat bigip.license',
'tail -100 /var/log/ltm',
'tmsh show /apm license'
];

const cmd = await new Promise((resolve) => {

const qp = window.createQuickPick()

//build all the history items with delete buttons
const i = histary.map(label => ({
label,
buttons: [{ iconPath: new ThemeIcon("trash"), tooltip: "Remove this item" }]
}))

// build all the defaults (no delete button)
const ii = historyDefaults.map(label => ({ label }))

// spread all the options together
qp.items = [...i, ...ii];

// allow focus out
qp.ignoreFocusOut = true;

// event for history button (trash)
qp.onDidTriggerItemButton(async (_button) => {

// isolat the value
const item = _button.item.label;

// filter out this button item from the history array
const newHistary = histary.filter(x => x !== item)
// clear the history array
histary.length = 0
// spread all the filtered records back into the history array
histary.push(...newHistary)

// rerun the command to get new values
return commands.executeCommand('f5.remoteCommand')

}),

qp.onDidAccept(a => {

// main quick pick object
const b = qp;
// if new item typed in
const bv = b.value;
// if existing item selected;
const bs = b.selectedItems[0]?.label;

resolve(bv || bs);
qp.hide();
})

qp.show();
}) as string;

if (cmd) {

// console.log(cmd)

await ext.f5Client?.https(`/mgmt/tm/util/bash`, {
method: 'POST',
data: {
command: 'run',
utilCmdArgs: `-c '${cmd}'`
}
});
})
.then(resp => {

// render the output for the user
ext.panel.render(resp.data.commandResult)

// is command part of the historyDefaults
const isDefaultCmd = historyDefaults.indexOf(cmd);

if (isDefaultCmd < 0) {

//is command already in the history
const idx = histary.indexOf(cmd)

// command is not in history
if(idx < 0) {

// add the cmd to the top of the history array
histary.unshift(cmd)

} else {

// command found in history
// remove command by index
histary.splice(idx, 1)
// re-add command back to the top
histary.unshift(cmd)
}

// if we exceed 5, remove oldest
if (histary.length > 5) histary.pop();

// save the array to the vscode global state
context.globalState.update('f5-rc-history', histary)
}

})
.catch(err => logger.error('bash command failed:', err));
}


// }



// // merge the history and defaults to disply for user, with latest history on top
// await window.showQuickPick([...histary, ...historyDefaults], {
// ignoreFocusOut: true,
// title: 'Enter command to execute on the BIG-IP'
// })
// .then(async cmd => {



}));

Expand All @@ -969,6 +1071,6 @@ export async function activateInternal(context: ExtensionContext) {


// this method is called when your extension is deactivated
export async function deactivateInternal(context: ExtensionContext) {
export async function deactivate(context: ExtensionContext) {
// log deactivation event
}
2 changes: 1 addition & 1 deletion src/extensionVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export async function loadSettings() {

process.env.F5_VSCODE_LOG_LEVEL = f5Cfg.get('logLevel');

process.env[ext.teemEnv] = f5Cfg.get('f5.TEEM')!;
process.env[ext.teemEnv] = f5Cfg.get('TEEM');

process.env.F5_CONX_CORE_REJECT_UNAUTORIZED = f5Cfg.get('rejectUnauthorizedBIGIP')!.toString();

Expand Down
Loading

0 comments on commit 9a0dc6c

Please sign in to comment.