Skip to content

Commit

Permalink
Coalescing home directory for remoteUser following commons-utils logic
Browse files Browse the repository at this point in the history
  • Loading branch information
prulloac committed Mar 22, 2024
1 parent 05ae9d8 commit a98cb17
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@
"vscode-uri": "^3.0.8",
"yargs": "~17.7.2"
}
}
}
5 changes: 4 additions & 1 deletion src/spec-configuration/containerFeaturesConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,14 @@ function escapeQuotesForShell(input: string) {

export function getFeatureLayers(featuresConfig: FeaturesConfig, containerUser: string, remoteUser: string, isBuildah = false, useBuildKitBuildContexts = false, contentSourceRootPath = '/tmp/build-features') {

const coalesceHomeDir = (user: string) => `$(if [ -d "$(${getEntPasswdShellCommand(user)} | cut -d: -f6)" ]; then echo "$(${getEntPasswdShellCommand(user)} | cut -d: -f6)"; else echo "/home/${user}"; fi)`;

const useSELinuxLabel = process.platform === 'linux' && isBuildah;

const builtinsEnvFile = `${path.posix.join(FEATURES_CONTAINER_TEMP_DEST_FOLDER, 'devcontainer-features.builtin.env')}`;
let result = `RUN \\
echo "_CONTAINER_USER_HOME=$(${getEntPasswdShellCommand(containerUser)} | cut -d: -f6)" >> ${builtinsEnvFile} && \\
echo "_REMOTE_USER_HOME=$(${getEntPasswdShellCommand(remoteUser)} | cut -d: -f6)" >> ${builtinsEnvFile}
echo "_REMOTE_USER_HOME=${coalesceHomeDir(remoteUser)}" >> ${builtinsEnvFile}
`;

Expand Down

0 comments on commit a98cb17

Please sign in to comment.