Skip to content

Commit 6345e9d

Browse files
Copilotabdurriq
andcommitted
Increment minor version for all 17 features impacted by user selection refactor
Co-authored-by: abdurriq <[email protected]>
1 parent 79add1a commit 6345e9d

31 files changed

Lines changed: 1864 additions & 438 deletions

.rebase-continue.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
set -e
3+
cd /workspaces/features
4+
git add -A
5+
GIT_EDITOR=true git rebase --continue 2>&1 || true
6+
# Loop to handle remaining conflicts automatically
7+
while [ -d .git/rebase-merge ]; do
8+
echo "=== Checking for conflicts ==="
9+
if grep -rl '<<<<<<< HEAD' src/ test/ scripts/ .gitignore SHARED_CODE.md 2>/dev/null; then
10+
echo "=== Conflicts found, resolving by keeping HEAD ==="
11+
# For each conflicted file, take HEAD version
12+
for f in $(grep -rl '<<<<<<< HEAD' src/ test/ scripts/ .gitignore SHARED_CODE.md 2>/dev/null); do
13+
# Use git checkout --theirs/--ours won't work mid-rebase the way we need
14+
# Instead, strip conflict markers keeping HEAD (ours in rebase = main)
15+
python3 -c "
16+
import re, sys
17+
with open('$f', 'r') as fh:
18+
content = fh.read()
19+
# In rebase, HEAD = the branch being rebased onto (main)
20+
# Remove conflict blocks, keeping HEAD content
21+
pattern = r'<<<<<<<[^\n]*\n(.*?)=======\n.*?>>>>>>>[^\n]*\n'
22+
resolved = re.sub(pattern, r'\1', content, flags=re.DOTALL)
23+
with open('$f', 'w') as fh:
24+
fh.write(resolved)
25+
" 2>/dev/null || echo "Failed to resolve $f"
26+
done
27+
fi
28+
git add -A
29+
GIT_EDITOR=true git rebase --continue 2>&1 || true
30+
done
31+
echo "=== Rebase complete ==="
32+
git log --oneline -5
33+
# Cleanup
34+
rm -f /workspaces/features/.rebase-continue.sh

src/anaconda/common-setup.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
#-------------------------------------------------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See https://github.com/devcontainers/features/blob/main/LICENSE for license information.
5+
#-------------------------------------------------------------------------------------------------------------------------
6+
#
7+
# Helper script for common feature setup tasks, including user selection logic.
8+
# Maintainer: The Dev Container spec maintainers
9+
10+
# Determine the appropriate non-root user
11+
# Usage: determine_user_from_input USERNAME [FALLBACK_USER]
12+
#
13+
# This function resolves the USERNAME variable based on the input value:
14+
# - If USERNAME is "auto" or "automatic", it will detect an existing non-root user
15+
# - If USERNAME is "none" or doesn't exist, it will fall back to root
16+
# - Otherwise, it validates the specified USERNAME exists
17+
#
18+
# Arguments:
19+
# USERNAME - The username input (typically from feature configuration)
20+
# FALLBACK_USER - Optional fallback user when no user is found in automatic mode (defaults to "root")
21+
#
22+
# Returns:
23+
# The resolved username is printed to stdout
24+
#
25+
# Examples:
26+
# USERNAME=$(determine_user_from_input "automatic")
27+
# USERNAME=$(determine_user_from_input "vscode")
28+
# USERNAME=$(determine_user_from_input "auto" "vscode")
29+
#
30+
determine_user_from_input() {
31+
local input_username="${1:-automatic}"
32+
local fallback_user="${2:-root}"
33+
local resolved_username=""
34+
35+
if [ "${input_username}" = "auto" ] || [ "${input_username}" = "automatic" ]; then
36+
# Automatic mode: try to detect an existing non-root user
37+
38+
# First, check if _REMOTE_USER is set and is not root
39+
if [ -n "${_REMOTE_USER:-}" ] && [ "${_REMOTE_USER}" != "root" ]; then
40+
# Verify the user exists before using it
41+
if id -u "${_REMOTE_USER}" > /dev/null 2>&1; then
42+
resolved_username="${_REMOTE_USER}"
43+
else
44+
# _REMOTE_USER doesn't exist, fall through to normal detection
45+
resolved_username=""
46+
fi
47+
fi
48+
49+
# If we didn't resolve via _REMOTE_USER, try to find a non-root user
50+
if [ -z "${resolved_username}" ]; then
51+
# Try to find a non-root user from a list of common usernames
52+
# The list includes: devcontainer, vscode, node, codespace, and the user with UID 1000
53+
local possible_users=("devcontainer" "vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd 2>/dev/null || echo '')")
54+
55+
for current_user in "${possible_users[@]}"; do
56+
# Skip empty entries
57+
if [ -z "${current_user}" ]; then
58+
continue
59+
fi
60+
61+
# Check if user exists
62+
if id -u "${current_user}" > /dev/null 2>&1; then
63+
resolved_username="${current_user}"
64+
break
65+
fi
66+
done
67+
68+
# If no user found, use the fallback
69+
if [ -z "${resolved_username}" ]; then
70+
resolved_username="${fallback_user}"
71+
fi
72+
fi
73+
elif [ "${input_username}" = "none" ]; then
74+
# Explicit "none" means use root
75+
resolved_username="root"
76+
else
77+
# Specific username provided - validate it exists
78+
if id -u "${input_username}" > /dev/null 2>&1; then
79+
resolved_username="${input_username}"
80+
else
81+
# User doesn't exist, fall back to root
82+
resolved_username="root"
83+
fi
84+
fi
85+
86+
echo "${resolved_username}"
87+
}
Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
{
2-
"id": "anaconda",
3-
"version": "1.1.0",
4-
"name": "Anaconda",
5-
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/anaconda",
6-
"options": {
7-
"version": {
8-
"type": "string",
9-
"proposals": [
10-
"latest"
11-
],
12-
"default": "latest",
13-
"description": "Select or enter an anaconda version."
14-
}
15-
},
16-
"containerEnv": {
17-
"CONDA_DIR": "/usr/local/conda",
18-
"PATH": "/usr/local/conda/bin:${PATH}"
19-
},
20-
"customizations": {
21-
"vscode": {
22-
"settings": {
23-
"github.copilot.chat.codeGeneration.instructions": [
24-
{
25-
"text": "This dev container includes Anaconda and the conda package manager pre-installed and available on the `PATH` for data science and Python development. Additional packages installed using Conda will be downloaded from Anaconda or another repository configured by the user. A user can install different versions of Python than the one in this dev container by running a command like: conda install python=3.7"
26-
}
27-
]
28-
}
29-
}
30-
},
31-
"installsAfter": [
32-
"ghcr.io/devcontainers/features/common-utils"
33-
]
2+
"id": "anaconda",
3+
"version": "1.2.0",
4+
"name": "Anaconda",
5+
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/anaconda",
6+
"options": {
7+
"version": {
8+
"type": "string",
9+
"proposals": [
10+
"latest"
11+
],
12+
"default": "latest",
13+
"description": "Select or enter an anaconda version."
14+
}
15+
},
16+
"containerEnv": {
17+
"CONDA_DIR": "/usr/local/conda",
18+
"PATH": "/usr/local/conda/bin:${PATH}"
19+
},
20+
"customizations": {
21+
"vscode": {
22+
"settings": {
23+
"github.copilot.chat.codeGeneration.instructions": [
24+
{
25+
"text": "This dev container includes Anaconda and the conda package manager pre-installed and available on the `PATH` for data science and Python development. Additional packages installed using Conda will be downloaded from Anaconda or another repository configured by the user. A user can install different versions of Python than the one in this dev container by running a command like: conda install python=3.7"
26+
}
27+
]
28+
}
29+
}
30+
},
31+
"installsAfter": [
32+
"ghcr.io/devcontainers/features/common-utils"
33+
]
3434
}

