Skip to content

Commit d6557ff

Browse files
fix: address Copilot review feedback round 6
Addresses review #3737557661: 1. Password note wording: Fixed misleading claim that password is not stored in committed files. Now clarifies it's a dev-only default checked into repo for convenience. 2. MSSQL profile name: Updated docs to match devcontainer.json profile name 'sqlcmd-container (use SQLCMDPASSWORD env var)' 3. workspaceFolder mismatch: Changed from variable-based path to fixed '/workspaces/go-sqlcmd' to match docker-compose.yml mount 4. go.testEnvVars password: Now uses env:SQLCMDPASSWORD instead of hardcoded value, so VS Code tests use same password as container 5. ARM64 architecture support: Added architecture detection for golangci-lint with separate SHA256 checksums for amd64/arm64 6. Alias management: Now uses ~/.bash_aliases.d/ directory instead of overwriting ~/.bash_aliases, preserving user's custom aliases
1 parent 75cec78 commit d6557ff

4 files changed

Lines changed: 42 additions & 19 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,23 @@ ENV PATH="/opt/mssql-tools18/bin:${PATH}"
1616

1717
# Install golangci-lint for code quality
1818
# Download pre-built binary with SHA256 checksum verification (supply chain security)
19+
# Supports both amd64 and arm64 architectures
1920
ARG GOLANGCI_LINT_VERSION=1.64.8
20-
ARG GOLANGCI_LINT_SHA256=b6270687afb143d019f387c791cd2a6f1cb383be9b3124d241ca11bd3ce2e54e
21-
RUN curl -fsSLO "https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_LINT_VERSION}/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz" \
22-
&& echo "${GOLANGCI_LINT_SHA256} golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz" | sha256sum -c - \
23-
&& tar -xzf "golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz" \
24-
&& mv "golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64/golangci-lint" /usr/local/bin/ \
25-
&& rm -rf "golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64" "golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz" \
21+
ARG GOLANGCI_LINT_SHA256_AMD64=b6270687afb143d019f387c791cd2a6f1cb383be9b3124d241ca11bd3ce2e54e
22+
ARG GOLANGCI_LINT_SHA256_ARM64=a6ab58ebcb1c48572622146cdaec2956f56871038a54ed1149f1386e287789a5
23+
RUN ARCH=$(dpkg --print-architecture) \
24+
&& if [ "$ARCH" = "amd64" ]; then \
25+
CHECKSUM="${GOLANGCI_LINT_SHA256_AMD64}"; \
26+
elif [ "$ARCH" = "arm64" ]; then \
27+
CHECKSUM="${GOLANGCI_LINT_SHA256_ARM64}"; \
28+
else \
29+
echo "Unsupported architecture: $ARCH" && exit 1; \
30+
fi \
31+
&& curl -fsSLO "https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_LINT_VERSION}/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-${ARCH}.tar.gz" \
32+
&& echo "${CHECKSUM} golangci-lint-${GOLANGCI_LINT_VERSION}-linux-${ARCH}.tar.gz" | sha256sum -c - \
33+
&& tar -xzf "golangci-lint-${GOLANGCI_LINT_VERSION}-linux-${ARCH}.tar.gz" \
34+
&& mv "golangci-lint-${GOLANGCI_LINT_VERSION}-linux-${ARCH}/golangci-lint" /usr/local/bin/ \
35+
&& rm -rf "golangci-lint-${GOLANGCI_LINT_VERSION}-linux-${ARCH}" "golangci-lint-${GOLANGCI_LINT_VERSION}-linux-${ARCH}.tar.gz" \
2636
&& golangci-lint --version
2737

2838
# Install additional Go tools (pinned versions for reproducibility)

.devcontainer/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ The SQL Server instance is accessible at:
7777
- **Password**: Available via `$SQLCMDPASSWORD` environment variable
7878
- **Database**: `master` (default) or `SqlCmdTest` (created for testing)
7979

