Skip to content

Commit

Permalink
Merge branch 'main' into chore/ubuntu-24.04
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Nov 2, 2024
2 parents cdde4d1 + 407d6d1 commit 5b354af
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 76 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 5 additions & 8 deletions docs/als/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
`""`

23 changes: 3 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IVolumeMounts>; description: string };
containerOptions: { default: string; description: string };
}

Expand All @@ -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<IVolumeMounts>;
}

interface AnsibleSettingsWithDescription extends SettingsEntry {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 !== "") {
Expand Down
24 changes: 5 additions & 19 deletions packages/ansible-language-server/src/services/settingsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions packages/ansible-language-server/test/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5b354af

Please sign in to comment.