src/conda/common-setup.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
#-------------------------------------------------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See https://github.com/devcontainers/features/blob/main/LICENSE for license information.
5+
#-------------------------------------------------------------------------------------------------------------------------
6+
#
7+
# Helper script for common feature setup tasks, including user selection logic.
8+
# Maintainer: The Dev Container spec maintainers
9+
10+
# Determine the appropriate non-root user
11+
# Usage: determine_user_from_input USERNAME [FALLBACK_USER]
12+
#
13+
# This function resolves the USERNAME variable based on the input value:
14+
# - If USERNAME is "auto" or "automatic", it will detect an existing non-root user
15+
# - If USERNAME is "none" or doesn't exist, it will fall back to root
16+
# - Otherwise, it validates the specified USERNAME exists
17+
#
18+
# Arguments:
19+
# USERNAME - The username input (typically from feature configuration)
20+
# FALLBACK_USER - Optional fallback user when no user is found in automatic mode (defaults to "root")
21+
#
22+
# Returns:
23+
# The resolved username is printed to stdout
24+
#
25+
# Examples:
26+
# USERNAME=$(determine_user_from_input "automatic")
27+
# USERNAME=$(determine_user_from_input "vscode")
28+
# USERNAME=$(determine_user_from_input "auto" "vscode")
29+
#
30+
determine_user_from_input() {
31+
local input_username="${1:-automatic}"
32+
local fallback_user="${2:-root}"
33+
local resolved_username=""
34+
35+
if [ "${input_username}" = "auto" ] || [ "${input_username}" = "automatic" ]; then
36+
# Automatic mode: try to detect an existing non-root user
37+
38+
# First, check if _REMOTE_USER is set and is not root
39+
if [ -n "${_REMOTE_USER:-}" ] && [ "${_REMOTE_USER}" != "root" ]; then
40+
# Verify the user exists before using it
41+
if id -u "${_REMOTE_USER}" > /dev/null 2>&1; then
42+
resolved_username="${_REMOTE_USER}"
43+
else
44+
# _REMOTE_USER doesn't exist, fall through to normal detection
45+
resolved_username=""
46+
fi
47+
fi
48+
49+
# If we didn't resolve via _REMOTE_USER, try to find a non-root user
50+
if [ -z "${resolved_username}" ]; then
51+
# Try to find a non-root user from a list of common usernames
52+
# The list includes: devcontainer, vscode, node, codespace, and the user with UID 1000
53+
local possible_users=("devcontainer" "vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd 2>/dev/null || echo '')")
54+
55+
for current_user in "${possible_users[@]}"; do
56+
# Skip empty entries
57+
if [ -z "${current_user}" ]; then
58+
continue
59+
fi
60+
61+
# Check if user exists
62+
if id -u "${current_user}" > /dev/null 2>&1; then
63+
resolved_username="${current_user}"
64+
break
65+
fi
66+
done
67+
68+
# If no user found, use the fallback
69+
if [ -z "${resolved_username}" ]; then
70+
resolved_username="${fallback_user}"
71+
fi
72+
fi
73+
elif [ "${input_username}" = "none" ]; then
74+
# Explicit "none" means use root
75+
resolved_username="root"
76+
else
77+
# Specific username provided - validate it exists
78+
if id -u "${input_username}" > /dev/null 2>&1; then
79+
resolved_username="${input_username}"
80+
else
81+
# User doesn't exist, fall back to root
82+
resolved_username="root"
83+
fi
84+
fi
85+
86+
echo "${resolved_username}"
87+
}

