Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
chore: remove unused inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshrn committed Sep 27, 2021
1 parent 39281b7 commit dd7dab4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/interfaces/extensionSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface ExtensionSettings {
}

interface ExecutionEnvironmentSettings {
containerEngine: IContianerEngine;
containerEngine: IContianerEngine;
enabled: boolean;
image: string;
pullPolicy: IPullPolicy;
Expand Down
2 changes: 1 addition & 1 deletion src/providers/completionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export async function doCompletion(
// NOTE: Might no longer be required due to the hack above
const path = getPathAt(document, position, yamlDocs, true);
if (path) {
const node = path[path.length - 1];
const node = path[path.length - 1];
if (node) {
const docsLibrary = await context.docsLibrary;

Expand Down
6 changes: 3 additions & 3 deletions src/services/ansibleConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export class AnsibleConfig {
const settings = await this.context.documentSettings.get(
this.context.workspaceFolder.uri
);

const commandRunner = new CommandRunner(this.connection, this.context, settings)

// get Ansible configuration
const ansibleConfigResult = await commandRunner.runCommand(
'ansible-config',
Expand Down Expand Up @@ -75,7 +75,7 @@ export class AnsibleConfig {
set collections_paths(updatedCollectionPath: string[]) {
this._collection_paths = updatedCollectionPath;
}

get collections_paths(): string[] {
return this._collection_paths;
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/ansibleLint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,4 @@ export class AnsibleLint {
}
return configPath;
}
}
}
16 changes: 8 additions & 8 deletions src/services/executionEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class ExecutionEnvironment {
private _container_engine: IContianerEngine;
private _container_image: string;
private _container_image_id: string;

constructor(connection: Connection, context: WorkspaceFolderContext) {
this.connection = connection;
this.context = context;
Expand All @@ -28,7 +28,7 @@ export class ExecutionEnvironment {
);
this._container_image = settings.executionEnvironment.image
this._container_engine = settings.executionEnvironment.containerEngine
if (this._container_engine === 'auto') {
if (this._container_engine === 'auto') {
for (const ce of ['podman', 'docker']) {
try {
child_process.execSync(`which ${ce}`, {
Expand All @@ -45,7 +45,7 @@ export class ExecutionEnvironment {
try {
child_process.execSync(`which ${this._container_engine}`, {
encoding: 'utf-8'
})
})
} catch (error) {
this.connection.window.showErrorMessage(`Container engine '${this._container_engine}' not found. Failed with error '${error}'`)
return
Expand Down Expand Up @@ -76,13 +76,13 @@ export class ExecutionEnvironment {
);
}
}

}

async fetchPluginDocs(): Promise<void> {
const ansibleConfig = await this.context.ansibleConfig;
const containerName = `${this._container_image.replace(/[^a-z0-9]/ig, '_')}`

try {
const containerImageIdCommand = `${this._container_engine} images ${this._container_image} --format="{{.ID}}" | head -n 1`
this.connection.console.log(containerImageIdCommand)
Expand All @@ -94,7 +94,7 @@ export class ExecutionEnvironment {
if (!this.runContainer(containerName)) {
return
}

if (fs.existsSync(hostCacheBasePath)) {
ansibleConfig.collections_paths = this.updateCachePaths(ansibleConfig.collections_paths, hostCacheBasePath)
ansibleConfig.module_locations = this.updateCachePaths(ansibleConfig.module_locations, hostCacheBasePath)
Expand Down Expand Up @@ -132,7 +132,7 @@ export class ExecutionEnvironment {
this.cleanUpContainer(containerName)
}
}

public wrapContainerArgs(command: string): string {
const workspaceFolderPath = URI.parse(this.context.workspaceFolder.uri).path
const containerCommand: Array<string> = [this._container_engine]
Expand Down Expand Up @@ -208,7 +208,7 @@ export class ExecutionEnvironment {
contianerPluginPaths: string[],
searchKind: string
): Promise<string[]> {

const updatedHostDocPath: string[] = []
if (fs.existsSync(hostPluginDocCacheBasePath)) {
contianerPluginPaths.forEach((srcPath) => {
Expand Down
13 changes: 5 additions & 8 deletions src/utils/commandRunner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import * as child_process from 'child_process';
import * as ini from 'ini';
import * as _ from 'lodash';
import * as path from 'path';
import { URL } from 'url';
import { Connection } from 'vscode-languageserver';
Expand All @@ -12,16 +9,16 @@ export class CommandRunner {
private connection: Connection;
private context: WorkspaceFolderContext;
private settings: ExtensionSettings;

constructor(connection: Connection, context: WorkspaceFolderContext, settings: ExtensionSettings) {
this.connection = connection;
this.context = context;
this.settings = settings;
}

public async runCommand(
executable: string,
args: string,
args: string,
workingDirectory?: string
): Promise<{
stdout: string,
Expand Down Expand Up @@ -52,7 +49,7 @@ export class CommandRunner {
command = executionEnvironment.wrapContainerArgs(`${executable} ${args}`);
runEnv = undefined
}

const currentWorkingDirectory = workingDirectory ? workingDirectory : decodeURI(new URL(this.context.workspaceFolder.uri).pathname)
const result = await asyncExec(command, {
encoding: 'utf-8',
Expand All @@ -63,4 +60,4 @@ export class CommandRunner {
return result
}
}

0 comments on commit dd7dab4

Please sign in to comment.