From e4aa228679e8207de0456843c5b6b56621383fb4 Mon Sep 17 00:00:00 2001 From: Ryan Merolle Date: Mon, 14 Nov 2022 17:26:41 +0000 Subject: [PATCH 1/2] add yamllint --- src/yamllint/README.md | 26 +++++++++ src/yamllint/devcontainer-feature.json | 20 +++++++ src/yamllint/install.sh | 79 ++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 src/yamllint/README.md create mode 100644 src/yamllint/devcontainer-feature.json create mode 100644 src/yamllint/install.sh diff --git a/src/yamllint/README.md b/src/yamllint/README.md new file mode 100644 index 000000000..56a44c914 --- /dev/null +++ b/src/yamllint/README.md @@ -0,0 +1,26 @@ + +# yamllint (yamllint) + +yamllint is a Python utility / library to sort imports alphabetically, and automatically separated into sections and by type. + +## Example Usage + +```json +"features": { + "ghcr.io/devcontainers-contrib/features/yamllint:1": { + "version": "latest" + } +} +``` + +## Options + +| Options Id | Description | Type | Default Value | +|-----|-----|-----|-----| +| version | Select the yamllint version you would like to install | string | latest | + + + +--- + +_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/devcontainers-contrib/features/blob/main/src/yamllint/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ diff --git a/src/yamllint/devcontainer-feature.json b/src/yamllint/devcontainer-feature.json new file mode 100644 index 000000000..6ad760246 --- /dev/null +++ b/src/yamllint/devcontainer-feature.json @@ -0,0 +1,20 @@ +{ + "name": "yamllint", + "id": "yamllint", + "version": "1.0.1", + "description": "yamllint is a Python utility / library to sort imports alphabetically, and automatically separated into sections and by type.", + "documentationURL": "http://github.com/devcontainers-contrib/features/tree/main/src/yamllint", + "installAfter": [ + "ghcr.io/devcontainers/features/python:latest" + ], + "options": { + "version": { + "type": "string", + "proposals": [ + "latest" + ], + "default": "latest", + "description": "Select the yamllint version you would like to install" + } + } +} \ No newline at end of file diff --git a/src/yamllint/install.sh b/src/yamllint/install.sh new file mode 100644 index 000000000..b7b21b6e3 --- /dev/null +++ b/src/yamllint/install.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +UTIL_VERSION="${VERSION:-"latest"}" + +set -e + +# Clean up +rm -rf /var/lib/apt/lists/* + + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + + +updaterc() { + if [ "${UPDATE_RC}" = "true" ]; then + echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/zsh/zshrc + fi + fi +} + +# settings these will allow us to clean leftovers later on +export PYTHONUSERBASE=/tmp/pip-tmp +export PIP_CACHE_DIR=/tmp/pip-tmp/cache + + +# install python if does not exists +if ! type pip3 > /dev/null 2>&1; then + echo "Installing python3..." + # If the python feature script had option to install pipx without the + # additional tools we would have used that, but since it doesnt + # we have to disable it with INSTALLTOOLS=false and install + # pipx manually later on + + export VERSION="system" + export INSTALLTOOLS="false" + curl -fsSL https://raw.githubusercontent.com/devcontainers/features/main/src/python/install.sh | $SHELL +fi + +# configuring install location +# changing /usr/local/bin as we know it will be in PATH of all users +export PIPX_BIN_DIR="/usr/local/bin" + +if ! type pipx > /dev/null 2>&1; then + echo "Installing pipx..." + export PIPX_HOME=/opt/pipx + mkdir -p ${PIPX_HOME} + chmod -R g+r+w "${PIPX_HOME}" + + pip3 install --disable-pip-version-check --no-cache-dir --user pipx 2>&1 + /tmp/pip-tmp/bin/pipx install --pip-args=--no-cache-dir pipx + PIPX_COMMAND=/tmp/pip-tmp/bin/pipx +else + PIPX_COMMAND=pipx +fi + +if [ "${UTIL_VERSION}" == "latest" ]; then + util_command="yamllint" +else + util_command="yamllint==$UTIL_VERSION" +fi + +echo "Installing yamllint ..." +"${PIPX_COMMAND}" install --system-site-packages --force --pip-args '--no-cache-dir --force-reinstall' ${util_command} + +# cleaning after pip +rm -rf /tmp/pip-tmp + +# Clean up +rm -rf /var/lib/apt/lists/* + +echo "Done!" \ No newline at end of file From a5a87e1c27c3e7365177e07e078377360975131c Mon Sep 17 00:00:00 2001 From: Ryan Merolle Date: Mon, 14 Nov 2022 17:38:14 +0000 Subject: [PATCH 2/2] add yamllint test --- test/yamllint/test.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 test/yamllint/test.sh diff --git a/test/yamllint/test.sh b/test/yamllint/test.sh new file mode 100644 index 000000000..a7e54391c --- /dev/null +++ b/test/yamllint/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +source dev-container-features-test-lib + +check "yamllint --version" yamllint --version + +reportResults \ No newline at end of file