Skip to content

Commit

Permalink
v1.1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
cjlapao committed Jun 5, 2024
1 parent 2a05186 commit 6140abf
Show file tree
Hide file tree
Showing 14 changed files with 486 additions and 114 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ tsconfig.lsif.json
*.ipsw
**/*/.env
node_modules/
/remote-desktop-client-src/
/remote-desktop-client-src/
vscode.d.ts
25 changes: 25 additions & 0 deletions package-lock.json

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

36 changes: 27 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,12 +700,20 @@
},
{
"command": "parallels-desktop.devops-service.add-remote-provider-orchestrator-host",
"title": "Parallels DevOps: Add Orchestrator Host",
"title": "Add Orchestrator Host",
"icon": {
"light": "img/light/plus.svg",
"dark": "img/dark/plus.svg"
}
},
{
"command": "parallels-desktop.devops-service.update-remote-provider-orchestrator-host",
"title": "Update Orchestrator Host",
"icon": {
"light": "img/light/edit.svg",
"dark": "img/dark/edit.svg"
}
},
{
"command": "parallels-desktop.devops-service.remove-remote-provider-orchestrator-host",
"title": "Parallels DevOps: Add Orchestrator Host",
Expand Down Expand Up @@ -862,8 +870,8 @@
}
},
{
"command": "parallels-desktop.devops-service.management.rename-remote-provider",
"title": "Rename",
"command": "parallels-desktop.devops-service.remote-provider-management.update-remote-provider",
"title": "Update Provider",
"icon": {
"light": "img/light/edit.svg",
"dark": "img/dark/edit.svg"
Expand Down Expand Up @@ -1085,6 +1093,10 @@
"command": "parallels-desktop.devops-service.add-remote-provider-orchestrator-host",
"when": "false"
},
{
"command": "parallels-desktop.devops-service.update-remote-provider-orchestrator-host",
"when": "false"
},
{
"command": "parallels-desktop.devops-service.remove-remote-provider-orchestrator-host",
"when": "false"
Expand Down Expand Up @@ -1158,7 +1170,7 @@
"when": "false"
},
{
"command": "parallels-desktop.devops-service.management.rename-remote-provider",
"command": "parallels-desktop.devops-service.remote-provider-management.update-remote-provider",
"when": "false"
},
{
Expand Down Expand Up @@ -1494,6 +1506,11 @@
"when": "view == parallels-desktop-remote-hosts && viewItem =~ /devops\\.remote\\.orchestrator\\.hosts/",
"group": "inline@0"
},
{
"command": "parallels-desktop.devops-service.update-remote-provider-orchestrator-host",
"when": "view == parallels-desktop-remote-hosts && viewItem =~ /devops\\.remote\\.orchestrator\\.host_(healthy|unhealthy).*/",
"group": "inline@1"
},
{
"command": "parallels-desktop.devops-service.remove-remote-provider-orchestrator-host",
"when": "view == parallels-desktop-remote-hosts && viewItem =~ /devops\\.remote\\.orchestrator\\.host_(healthy|unhealthy).*/",
Expand Down Expand Up @@ -1590,7 +1607,7 @@
"group": "inline@10"
},
{
"command": "parallels-desktop.devops-service.management.rename-remote-provider",
"command": "parallels-desktop.devops-service.remote-provider-management.update-remote-provider",
"when": "(view == parallels-desktop-remote-hosts || view == parallels-desktop-catalog) && viewItem =~ /devops\\.(remote\\.provider|catalog\\.provider)/",
"group": "inline@0"
},
Expand Down Expand Up @@ -1696,12 +1713,12 @@
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"@types/axios": "^0.14.0",
"@types/glob": "^8.1.0",
"@types/mocha": "^10.0.1",
"@types/node": "16.x",
"@types/uuid": "^9.0.1",
"@types/vscode": "^1.77.0",
"@types/axios": "^0.14.0",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"@vscode/test-electron": "^2.3.0",
Expand All @@ -1724,9 +1741,10 @@
"dependencies": {
"@vscode/vsce": "^2.19.0",
"axios": "^1.4.0",
"tailwindcss": "^3.3.2",
"uuid": "^9.0.0",
"clipboardy": "^3.0.0",
"jwt-decode": "^4.0.0"
"copy-paste": "^1.5.3",
"jwt-decode": "^4.0.0",
"tailwindcss": "^3.3.2",
"uuid": "^9.0.0"
}
}
4 changes: 3 additions & 1 deletion src/constants/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,11 @@ export class CommandsFlags {
static devopsInstallFromRemoteProvider = `${COMMAND_PREFIX}.devops-service.install-from-remote-host-provider`;
static devopsAddRemoteProvider = `${COMMAND_PREFIX}.devops-service.add-remote-host-provider`;
static devopsRemoveRemoteHostProvider = `${COMMAND_PREFIX}.devops-service.remove-remote-host-provider`;
static devopsUpdateRemoteHostProvider = `${COMMAND_PREFIX}.devops-service.update-remote-host-provider`;
static devopsRefreshRemoteHostProvider = `${COMMAND_PREFIX}.devops-service.refresh-remote-host-provider`;
static devopsForceRefreshRemoteHostProvider = `${COMMAND_PREFIX}.devops-service.force-refresh-remote-host-provider`;
static devopsAddRemoteProviderOrchestratorHost = `${COMMAND_PREFIX}.devops-service.add-remote-provider-orchestrator-host`;
static devopsUpdateRemoteProviderOrchestratorHost = `${COMMAND_PREFIX}.devops-service.update-remote-provider-orchestrator-host`;
static devopsRemoveRemoteProviderOrchestratorHost = `${COMMAND_PREFIX}.devops-service.remove-remote-provider-orchestrator-host`;
static devopsRemoveRemoteProviderHost = `${COMMAND_PREFIX}.devops-service.remove-remote-host-provider-host`;
static devopsEnableRemoteProviderHost = `${COMMAND_PREFIX}.devops-service.enable-remote-host-provider-host`;
Expand All @@ -242,7 +244,7 @@ export class CommandsFlags {
static devopsRemoveRemoteProviderHostVm = `${COMMAND_PREFIX}.devops-service.remove-remote-host-provider-host-vm`;
static devopsPullCatalogManifestMachineOnRemoteHost = `${COMMAND_PREFIX}.devops-service.remote-host.pull-catalog-manifest-machine-on-host`;

static devopsRemoteProviderManagementRenameProvider = `${COMMAND_PREFIX}.devops-service.management.rename-remote-provider`;
static devopsRemoteProviderManagementUpdateProvider = `${COMMAND_PREFIX}.devops-service.remote-provider-management.update-remote-provider`;
static devopsRemoteProviderManagementAddUser = `${COMMAND_PREFIX}.devops-service.remote-provider-management.add-user`;
static devopsRemoteProviderManagementRemoveUser = `${COMMAND_PREFIX}.devops-service.remote-provider-management.remove-user`;
static devopsRemoteProviderManagementUpdateUser = `${COMMAND_PREFIX}.devops-service.remote-provider-management.update-user`;
Expand Down
1 change: 1 addition & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export async function activate(context: vscode.ExtensionContext) {
// Initializing the DevOps Remote Provider
const devopsRemoteProvider = new DevOpsRemoteHostsProvider(context);
vscode.commands.executeCommand(CommandsFlags.devopsRefreshRemoteHostProvider);
new DevOpsService(context)
DevOpsService.startRemoteHostsViewAutoRefresh();

AllDevopsRemoteProviderManagementCommands.forEach(c => c.register(context, devopsRemoteProvider));
Expand Down
10 changes: 10 additions & 0 deletions src/models/devops/updateOrchestratorHostRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export interface UpdateOrchestratorHostRequest {
host?: string;
description?: string;
authentication?: UpdateOrchestratorHostRequestAuthentication;
}

export interface UpdateOrchestratorHostRequestAuthentication {
username: string;
password: string;
}
84 changes: 61 additions & 23 deletions src/services/configurationService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {configurationInitialized} from "./../ioc/provider";
import {FeatureFlags} from "./../models/FeatureFlags";
import { configurationInitialized } from "./../ioc/provider";
import { FeatureFlags } from "./../models/FeatureFlags";
import * as vscode from "vscode";
import * as path from "path";
import * as fs from "fs";
Expand All @@ -15,27 +15,27 @@ import {
FLAG_PARALLELS_DESKTOP_EXISTS,
FLAG_VAGRANT_EXISTS
} from "../constants/flags";
import {getUserProfileFolder} from "../helpers/helpers";
import {Provider} from "../ioc/provider";
import {VirtualMachineGroup} from "../models/parallels/virtualMachineGroup";
import {ParallelsDesktopService} from "./parallelsDesktopService";
import {VirtualMachine} from "../models/parallels/virtualMachine";
import {HardwareInfo} from "../models/parallels/HardwareInfo";
import {HelperService} from "./helperService";
import {LogService} from "./logService";
import {ParallelsDesktopServerInfo} from "../models/parallels/ParallelsDesktopServerInfo";
import {Tools} from "../models/tools";
import {BrewService} from "./brewService";
import {GitService} from "./gitService";
import {PackerService} from "./packerService";
import {VagrantService} from "./vagrantService";
import {DockerRunItem} from "../models/docker/dockerRunItem";
import {DevOpsService} from "./devopsService";
import {DevOpsCatalogHostProvider} from "../models/devops/catalogHostProvider";
import {CatalogManifest, CatalogManifestItem} from "../models/devops/catalogManifest";
import {parseHost} from "../models/host";
import {DevOpsRemoteHostProvider} from "../models/devops/remoteHostProvider";
import {DevOpsRemoteHost} from "../models/devops/remoteHost";
import { getUserProfileFolder } from "../helpers/helpers";
import { Provider } from "../ioc/provider";
import { VirtualMachineGroup } from "../models/parallels/virtualMachineGroup";
import { ParallelsDesktopService } from "./parallelsDesktopService";
import { VirtualMachine } from "../models/parallels/virtualMachine";
import { HardwareInfo } from "../models/parallels/HardwareInfo";
import { HelperService } from "./helperService";
import { LogService } from "./logService";
import { ParallelsDesktopServerInfo } from "../models/parallels/ParallelsDesktopServerInfo";
import { Tools } from "../models/tools";
import { BrewService } from "./brewService";
import { GitService } from "./gitService";
import { PackerService } from "./packerService";
import { VagrantService } from "./vagrantService";
import { DockerRunItem } from "../models/docker/dockerRunItem";
import { DevOpsService } from "./devopsService";
import { DevOpsCatalogHostProvider } from "../models/devops/catalogHostProvider";
import { CatalogManifest, CatalogManifestItem } from "../models/devops/catalogManifest";
import { parseHost } from "../models/host";
import { DevOpsRemoteHostProvider } from "../models/devops/remoteHostProvider";
import { DevOpsRemoteHost } from "../models/devops/remoteHost";

export class ConfigurationService {
virtualMachinesGroups: VirtualMachineGroup[];
Expand Down Expand Up @@ -559,6 +559,44 @@ export class ConfigurationService {
return true;
}

updateRemoteProvider(provider: DevOpsCatalogHostProvider | DevOpsRemoteHostProvider): boolean {
if (!provider) {
vscode.window.showErrorMessage(`Provider not found`);
return false;
}
let foundProvider: DevOpsCatalogHostProvider | DevOpsRemoteHostProvider | undefined;
if (provider.class === "DevOpsRemoteHostProvider") {
foundProvider = this.findRemoteHostProviderById(provider.ID);
}
if (provider.class === "DevOpsCatalogHostProvider") {
foundProvider = this.findCatalogProviderByIOrName(provider.ID);
}
if (!foundProvider) {
vscode.window.showErrorMessage(`Remote Host Provider User ${provider.name} not found`);
return false;
}

if (provider.class === "DevOpsCatalogHostProvider") {
const catalogProvider = foundProvider as DevOpsCatalogHostProvider;
const index = this.catalogProviders.indexOf(catalogProvider);
this.catalogProviders[index].name = provider.name;
this.catalogProviders[index].username = provider.username;
this.catalogProviders[index].password = provider.password;
this.catalogProviders[index].authToken = '';
}
if (provider.class === "DevOpsRemoteHostProvider") {
const remoteProvider = foundProvider as DevOpsRemoteHostProvider;
const index = this.remoteHostProviders.indexOf(remoteProvider);
this.remoteHostProviders[index].name = provider.name;
this.remoteHostProviders[index].username = provider.username;
this.remoteHostProviders[index].password = provider.password;
this.remoteHostProviders[index].authToken = '';
}

this.save();
return true;
}

removeCatalogProvider(providerId: string): boolean {
const provider = this.findCatalogProviderByIOrName(providerId);
if (provider) {
Expand Down
49 changes: 44 additions & 5 deletions src/services/devopsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import {LogService} from "./logService";
import {
CommandsFlags,
FLAG_DEVOPS_PATH,
FLAG_DEVOPS_VERSION,
FLAG_GIT_PATH,
FLAG_GIT_VERSION
} from "../constants/flags";
FLAG_DEVOPS_VERSION} from "../constants/flags";
import {DevOpsCatalogHostProvider} from "../models/devops/catalogHostProvider";
import axios from "axios";
import {AuthorizationResponse} from "../models/devops/authorization";
Expand All @@ -35,6 +32,7 @@ import {
} from "../models/devops/rolesAndClaims";
import {HostHardwareInfo} from "../models/devops/hardwareInfo";
import {CreateCatalogMachine} from "../models/devops/createCatalogMachine";
import { UpdateOrchestratorHostRequest } from "../models/devops/updateOrchestratorHostRequest";

const refreshThreshold = 5000;

Expand All @@ -47,7 +45,10 @@ let isRefreshingRemoteHostProviders = false;
let remoteHostViewAutoRefreshStarted = false;

export class DevOpsService {
constructor(private context: vscode.ExtensionContext) {}
constructor(private context: vscode.ExtensionContext) {
axios.defaults.headers.common["X-LOGGING"] = "IGNORE";
axios.defaults.timeout = 15000;
}

static isInstalled(): Promise<boolean> {
return new Promise(resolve => {
Expand Down Expand Up @@ -1426,6 +1427,44 @@ export class DevOpsService {
});
}

static async updateRemoteHostOrchestratorHost(
provider: DevOpsRemoteHostProvider,
hostId: string,
request: UpdateOrchestratorHostRequest
): Promise<void> {
return new Promise(async (resolve, reject) => {
const url = await this.getHostUrl(provider).catch(err => {
return reject(err);
});
if (!request) {
return reject("Request is required");
}

const path = `${url}/api/v1/orchestrator/hosts/${hostId}`;
if (provider.type !== "orchestrator") {
return reject("Only orchestrator type can get resources");
}

const auth = await this.authorize(provider).catch(err => {
return reject(err);
});

let error: any;
const response = await axios
.put(`${path}`, request, {
headers: {
Authorization: `Bearer ${auth?.token}`
}
})
.catch(err => {
error = err;
return reject(err);
});

return !response ? reject(error) : resolve(response?.data ?? []);
});
}

static async removeRemoteHostOrchestratorHost(provider: DevOpsRemoteHostProvider, hostId: string): Promise<void> {
return new Promise(async (resolve, reject) => {
const url = await this.getHostUrl(provider).catch(err => {
Expand Down
Loading

0 comments on commit 6140abf

Please sign in to comment.