generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chaps-env-vars
- Loading branch information
Showing
65 changed files
with
3,060 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,6 @@ | |
"proposals": ["latest"], | ||
"default": "latest" | ||
} | ||
} | ||
}, | ||
"installsAfter": ["./features/src/base"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
set -e | ||
|
||
VERSION=${AWSCLIVERSION:-"latest"} | ||
source /usr/local/bin/devcontainer-utils | ||
|
||
get_system_architecture | ||
|
||
VERSION="${AWSCLIVERSION:-"latest"}" | ||
|
||
if [[ "${VERSION}" == "latest" ]]; then | ||
ARTEFACT="awscli-exe-linux-$( uname -m ).zip" | ||
ARTEFACT="awscli-exe-linux-$(uname -m).zip" | ||
else | ||
ARTEFACT="awscli-exe-linux-$( uname -m )-${VERSION}.zip" | ||
ARTEFACT="awscli-exe-linux-$(uname -m)-${VERSION}.zip" | ||
fi | ||
|
||
# Install | ||
|
||
apt-get update --yes | ||
|
||
apt-get -y install --no-install-recommends \ | ||
ca-certificates \ | ||
curl \ | ||
unzip | ||
curl --fail-with-body --location "https://awscli.amazonaws.com/${ARTEFACT}" \ | ||
--output "${ARTEFACT}" | ||
|
||
curl https://awscli.amazonaws.com/${ARTEFACT} \ | ||
--output ${ARTEFACT} | ||
|
||
unzip ${ARTEFACT} | ||
unzip "${ARTEFACT}" | ||
|
||
bash ./aws/install | ||
|
||
rm --force --recursive aws ${ARTEFACT} | ||
|
||
# Configure | ||
|
||
echo "complete -C '/usr/local/bin/aws_completer' aws" >> /home/vscode/.bashrc | ||
|
||
# Cleanup | ||
rm --recursive --force aws "${ARTEFACT}" | ||
|
||
rm --force --recursive /var/lib/apt/lists/* | ||
install --owner=vscode --group=vscode --mode=775 "$(dirname "${0}")"/src/home/vscode/.devcontainer/feature-completion/aws.sh /home/vscode/.devcontainer/feature-completion/aws.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
set -e | ||
|
||
VERSION=${AWSSSOCLIVERSION:-"latest"} | ||
source /usr/local/bin/devcontainer-utils | ||
|
||
get_system_architecture | ||
|
||
case "$( uname -m )" in | ||
x86_64) | ||
export ARCHITECTURE="amd64" ;; | ||
aarch64 | armv8*) | ||
export ARCHITECTURE="arm64" ;; | ||
*) | ||
echo "(!) Architecture $( uname -m ) unsupported"; exit 1 ;; | ||
esac | ||
GITHUB_REPOSITORY="synfinatic/aws-sso-cli" | ||
VERSION=${AWSSSOCLIVERSION:-"latest"} | ||
|
||
if [[ "${VERSION}" == "latest" ]]; then | ||
VERSION=$(curl --silent "https://api.github.com/repos/synfinatic/aws-sso-cli/releases/latest" | jq -r '.tag_name') | ||
VERSION_STRIP_V=$(echo "${VERSION}" | sed 's/v//') | ||
get_github_latest_tag "${GITHUB_REPOSITORY}" | ||
VERSION="${GITHUB_LATEST_TAG}" | ||
VERSION_STRIP_V="${GITHUB_LATEST_TAG_STRIP_V}" | ||
else | ||
VERSION_STRIP_V="${VERSION#v}" | ||
fi | ||
|
||
# Install | ||
|
||
curl --location https://github.com/synfinatic/aws-sso-cli/releases/download/${VERSION}/aws-sso-${VERSION_STRIP_V}-linux-${ARCHITECTURE} \ | ||
--output /usr/local/bin/aws-sso | ||
|
||
chmod +x /usr/local/bin/aws-sso | ||
|
||
mkdir --parents /home/vscode/.aws-sso | ||
curl --location https://github.com/${GITHUB_REPOSITORY}/releases/download/${VERSION}/aws-sso-${VERSION_STRIP_V}-linux-${ARCHITECTURE} \ | ||
--output "aws-sso" | ||
|
||
cp $( dirname $0 )/src/home/vscode/.aws-sso/config.yaml /home/vscode/.aws-sso/config.yaml | ||
install --owner=vscode --group=vscode --mode=775 aws-sso /usr/local/bin/aws-sso | ||
|
||
chown --recursive vscode:vscode /home/vscode/.aws-sso | ||
install --directory --owner=vscode --group=vscode /home/vscode/.aws-sso | ||
|
||
# Configure | ||
install --owner=vscode --group=vscode --mode=775 "$(dirname "${0}")"/src/home/vscode/.aws-sso/config.yaml /home/vscode/.aws-sso/config.yaml | ||
|
||
echo "export AWS_SSO_FILE_PASSWORD=\"aws_sso_123456789\"" >> /home/vscode/.bashrc | ||
install --owner=vscode --group=vscode --mode=775 "$(dirname "${0}")"/src/home/vscode/.devcontainer/feature-completion/aws-sso.sh /home/vscode/.devcontainer/feature-completion/aws-sso.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
bash $( dirname $0 )/install-aws-cli.sh | ||
set -e | ||
|
||
bash $( dirname $0 )/install-aws-sso-cli.sh | ||
source /usr/local/bin/devcontainer-utils | ||
|
||
logger "info" "Installing AWS CLI (version: ${AWSCLIVERSION})" | ||
bash "$(dirname "${0}")"/install-aws-cli.sh | ||
|
||
logger "info" "Installing AWS SSO CLI (version: ${AWSSSOCLIVERSION})" | ||
bash "$(dirname "${0}")"/install-aws-sso-cli.sh |
3 changes: 3 additions & 0 deletions
3
.devcontainer/features/src/aws/src/home/vscode/.devcontainer/feature-completion/aws-sso.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
export AWS_SSO_FILE_PASSWORD="aws_sso_123456789" |
3 changes: 3 additions & 0 deletions
3
.devcontainer/features/src/aws/src/home/vscode/.devcontainer/feature-completion/aws.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
complete -C '/usr/local/bin/aws_completer' aws |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"id": "base", | ||
"version": "1.0.0", | ||
"name": "base", | ||
"description": "Base", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": ["GitHub.vscode-pull-request-github", "GitHub.vscode-github-actions", "ms-vsliveshare.vsliveshare"] | ||
} | ||
}, | ||
"installsAfter": ["ghcr.io/devcontainers/features/common-utils"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
source "$(dirname "${0}")"/src/usr/local/bin/devcontainer-utils | ||
|
||
install --owner=vscode --group=vscode --mode=775 "$(dirname "${0}")"/src/usr/local/bin/devcontainer-utils /usr/local/bin/devcontainer-utils | ||
|
||
install --owner=vscode --group=vscode --mode=755 "$(dirname "${0}")"/src/usr/local/etc/vscode-dev-containers/first-run-notice.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt | ||
|
||
install --owner=vscode --group=vscode --mode=755 "$(dirname "${0}")"/src/home/vscode/.oh-my-zsh/custom/themes/devcontainers.zsh-theme /home/vscode/.oh-my-zsh/custom/themes/devcontainers.zsh-theme | ||
|
||
install --directory --owner=vscode --group=vscode /home/vscode/.devcontainer/feature-completion | ||
|
||
cat <<EOF >> /home/vscode/.zshrc | ||
# dev container feature completion scripts | ||
for file in "\${HOME}"/.devcontainer/feature-completion/*.sh; do | ||
source "\${file}" | ||
done | ||
EOF |
51 changes: 51 additions & 0 deletions
51
...tainer/features/src/base/src/home/vscode/.oh-my-zsh/custom/themes/devcontainers.zsh-theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Oh My Zsh! theme - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme | ||
# Source: https://github.com/devcontainers/features/blob/main/src/common-utils/scripts/devcontainers.zsh-theme | ||
|
||
__zsh_prompt() { | ||
local prompt_username | ||
if [ ! -z "${GITHUB_USER}" ]; then | ||
prompt_username="@${GITHUB_USER}" | ||
else | ||
prompt_username="%n" | ||
fi | ||
PROMPT="%{$fg[green]%}${prompt_username} %(?:%{$reset_color%}➜ :%{$fg_bold[red]%}➜ )" # User/exit code arrow | ||
PROMPT+='%{$fg_bold[blue]%}%(5~|%-1~/…/%3~|%4~)%{$reset_color%} ' # cwd | ||
PROMPT+='`\ | ||
if [ "$(git config --get devcontainers-theme.hide-status 2>/dev/null)" != 1 ] && [ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ]; then \ | ||
export BRANCH=$(git --no-optional-locks symbolic-ref --short HEAD 2>/dev/null || git --no-optional-locks rev-parse --short HEAD 2>/dev/null); \ | ||
if [ "${BRANCH}" != "" ]; then \ | ||
echo -n "%{$fg_bold[cyan]%}(%{$fg_bold[red]%}${BRANCH}" \ | ||
&& if [ "$(git config --get devcontainers-theme.show-dirty 2>/dev/null)" = 1 ] && \ | ||
git --no-optional-locks ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \ | ||
echo -n " %{$fg_bold[yellow]%}✗"; \ | ||
fi \ | ||
&& echo -n "%{$fg_bold[cyan]%})%{$reset_color%} "; \ | ||
fi; \ | ||
fi`' | ||
|
||
# Terraform | ||
if command -v terraform &> /dev/null; then | ||
PROMPT+='`\ | ||
terraformVersion=$(terraform -version | grep Terraform | cut -d " " -f 2 | sed "s/v//"); \ | ||
echo -n "[ terraform: %{$fg[blue]%}${terraformVersion}%{$reset_color%} ] " \ | ||
`' | ||
fi | ||
|
||
# AWS SSO | ||
if command -v aws-sso &> /dev/null; then | ||
PROMPT+='`\ | ||
if [[ ${AWS_SSO_PROFILE} == *"development"* || ${AWS_SSO_PROFILE} == *"test"* ]]; then \ | ||
echo -n "[ aws: %{$fg[green]%}${AWS_SSO_PROFILE}@${AWS_DEFAULT_REGION}%{$reset_color%} ] "; \ | ||
elif [[ ${AWS_SSO_PROFILE} == *"preproduction"* ]]; then \ | ||
echo -n "[ aws: %{$fg[yellow]%}${AWS_SSO_PROFILE}@${AWS_DEFAULT_REGION}%{$reset_color%} ] "; \ | ||
elif [[ ${AWS_SSO_PROFILE} == *"production"* ]]; then \ | ||
echo -n "[ aws: %{$fg[red]%}${AWS_SSO_PROFILE}@${AWS_DEFAULT_REGION}%{$reset_color%} ] "; \ | ||
elif [[ ! -z ${AWS_SSO_PROFILE} ]]; then \ | ||
echo -n "[ aws: %{$fg[blue]%}${AWS_SSO_PROFILE}@${AWS_DEFAULT_REGION}%{$reset_color%} ] "; \ | ||
fi`' | ||
fi | ||
|
||
PROMPT+='%{$fg[white]%}$ %{$reset_color%}' | ||
unset -f __zsh_prompt | ||
} | ||
__zsh_prompt |
75 changes: 75 additions & 0 deletions
75
.devcontainer/features/src/base/src/usr/local/bin/devcontainer-utils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env bash | ||
|
||
################################################## | ||
# Environment | ||
################################################## | ||
|
||
export DEBIAN_FRONTEND="noninteractive" | ||
|
||
################################################## | ||
# Function | ||
################################################## | ||
|
||
logger() { | ||
local type="${1}" | ||
local message="${2}" | ||
timestamp=$(date --rfc-3339=seconds) | ||
local timestamp | ||
|
||
case "${type}" in | ||
err | error) | ||
echo "${timestamp} [ERROR] ${message}" | ||
;; | ||
info | information) | ||
echo "${timestamp} [INFO] ${message}" | ||
;; | ||
warn | warning) | ||
echo "${timestamp} [WARN] ${message}" | ||
;; | ||
esac | ||
} | ||
|
||
get_system_architecture() { | ||
systemArchitecture="$(uname -m)" | ||
export systemArchitecture | ||
|
||
case ${systemArchitecture} in | ||
x86_64) | ||
logger "info" "Architecture is x86_64" | ||
export ARCHITECTURE="amd64" | ||
;; | ||
aarch64 | armv8*) | ||
logger "info" "Architecture is aarch64 or armv8" | ||
export ARCHITECTURE="arm64" | ||
;; | ||
*) | ||
logger "error" "Architecture ${systemArchitecture} is not supported" | ||
exit 1 | ||
;; | ||
esac | ||
} | ||
|
||
get_github_latest_tag() { | ||
local repository="${1}" | ||
|
||
repositoryLatestTag="$(curl --silent https://api.github.com/repos/"${repository}"/releases/latest | jq -r '.tag_name')" | ||
export repositoryLatestTag | ||
|
||
repositoryLatestTagStripV=${repositoryLatestTag//v/} | ||
|
||
logger "info" "GitHub latest tag for ${repository} is ${repositoryLatestTag}" | ||
export GITHUB_LATEST_TAG="${repositoryLatestTag}" | ||
export GITHUB_LATEST_TAG_STRIP_V="${repositoryLatestTagStripV}" | ||
} | ||
|
||
apt_install() { | ||
local packages="${1}" | ||
|
||
apt-get update --yes | ||
|
||
apt-get install --yes --no-install-recommends "${packages}" | ||
|
||
apt-get clean | ||
|
||
rm --force --recursive /var/lib/apt/lists/* | ||
} |
5 changes: 5 additions & 0 deletions
5
.devcontainer/features/src/base/src/usr/local/etc/vscode-dev-containers/first-run-notice.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
👋 Welcome! You are using the Modernisation Platform Environments dev container image. | ||
|
||
🆘 If you need help or assistance, please post in #devcontainer (https://moj.enterprise.slack.com/archives/C06DZ4F04JZ) | ||
|
||
🔍 To explore VS Code to its fullest, search using the Command Palette (Cmd/Ctrl + Shift + P or F1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,6 @@ | |
"editor.defaultFormatter": "hashicorp.terraform" | ||
} | ||
} | ||
} | ||
}, | ||
"installsAfter": ["./features/src/base"] | ||
} |
Oops, something went wrong.