Unverified Commit 56233fda authored by Prathamesh Zarkar's avatar Prathamesh Zarkar Committed by GitHub

common-utils overwrites .zshrc coming from image built (#1069)

* common-utils overwrites .zshrc coming from image built with common-utils already

* version bumped and added scenario to test the user issue

* cp command failing fix test

* bump version reverted

* fixed the pipeline failures

* discarded diff logic and introduced new one

* Update src/common-utils/main.sh

* instead of overwritting, template file will be appended to existing .zshrc file if INSTALL_OH_MY_ZSH_CONFIG is true

* removed if statement to check .zshrc file exists

* if condition added to check user_rc_file exist

* linter error fixed

* optimize duplication for template_path and user_rc_file logic

---------
Co-authored-by: 's avatarSamruddhi Khandale <samruddhikhandale@github.com>
parent 9b189037
{ {
"id": "common-utils", "id": "common-utils",
"version": "2.4.5", "version": "2.4.6",
"name": "Common Utilities", "name": "Common Utilities",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils",
"description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.", "description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.",
......
...@@ -491,7 +491,6 @@ if [ "${INSTALL_ZSH}" = "true" ]; then ...@@ -491,7 +491,6 @@ if [ "${INSTALL_ZSH}" = "true" ]; then
echo 'source $HOME/.profile' >> "${user_home}/.zprofile" # TODO: Reconsider adding '.profile' to '.zprofile' echo 'source $HOME/.profile' >> "${user_home}/.zprofile" # TODO: Reconsider adding '.profile' to '.zprofile'
chown ${USERNAME}:${group_name} "${user_home}/.zprofile" chown ${USERNAME}:${group_name} "${user_home}/.zprofile"
fi fi
if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then
if [ "${ADJUSTED_ID}" = "rhel" ]; then if [ "${ADJUSTED_ID}" = "rhel" ]; then
global_rc_path="/etc/zshrc" global_rc_path="/etc/zshrc"
...@@ -543,7 +542,8 @@ if [ "${INSTALL_ZSH}" = "true" ]; then ...@@ -543,7 +542,8 @@ if [ "${INSTALL_ZSH}" = "true" ]; then
# Add devcontainer .zshrc template # Add devcontainer .zshrc template
if [ "$INSTALL_OH_MY_ZSH_CONFIG" = "true" ]; then if [ "$INSTALL_OH_MY_ZSH_CONFIG" = "true" ]; then
echo -e "$(cat "${template_path}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${user_rc_file} template_code="$(cat "${template_path}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true"
echo -e "$([ -f "${user_rc_file}" ] && cat "${user_rc_file}")\n${template_code}" > "${user_rc_file}"
sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="devcontainers"/g' ${user_rc_file} sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="devcontainers"/g' ${user_rc_file}
fi fi
......
#!/bin/bash
set -e
# Optional: Import test library
source dev-container-features-test-lib
# Definition specific tests
check "configure-zshrc-without-overwrite" bash -c "grep 'rbenv init -' ~/.zshrc"
# Report result
reportResults
FROM mcr.microsoft.com/devcontainers/ruby:3.2
RUN echo 'eval "$(rbenv init -)"' >> /home/vscode/.zshrc
VERSION='test-version'
DEFINITION_ID='test-id'
VARIANT='test-variant'
GIT_REPOSITORY='test-repository'
GIT_REPOSITORY_RELEASE='test-release'
GIT_REPOSITORY_REVISION='test-revision'
BUILD_TIMESTAMP='test-time'
CONTENTS_URL='test-url'
...@@ -235,6 +235,24 @@ ...@@ -235,6 +235,24 @@
} }
} }
}, },
"devcontainer-ruby-zshrc": {
"build": {
"dockerfile": "Dockerfile"
},
"remoteUser": "vscode",
"features": {
"common-utils": {
"installZsh": true,
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": true,
"installOhMyZsh": true,
"installOhMyZshConfig": true,
"configureZshAsDefaultShell": true
}
}
},
"alpine-base-zsh-default": { "alpine-base-zsh-default": {
"image": "mcr.microsoft.com/devcontainers/base:alpine", "image": "mcr.microsoft.com/devcontainers/base:alpine",
"remoteUser": "vscode", "remoteUser": "vscode",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment