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 18, 2024
1 parent eb5ce90 commit ec0fad5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@devcontainers/cli",
"description": "Dev Containers CLI",
"version": "0.57.0",
"version": "0.57.1",
"bin": {
"devcontainer": "devcontainer.js"
},
Expand Down
4 changes: 3 additions & 1 deletion src/spec-configuration/containerFeaturesConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,12 @@ 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 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 ec0fad5

Please sign in to comment.