80-
> **Note**: The password is set via environment variables and is not stored in any committed files.
81-
> For the default devcontainer setup, the password is `SqlCmd@2025!`.
82-
> When using VS Code's MSSQL extension, copy this value from `$SQLCMDPASSWORD` when prompted.
80+
> **Note**: The SQL Server password for this devcontainer is provided via the `$SQLCMDPASSWORD` environment variable and is a non-production, development-only default.
81+
> For the default devcontainer setup, the password value (`SqlCmd@2025!`) is checked into this repository for convenience; override it via environment variables or Codespaces/CI secrets for non-local use.
82+
> When using VS Code's MSSQL extension, copy the value from `$SQLCMDPASSWORD` when prompted.
8383
8484
### Using the Built-in sqlcmd
8585

@@ -109,7 +109,7 @@ sql-legacy -Q "SELECT 1 AS test"
109109

110110
### VS Code SQL Extension
111111

112-
The MSSQL extension is pre-configured with a connection profile named **"sqlcmd-container"**. Click the SQL Server icon in the Activity Bar to connect.
112+
The MSSQL extension is pre-configured with a connection profile named **"sqlcmd-container (use SQLCMDPASSWORD env var)"**. Click the SQL Server icon in the Activity Bar to connect.
113113

114114
### Connecting from Host Machine Tools
115115

.devcontainer/devcontainer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "go-sqlcmd Development",
33
"dockerComposeFile": "docker-compose.yml",
44
"service": "devcontainer",
5-
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
5+
"workspaceFolder": "/workspaces/go-sqlcmd",
66
"shutdownAction": "stopCompose",
77

88
// Configure tool-specific properties
@@ -26,7 +26,7 @@
2626
"go.testEnvVars": {
2727
"SQLCMDSERVER": "localhost",
2828
"SQLCMDUSER": "sa",
29-
"SQLCMDPASSWORD": "SqlCmd@2025!",
29+
"SQLCMDPASSWORD": "${env:SQLCMDPASSWORD}",
3030
"SQLCMDDATABASE": "master"
3131
},
3232
"mssql.connections": [

.devcontainer/post-create.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ if [ -f ".devcontainer/mssql/setup.sql" ]; then
6363
fi
6464
fi
6565

66-
# Create useful aliases in a dedicated file (safe and idempotent)
66+
# Create useful aliases in a dedicated directory (safe and idempotent)
6767
echo "🔧 Setting up helpful aliases..."
68-
cat > ~/.bash_aliases << 'EOF'
68+
mkdir -p ~/.bash_aliases.d
69+
cat > ~/.bash_aliases.d/go-sqlcmd << 'EOF'
6970
# go-sqlcmd development aliases
7071
alias gtest='go test ./...'
7172
alias gtest-short='go test -short ./...'
@@ -90,11 +91,23 @@ alias test-db='~/bin/sqlcmd -S localhost -U sa -P "$SQLCMDPASSWORD" -C -Q "SELEC
9091
alias rebuild='go build -o ~/bin/sqlcmd ./cmd/modern && echo "Rebuilt sqlcmd"'
9192
EOF
9293

93-
# Ensure .bash_aliases is sourced from .bashrc
94-
if ! grep -q 'source ~/.bash_aliases' ~/.bashrc 2>/dev/null; then
95-
echo '' >> ~/.bashrc
96-
echo '# Source aliases file' >> ~/.bashrc
97-
echo 'if [ -f ~/.bash_aliases ]; then source ~/.bash_aliases; fi' >> ~/.bashrc
94+
# Ensure aliases are sourced from .bashrc
95+
if ! grep -q 'go-sqlcmd aliases' ~/.bashrc 2>/dev/null; then
96+
{
97+
echo ''
98+
echo '# go-sqlcmd aliases'
99+
echo 'if [ -f ~/.bash_aliases ]; then'
100+
echo ' # Source traditional aliases file if present'
101+
echo ' . ~/.bash_aliases'
102+
echo 'fi'
103+
echo ''
104+
echo 'if [ -d ~/.bash_aliases.d ]; then'
105+
echo ' # Source all alias snippets from ~/.bash_aliases.d'
106+
echo ' for f in ~/.bash_aliases.d/*; do'
107+
echo ' [ -r "$f" ] && . "$f"'
108+
echo ' done'
109+
echo 'fi'
110+
} >> ~/.bashrc
98111
fi
99112

100113
echo ""

0 commit comments

Comments
 (0)