Skip to content
This repository was archived by the owner on Jan 12, 2025. It is now read-only.

add yamllint #50

Merged
merged 2 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/yamllint/README.md
Original file line number Diff line number Diff line change
@@ -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`._
20 changes: 20 additions & 0 deletions src/yamllint/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
79 changes: 79 additions & 0 deletions src/yamllint/install.sh
Original file line number Diff line number Diff line change
@@ -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!"
9 changes: 9 additions & 0 deletions test/yamllint/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

source dev-container-features-test-lib

check "yamllint --version" yamllint --version

reportResults