src/conda/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "conda",
3-
"version": "1.2.5",
3+
"version": "1.2.5",
44
"name": "Conda",
55
"description": "A cross-platform, language-agnostic binary package manager",
66
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/conda",

src/desktop-lite/common-setup.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
#-------------------------------------------------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See https://github.com/devcontainers/features/blob/main/LICENSE for license information.
5+
#-------------------------------------------------------------------------------------------------------------------------
6+
#
7+
# Helper script for common feature setup tasks, including user selection logic.
8+
# Maintainer: The Dev Container spec maintainers
9+
10+
# Determine the appropriate non-root user
11+
# Usage: determine_user_from_input USERNAME [FALLBACK_USER]
12+
#
13+
# This function resolves the USERNAME variable based on the input value:
14+
# - If USERNAME is "auto" or "automatic", it will detect an existing non-root user
15+
# - If USERNAME is "none" or doesn't exist, it will fall back to root
16+
# - Otherwise, it validates the specified USERNAME exists
17+
#
18+
# Arguments:
19+
# USERNAME - The username input (typically from feature configuration)
20+
# FALLBACK_USER - Optional fallback user when no user is found in automatic mode (defaults to "root")
21+
#
22+
# Returns:
23+
# The resolved username is printed to stdout
24+
#
25+
# Examples:
26+
# USERNAME=$(determine_user_from_input "automatic")
27+
# USERNAME=$(determine_user_from_input "vscode")
28+
# USERNAME=$(determine_user_from_input "auto" "vscode")
29+
#
30+
determine_user_from_input() {
31+
local input_username="${1:-automatic}"
32+
local fallback_user="${2:-root}"
33+
local resolved_username=""
34+
35+
if [ "${input_username}" = "auto" ] || [ "${input_username}" = "automatic" ]; then
36+
# Automatic mode: try to detect an existing non-root user
37+
38+
# First, check if _REMOTE_USER is set and is not root
39+
if [ -n "${_REMOTE_USER:-}" ] && [ "${_REMOTE_USER}" != "root" ]; then
40+
# Verify the user exists before using it
41+
if id -u "${_REMOTE_USER}" > /dev/null 2>&1; then
42+
resolved_username="${_REMOTE_USER}"
43+
else
44+
# _REMOTE_USER doesn't exist, fall through to normal detection
45+
resolved_username=""
46+
fi
47+
fi
48+
49+
# If we didn't resolve via _REMOTE_USER, try to find a non-root user
50+
if [ -z "${resolved_username}" ]; then
51+
# Try to find a non-root user from a list of common usernames
52+
# The list includes: devcontainer, vscode, node, codespace, and the user with UID 1000
53+
local possible_users=("devcontainer" "vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd 2>/dev/null || echo '')")
54+
55+
for current_user in "${possible_users[@]}"; do
56+
# Skip empty entries
57+
if [ -z "${current_user}" ]; then
58+
continue
59+
fi
60+
61+
# Check if user exists
62+
if id -u "${current_user}" > /dev/null 2>&1; then
63+
resolved_username="${current_user}"
64+
break
65+
fi
66+
done
67+
68+
# If no user found, use the fallback
69+
if [ -z "${resolved_username}" ]; then
70+
resolved_username="${fallback_user}"
71+
fi
72+
fi
73+
elif [ "${input_username}" = "none" ]; then
74+
# Explicit "none" means use root
75+
resolved_username="root"
76+
else
77+
# Specific username provided - validate it exists
78+
if id -u "${input_username}" > /dev/null 2>&1; then
79+
resolved_username="${input_username}"
80+
else
81+
# User doesn't exist, fall back to root
82+
resolved_username="root"
83+
fi
84+
fi
85+
86+
echo "${resolved_username}"
87+
}

0 commit comments

Comments
 (0)