File tree Expand file tree Collapse file tree 13 files changed +255
-0
lines changed
src/azure-cli-persistence
test/azure-cli-persistence Expand file tree Collapse file tree 13 files changed +255
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ This repo contains my custom devcontainer features.
1111| [ github-cli-persistence] ( ./src/github-cli-persistence ) | Avoid extra logins from the Github CLI by preserving the ` ~/.config/gh ` folder across container instances. |
1212| [ terraform-cli-persistence] ( ./src/terraform-cli-persistence ) | Avoid extra logins from the Terraform CLI by preserving the ` ~/.terraform.d ` folder across container instances. |
1313| [ aws-cli-persistence] ( ./src/aws-cli-persistence ) | Avoid extra logins from the AWS CLI by preserving the ` ~/.aws ` folder across container instances. |
14+ | [ azure-cli-persistence] ( ./src/azure-cli-persistence ) | Avoid extra logins from the Azure CLI by preserving the ` ~/.azure ` folder across container instances. |
1415| [ gcloud-cli-persistence] ( ./src/gcloud-cli-persistence ) | Avoid extra logins from the Google Cloud CLI by preserving the ` ~/.config/gcloud ` folder across container instances. |
1516| [ lamdera] ( ./src/lamdera ) | Installs [ Lamdera] ( https://dashboard.lamdera.app/ ) , a type-safe full-stack web-app platform for Elm (v1.1.0 and later). |
1617| [ mount-pnpm-store] ( ./src/mount-pnpm-store ) | Mounts the pnpm store to a volume to share between multiple devcontainers. |
Original file line number Diff line number Diff line change 1+ ## OS and Architecture Support
2+
3+ Architectures: ` amd ` and ` arm `
4+
5+ OS: ` ubuntu ` , ` debian `
6+
7+ Shells: ` bash ` , ` zsh ` , ` fish `
8+
9+ ## Changelog
10+
11+ | Version | Notes |
12+ | ------- | ----------------------------------------------- |
13+ | 0.0.1 | Initial Version |
14+
15+ ## References
16+
17+ - [ stuartleeks/azure-cli-persistence] ( https://github.com/stuartleeks/dev-container-features/tree/main/src/azure-cli-persistence )
Original file line number Diff line number Diff line change 1+
2+ # Azure CLI Persistence (azure-cli-persistence)
3+
4+ Avoid extra logins from the Azure CLI by preserving the ` ~/.azure ` folder across container instances.
5+
6+ ## Example Usage
7+
8+ ``` json
9+ "features" : {
10+ "ghcr.io/joshuanianji/devcontainer-features/azure-cli-persistence:1" : {}
11+ }
12+ ```
13+
14+ ## Options
15+
16+ | Options Id | Description | Type | Default Value |
17+ | -----| -----| -----| -----|
18+
19+
20+ ## OS and Architecture Support
21+
22+ Architectures: ` amd ` and ` arm `
23+
24+ OS: ` ubuntu ` , ` debian `
25+
26+ Shells: ` bash ` , ` zsh ` , ` fish `
27+
28+ ## Changelog
29+
30+ | Version | Notes |
31+ | ------- | ----------------------------------------------- |
32+ | 0.0.1 | Initial Version |
33+
34+ ## References
35+
36+ - [ stuartleeks/azure-cli-persistence] ( https://github.com/stuartleeks/dev-container-features/tree/main/src/azure-cli-persistence )
37+
38+
39+ ---
40+
41+ _ Note: This file was auto-generated from the [ devcontainer-feature.json] ( https://github.com/joshuanianji/devcontainer-features/blob/main/src/azure-cli-persistence/devcontainer-feature.json ) . Add additional notes to a ` NOTES.md ` ._
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " Azure CLI Persistence (forked)" ,
3+ "id" : " azure-cli-persistence-forked" ,
4+ "version" : " 0.0.1" ,
5+ "documentationURL" : " https://github.com/joshuanianji/devcontainer-features/tree/main/src/azure-cli-persistence" ,
6+ "description" : " (fork of stuartleeks): Avoid extra logins from the Azure CLI by preserving the `~/.azure` folder across container instances." ,
7+ "options" : {},
8+ "mounts" : [
9+ {
10+ "source" : " ${devcontainerId}-azure-cli" ,
11+ "target" : " /dc/azure-cli" ,
12+ "type" : " volume"
13+ }
14+ ],
15+ "installsAfter" : [
16+ " ghcr.io/devcontainers/features/azure-cli" ,
17+ " ghcr.io/devcontainers/features/common-utils" ,
18+ " ghcr.io/meaningful-ooo/devcontainer-features/fish"
19+ ],
20+ "onCreateCommand" : {
21+ "azure-cli-persistence-setup" : " /usr/local/share/azure-cli-persistence/scripts/oncreate.sh"
22+ }
23+ }
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ USERNAME=${USERNAME:- ${_REMOTE_USER} }
4+ FEATURE_ID=" azure-cli-persistence"
5+ LIFECYCLE_SCRIPTS_DIR=" /usr/local/share/${FEATURE_ID} /scripts"
6+
7+ set -e
8+
9+ create_cache_dir () {
10+ if [ -d " $1 " ]; then
11+ echo " Cache directory $1 already exists. Skip creation..."
12+ else
13+ echo " Create cache directory $1 ..."
14+ mkdir -p " $1 "
15+ fi
16+
17+ if [ -z " $2 " ]; then
18+ echo " No username provided. Skip chown..."
19+ else
20+ echo " Change owner of $1 to $2 ..."
21+ chown -R " $2 :$2 " " $1 "
22+ fi
23+ }
24+
25+ create_symlink_dir () {
26+ local local_dir=$1
27+ local cache_dir=$2
28+ local username=$3
29+
30+ runuser -u " $username " -- mkdir -p " $( dirname " $local_dir " ) "
31+ runuser -u " $username " -- mkdir -p " $cache_dir "
32+
33+ # if the folder we want to symlink already exists, the ln -s command will create a folder inside the existing folder
34+ if [ -e " $local_dir " ]; then
35+ echo " Moving existing $local_dir folder to $local_dir -old"
36+ mv " $local_dir " " $local_dir -old"
37+ fi
38+
39+ echo " Symlink $local_dir to $cache_dir for $username ..."
40+ runuser -u " $username " -- ln -s " $cache_dir " " $local_dir "
41+ }
42+
43+ create_cache_dir " /dc/azure-cli" " ${USERNAME} "
44+ create_symlink_dir " $_REMOTE_USER_HOME /.azure" " /dc/azure-cli" " ${USERNAME} "
45+
46+ # Set Lifecycle scripts
47+ if [ -f oncreate.sh ]; then
48+ mkdir -p " ${LIFECYCLE_SCRIPTS_DIR} "
49+ cp oncreate.sh " ${LIFECYCLE_SCRIPTS_DIR} /oncreate.sh"
50+ fi
51+
52+ echo " Finished installing $FEATURE_ID "
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ set -e
4+
5+ # if the user is not root, chown /dc/azure-cli to the user
6+ if [ " $( id -u) " != " 0" ]; then
7+ echo " Running oncreate.sh for user $USER "
8+ sudo chown -R " $USER :$USER " /dc/azure-cli
9+ fi
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -e
4+
5+ # This script is the "default" test script for the azure-cli-persistence feature.
6+ # It is not run as a scenario, but is run by other test scripts.
7+
8+ # Optional: Import test library
9+ source dev-container-features-test-lib
10+
11+ # check that `azure --help` works
12+ check " help" bash -c " az help | grep 'usage'"
13+
14+ # check that `.azure` and `/dc/azure-cli` exist under the user (should be node)
15+ check " ~/.azure existence" bash -c " ls -la ~ | grep '.azure'"
16+ check " /dc/azure-cli existence" bash -c " ls -la /dc | grep 'azure-cli'"
17+
18+ # check that the folders are owned by the user
19+ # https://askubuntu.com/a/175060
20+ echo " Checking ownership of ~/.azure and /dc/azure-cli (ensure it is owned by $USER )"
21+
22+ check " ~/.azure owned by user" bash -c " test \" $( stat -c " %U" ~ /.azure) \" = $USER "
23+ check " /dc/azure-cli owned by user" bash -c " test \" $( stat -c " %U" /dc/azure-cli) \" = $USER "
24+
25+ # Report result
26+ reportResults
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -e
4+
5+ # Run default test script (in same folder)
6+ # See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh
7+ ./_default.sh
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -e
4+
5+ source dev-container-features-test-lib
6+
7+ # Run default test script (in same folder)
8+ # See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh
9+ ./_default.sh
Original file line number Diff line number Diff line change 1+ {
2+ "with_node" : {
3+ "image" : " mcr.microsoft.com/devcontainers/javascript-node:1-18" ,
4+ "features" : {
5+ "ghcr.io/devcontainers/features/azure-cli" : {},
6+ "azure-cli-persistence" : {}
7+ }
8+ },
9+ "zsh_shell" : {
10+ "image" : " mcr.microsoft.com/devcontainers/base:debian" ,
11+ "features" : {
12+ "ghcr.io/devcontainers/features/common-utils:2" : {
13+ "configureZshAsDefaultShell" : true
14+ },
15+ "ghcr.io/devcontainers/features/azure-cli" : {},
16+ "azure-cli-persistence" : {}
17+ }
18+ },
19+ "fish_shell" : {
20+ "image" : " mcr.microsoft.com/devcontainers/base:debian" ,
21+ "features" : {
22+ "ghcr.io/meaningful-ooo/devcontainer-features/fish:1" : {},
23+ "ghcr.io/devcontainers/features/azure-cli" : {},
24+ "azure-cli-persistence" : {}
25+ }
26+ },
27+ "root_user" : {
28+ "image" : " mcr.microsoft.com/devcontainers/base:debian" ,
29+ "features" : {
30+ "ghcr.io/devcontainers/features/azure-cli" : {},
31+ "azure-cli-persistence" : {}
32+ },
33+ "remoteUser" : " root"
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments