From c3cbcffa39b8e9fd5323967813ef9275ffdeff52 Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Wed, 28 Feb 2024 15:22:20 -0500 Subject: [PATCH 1/7] Formatting [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 236510f..5300def 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # CargoSense/devcontainer-features -🐳 📦 **Reusable features for [Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) and [GitHub Codespaces](https://github.com/features/codespaces).** +🐳 📦 **Reusable Features for [Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) and [GitHub Codespaces](https://github.com/features/codespaces).** > [!TIP] > If you're new to Dev Containers, check out [the VisualStudio Code Dev Containers tutorial](https://code.visualstudio.com/docs/devcontainers/tutorial). From 9fef00ebbf225be455d702acc67f9e2e043c0dfc Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Wed, 28 Feb 2024 15:28:33 -0500 Subject: [PATCH 2/7] Update metadata and README [skip ci] --- src/actionlint/README.md | 2 +- src/actionlint/devcontainer-feature.json | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/actionlint/README.md b/src/actionlint/README.md index b29bc88..3024ade 100644 --- a/src/actionlint/README.md +++ b/src/actionlint/README.md @@ -1,6 +1,6 @@ # actionlint -Install [actionlint](https://github.com/rhysd/actionlint), a static checker for GitHub Actions workflow files. +Install [actionlint](https://github.com/rhysd/actionlint), a static checker for [GitHub Actions](https://github.com/features/actions) workflow files. ## Usage diff --git a/src/actionlint/devcontainer-feature.json b/src/actionlint/devcontainer-feature.json index 103f072..f43a8c9 100644 --- a/src/actionlint/devcontainer-feature.json +++ b/src/actionlint/devcontainer-feature.json @@ -2,6 +2,9 @@ "name": "actionlint", "id": "actionlint", "version": "1.0.0", + "description": "Install actionlint, a static checker for GitHub Actions workflow files.", + "documentationUrl": "https://github.com/CargoSense/devcontainer-features/tree/main/src/actionlint", + "licenseUrl": "https://github.com/CargoSense/devcontainer-features/blob/main/LICENSE", "options": { "version": { "type": "string", From c5e0249485f8ec8f0e0fb61dd6270400627f247d Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Wed, 28 Feb 2024 16:52:42 -0500 Subject: [PATCH 3/7] Add PostgreSQL client feature --- src/postgresql-client/README.md | 21 ++++++++ .../devcontainer-feature.json | 23 +++++++++ src/postgresql-client/install.sh | 50 +++++++++++++++++++ .../postgresql-client/postgresql-client-15.sh | 46 +++++++++++++++++ test/postgresql-client/scenarios.json | 10 ++++ test/postgresql-client/test.sh | 47 +++++++++++++++++ 6 files changed, 197 insertions(+) create mode 100644 src/postgresql-client/README.md create mode 100644 src/postgresql-client/devcontainer-feature.json create mode 100755 src/postgresql-client/install.sh create mode 100755 test/postgresql-client/postgresql-client-15.sh create mode 100644 test/postgresql-client/scenarios.json create mode 100755 test/postgresql-client/test.sh diff --git a/src/postgresql-client/README.md b/src/postgresql-client/README.md new file mode 100644 index 0000000..97b2178 --- /dev/null +++ b/src/postgresql-client/README.md @@ -0,0 +1,21 @@ +# postgresql-client + +Install client and administrative programs for [PostgreSQL](https://www.postgresql.org). + +## Usage + +```json +"features": { + "ghcr.io/CargoSense/devcontainer-features/postgresql-client:1": {} +} +``` + +## Options + +| Option ID | Description | Type | Default Value | +|:--------------|:------------------------------------------|:-------|:--------------| +| `version` | The postgresql-client version to install. | string | `os-provided` | + +## OS Support + +This Feature should work on recent versions of Debian/Ubuntu and Linux distributions using the [apt](https://wiki.debian.org/AptCLI) management tool. diff --git a/src/postgresql-client/devcontainer-feature.json b/src/postgresql-client/devcontainer-feature.json new file mode 100644 index 0000000..e90e45d --- /dev/null +++ b/src/postgresql-client/devcontainer-feature.json @@ -0,0 +1,23 @@ +{ + "name": "PostgreSQL Client", + "id": "postgresql-client", + "version": "1.0.0", + "description": "Install client and administrative programs for PostgreSQL.", + "documentationUrl": "", + "licenseUrl": "https://github.com/CargoSense/devcontainer-features/blob/main/LICENSE", + "options": { + "version": { + "type": "string", + "enum": [ + "15", + "16", + "os-provided" + ], + "default": "os-provided", + "description": "Select or enter a PostgreSQL version." + } + }, + "installsAfter": [ + "ghcr.io/devcontainers/features/common-utils" + ] +} diff --git a/src/postgresql-client/install.sh b/src/postgresql-client/install.sh new file mode 100755 index 0000000..5bfc219 --- /dev/null +++ b/src/postgresql-client/install.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env sh + +set -e + +POSTGRESQL_VERSION="${VERSION:-"os-provided"}" +VERSION_CODENAME="$(sed -nr 's/VERSION_CODENAME=(.+)/\1/p' /etc/os-release)" + +if [ "$(id -u)" -ne 0 ]; then + printf 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +if [ "${POSTGRESQL_VERSION}" = "os-provided" ]; then + apt update --yes + apt install --no-install-recommends --yes postgresql-client + + exit 0 +fi + +curl_installed="" +gpg_installed="" + +if ! type curl >/dev/null 2>&1; then + apt update --yes + apt install --no-install-recommends --yes curl ca-certificates + + curl_installed="true" +fi + +if ! type gpg >/dev/null 2>&1; then + apt update --yes + apt install --no-install-recommends --yes gpg + + gpg_installed="true" +fi + +install -d /usr/share/postgresql-common/pgdg +curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc +sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt '${VERSION_CODENAME}'-pgdg main" > /etc/apt/sources.list.d/pgdg.list' + +apt update --yes +apt install --no-install-recommends --yes postgresql-client-${POSTGRESQL_VERSION} + +if ! [ -z $curl_installed ]; then + apt purge curl --autoremove --yes +fi + +if ! [ -z $gpg_installed ]; then + apt purge gpg --autoremove --yes +fi diff --git a/test/postgresql-client/postgresql-client-15.sh b/test/postgresql-client/postgresql-client-15.sh new file mode 100755 index 0000000..e3f8a4b --- /dev/null +++ b/test/postgresql-client/postgresql-client-15.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# This test file will be executed against an auto-generated devcontainer.json that +# includes the 'postgresql-client' Feature with no options. +# +# For more information, see: https://github.com/devcontainers/cli/blob/main/docs/features/test.md +# +# Eg: +# { +# "image": "<..some-base-image...>", +# "features": { +# "postgresql-client": {} +# }, +# "remoteUser": "root" +# } +# +# Thus, the value of all options will fall back to the default value in the +# Feature's 'devcontainer-feature.json'. +# +# These scripts are run as 'root' by default. Although that can be changed +# with the '--remote-user' flag. +# +# This test can be run with the following command: +# +# devcontainer features test \ +# --features postgresql-client \ +# --remote-user root \ +# --skip-scenarios \ +# --base-image mcr.microsoft.com/devcontainers/base:ubuntu \ +# /path/to/this/repo + +set -e + +# Optional: Import test library bundled with the devcontainer CLI +# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib +# Provides the 'check' and 'reportResults' commands. +source dev-container-features-test-lib + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. Syntax is... +# check