diff --git a/docs/README.md b/docs/README.md index ab8dd8957..de017688a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -202,7 +202,7 @@ any level (User, Remote, Workspace and/or Folder). the image and setting tag will always pull if the image tag is 'latest', otherwise pull if not locally available. - `ansible.executionEnvironment.volumeMounts`: The setting contains volume mount - information for each entry in the list. Individual entry consist of a + information for each dict entry in the list. Individual entry consists of - `src`: The name of the local volume or path to be mounted within execution environment. - `dest`: The path where the file or directory are mounted in the container. diff --git a/docs/als/settings.md b/docs/als/settings.md index 6d15b8f91..89d482448 100644 --- a/docs/als/settings.md +++ b/docs/als/settings.md @@ -49,6 +49,11 @@ Specify any additional parameters that should be added to the pull command when . Default value: ``""`` +## [`ansible.executionEnvironment.volumeMounts`](#executionEnvironment.volumeMounts) { #executionEnvironment.volumeMounts data-toc-label=executionEnvironment.volumeMounts } +Add a dictionary entry to the array with the volume mount source path (key: 'src'), destination (key: 'dest'), and options (key: 'options') +. Default value: +``""`` + ## [`ansible.executionEnvironment.containerOptions`](#executionEnvironment.containerOptions) { #executionEnvironment.containerOptions data-toc-label=executionEnvironment.containerOptions } Extra parameters passed to the container engine command example: '--net=host' . Default value: @@ -84,11 +89,3 @@ Optional command line arguments to be appended to ansible-lint invocation . Default value: ``""`` -## [`ansible.executionEnvironment.volumeMounts`](#executionEnvironment.volumeMounts) { #executionEnvironment.volumeMounts data-toc-label=executionEnvironment.volumeMounts } - - **src**: The name of the local volume or path to be mounted within execution environment.. Default value: -`""` - - **dest**: The path where the file or directory are mounted in the container.. Default value: -`""` - - **options**: The field is optional, and is a comma-separated list of options, such as ro,Z. Default value: -`""` - diff --git a/package.json b/package.json index b88e30e7e..3226e68a5 100644 --- a/package.json +++ b/package.json @@ -620,26 +620,9 @@ "ansible.executionEnvironment.volumeMounts": { "scope": "resource", "type": "array", - "items": { - "type": "object", - "properties": { - "src": { - "type": "string", - "markdownDescription": "The name of the local volume or path to be mounted within execution environment.", - "order": 6 - }, - "dest": { - "type": "string", - "markdownDescription": "The path where the file or directory are mounted in the container.", - "order": 7 - }, - "options": { - "type": "string", - "markdownDescription": "The field is optional, and is a comma-separated list of options, such as `ro,Z.`", - "order": 8 - } - } - } + "default": [], + "markdownDescription": "Add a dictionary entry to the array with the volume mount source path (key: 'src'), destination (key: 'dest'), and options (key: 'options')", + "order": 6 } } }, diff --git a/packages/ansible-language-server/src/interfaces/extensionSettings.ts b/packages/ansible-language-server/src/interfaces/extensionSettings.ts index c9d3899d8..615a23cd9 100644 --- a/packages/ansible-language-server/src/interfaces/extensionSettings.ts +++ b/packages/ansible-language-server/src/interfaces/extensionSettings.ts @@ -72,11 +72,7 @@ interface ExecutionEnvironmentSettingsWithDescription extends SettingsEntry { policy: { default: IPullPolicy; description: string }; arguments: { default: string; description: string }; }; - volumeMounts: Array<{ - src: { default: string; description: string }; - dest: { default: string; description: string }; - options: { default: string; description: string }; - }>; + volumeMounts: { default: Array; description: string }; containerOptions: { default: string; description: string }; } @@ -98,11 +94,7 @@ export interface SettingsEntry { | SettingsEntry | string | boolean - | Array<{ - src: { default: string; description: string }; - dest: { default: string; description: string }; - options: { default: string; description: string }; - }>; + | Array; } interface AnsibleSettingsWithDescription extends SettingsEntry { diff --git a/packages/ansible-language-server/src/services/executionEnvironment.ts b/packages/ansible-language-server/src/services/executionEnvironment.ts index 1d8e5b790..09161071a 100644 --- a/packages/ansible-language-server/src/services/executionEnvironment.ts +++ b/packages/ansible-language-server/src/services/executionEnvironment.ts @@ -215,13 +215,9 @@ export class ExecutionEnvironment { ...["-v", `${workspaceFolderPath}:${workspaceFolderPath}`], ); - // TODO: add condition to check file path exists or not for (const mountPath of mountPaths || []) { - // push to array only if mount path is valid - if (mountPath === "" || !fs.existsSync(mountPath)) { - this.connection.console.error( - `Volume mount source path '${mountPath}' does not exist. Ignoring this volume mount entry.`, - ); + // push to array only if mount path isn't an empty string, then let podman produce errors as needed + if (mountPath === "") { continue; } @@ -399,18 +395,6 @@ export class ExecutionEnvironment { const fsSrcPath = volumeMounts.src; const fsDestPath = volumeMounts.dest; const options = volumeMounts.options; - if (fsSrcPath === "" || !fs.existsSync(fsSrcPath)) { - this.connection.console.error( - `Volume mount source path '${fsSrcPath}' does not exist. Ignoring this volume mount entry.`, - ); - continue; - } - if (fsDestPath === "") { - this.connection.console.error( - `Volume mount destination path '${fsDestPath}' not provided. Ignoring this volume mount entry.`, - ); - continue; - } let mountPath = `${fsSrcPath}:${fsDestPath}`; if (options && options !== "") { diff --git a/packages/ansible-language-server/src/services/settingsManager.ts b/packages/ansible-language-server/src/services/settingsManager.ts index 9e635367a..4eb9e87a2 100644 --- a/packages/ansible-language-server/src/services/settingsManager.ts +++ b/packages/ansible-language-server/src/services/settingsManager.ts @@ -68,25 +68,11 @@ export class SettingsManager { "Specify any additional parameters that should be added to the pull command when pulling an execution environment from a container registry. e.g. '-–tls-verify=false'", }, }, - volumeMounts: [ - { - src: { - default: "", - description: - "The name of the local volume or path to be mounted within execution environment.", - }, - dest: { - default: "", - description: - "The path where the file or directory are mounted in the container.", - }, - options: { - default: "", - description: - "The field is optional, and is a comma-separated list of options, such as ro,Z", - }, - }, - ], + volumeMounts: { + default: [], + description: + "Add a dictionary entry to the array with the volume mount source path (key: 'src'), destination (key: 'dest'), and options (key: 'options')", + }, containerOptions: { default: "", description: diff --git a/packages/ansible-language-server/test/helper.ts b/packages/ansible-language-server/test/helper.ts index 46fad3955..0ebdf0157 100644 --- a/packages/ansible-language-server/test/helper.ts +++ b/packages/ansible-language-server/test/helper.ts @@ -21,6 +21,7 @@ export const ANSIBLE_COLLECTIONS_FIXTURES_BASE_PATH = path.resolve( "collections", ); export const ANSIBLE_ADJACENT_COLLECTIONS__PATH = path.resolve( + FIXTURES_BASE_PATH, "playbook_adjacent_collection", "collections", ); diff --git a/packages/ansible-language-server/tools/settings-doc-generator.ts b/packages/ansible-language-server/tools/settings-doc-generator.ts index d5bea6706..cc4074aa0 100644 --- a/packages/ansible-language-server/tools/settings-doc-generator.ts +++ b/packages/ansible-language-server/tools/settings-doc-generator.ts @@ -111,6 +111,8 @@ export function toDotNotation( if (value && typeof value === "object") { if (_.isArray(value) && value[0]) { toDotNotation(value[0], res, `${newKey}._array`); // it's an array object, so do it again (to identify array '._array' is added) + } else if (_.isArray(value) && !value[0]) { + res[newKey] = value; // empty array } else { toDotNotation( value as ExtensionSettingsWithDescriptionBase,