generated from devcontainers/feature-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
92 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "Library - GitHub", | ||
"id": "lib-github", | ||
"version": "1.0.0", | ||
"description": "A feature that contains utilities to fetch releases from GitHub", | ||
"keywords": ["library"], | ||
"options": { | ||
"baseDir": { | ||
"type": "string", | ||
"default": "/usr/share/phorcys-devcontainer-libraries", | ||
"description": "Select the base directory where the library should be installed" | ||
} | ||
}, | ||
|
||
"installsAfter": [ | ||
"ghcr.io/devcontainers/features/common-utils" | ||
], | ||
|
||
"dependsOn": { | ||
"ghcr.io/phorcys420/devcontainer-features/lib-common:1": {} | ||
} | ||
} |
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,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
FEATURE_NAME="github" | ||
echo "Activating feature '$FEATURE_NAME'" | ||
|
||
# Define the base directory where the feature libraries are stored | ||
BASE_DIR=${BASEDIR:-"/usr/share/phorcys-devcontainer-libraries"} | ||
|
||
find /usr/share/phorcys-devcontainer-libraries/common | ||
|
||
# Source lib-common feature | ||
source "$BASE_DIR/common/1/main.sh" | ||
|
||
# Grab current feature version and split it in parts | ||
VERSION=$(getFeatureVersion) | ||
VERSION_PARTS=($(getVersionParts "$VERSION")) | ||
|
||
# Define the installation directory for the current feature and the current feature version | ||
FEATURE_DIR="$BASE_DIR/$FEATURE_NAME" | ||
INSTALL_DIR="$FEATURE_DIR/$VERSION" | ||
|
||
# Create directory for current feature version | ||
echo "[$FEATURE_NAME] [+] Installing library to $INSTALL_DIR" | ||
mkdir --parents "$INSTALL_DIR" | ||
cp --recursive src/. "$INSTALL_DIR" | ||
|
||
# Make links to each subversion (e.g if version is 1.0.0, then link to 1.0 and 1) and "current" | ||
SUBFOLDERS=( | ||
"${VERSION_PARTS[0]}.${VERSION_PARTS[1]}" # 1.0 | ||
"${VERSION_PARTS[0]}" # 1 | ||
"current" | ||
) | ||
|
||
for SUBFOLDER in "${SUBFOLDERS[@]}" | ||
do | ||
ln --symbolic --force "$INSTALL_DIR" "$FEATURE_DIR/$SUBFOLDER" | ||
done |
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,17 @@ | ||
#!/bin/bash | ||
|
||
getRelease() { | ||
REPOSITORY=$1 | ||
TAG=${2:-latest} | ||
|
||
if [ $TAG = "latest" ]; then | ||
RELEASE_API_URL="https://api.github.com/repos/$REPOSITORY/releases/latest" | ||
else | ||
RELEASE_API_URL="https://api.github.com/repos/$REPOSITORY/releases/tags/$TAG" | ||
fi | ||
|
||
curl "$RELEASE_API_URL" --silent --show-error | ||
} | ||
|
||
# Check for necessary packages | ||
checkPackages curl jq |
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 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Optional: Import test library bundled with the devcontainer CLI | ||
source dev-container-features-test-lib | ||
|
||
check "Library folder exists" test -d "/usr/share/phorcys-devcontainer-libraries/github" | ||
|
||
# Report results | ||
# If any of the checks above exited with a non-zero exit code, the test will fail. | ||
reportResults |