Skip to content

Commit b08a8a6

Browse files
added gem feature
1 parent 5fda364 commit b08a8a6

5 files changed

Lines changed: 89 additions & 0 deletions

File tree

src/gem/devcontainer-feature.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "RubyGems",
3+
"id": "gem",
4+
"version": "1.0.0",
5+
"description": "Installs RubyGems using the gem cli",
6+
"options": {
7+
"gem": {
8+
"type": "string",
9+
"description": "Name of gem(s) to install. Can be a single gem, or space/comma separated list of gems"
10+
},
11+
"version": {
12+
"type": "string",
13+
"description": "Specify version of gem to install",
14+
"default": ""
15+
},
16+
"prerelease": {
17+
"type": "boolean",
18+
"description": "Allow prerelease versions of a gem to be installed. (Only for listed gems)",
19+
"default": "false"
20+
}
21+
},
22+
"installsAfter": [
23+
"ghcr.io/devcontainers/features/common-utils"
24+
]
25+
}

src/gem/install.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
: ${GEM:=}
6+
gems=${GEM//,/ }
7+
8+
if [ -z "${gems}" ]; then
9+
echo "No RubyGems specified. Skip installation..."
10+
exit 0
11+
fi
12+
13+
if [ "$(id -u)" -ne 0 ]; then
14+
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
15+
exit 1
16+
fi
17+
18+
export DEBIAN_FRONTEND=noninteractive
19+
20+
args=("$gems")
21+
[ -n "${VERSION:-}" ] && args+=(--version "${VERSION}")
22+
[ -n "${PRERELEASE:-}" ] && args+=(--prerelease)
23+
24+
echo "Installing gems..."
25+
gem install "${args[@]}"
26+
27+
echo "Done!"

test/gem/install-cf-uaac.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Import 'check' command
6+
source dev-container-features-test-lib
7+
8+
check "uaac" uaac version
9+
10+
reportResults

test/gem/scenarios.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"install-cf-uaac": {
3+
"image": "ruby",
4+
"features": {
5+
"gem": {
6+
"gem": "cf-uaac",
7+
"version": "4.14.0",
8+
"prerelease": false
9+
}
10+
}
11+
}
12+
}

test/gem/test.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Import 'check' command
6+
source dev-container-features-test-lib
7+
8+
# Feature-specific tests
9+
no_op() {
10+
echo "gem tests use scenarios.json instead so that we can specify using the ruby image"
11+
}
12+
13+
check "empty test" no_op
14+
15+
reportResults

0 commit comments

Comments
 (0)