├── tests ├── fail │ ├── fail2.yml │ └── fail1.yml ├── test.yml └── ok │ ├── ok1.yml │ └── ok2.yml ├── .gitignore ├── .github ├── dependabot.yml ├── labels.yml ├── workflows │ ├── release-drafter.yml │ ├── repository.yml │ ├── lint.yml │ ├── action_pull_request.yml │ ├── action_schedule.yml │ ├── action_branch.yml │ └── params.yml └── release-drafter.yml ├── .yamllint ├── Dockerfiles ├── Dockerfile └── data │ └── docker-entrypoint.sh ├── LICENSE ├── Makefile └── README.md /tests/fail/fail2.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Makefile.docker 2 | Makefile.lint 3 | -------------------------------------------------------------------------------- /tests/test.yml: -------------------------------------------------------------------------------- 1 | test: 2 | indent1: 3 | indent2: test 4 | -------------------------------------------------------------------------------- /tests/fail/fail1.yml: -------------------------------------------------------------------------------- 1 | --- 2 | test: 3 | hallo: 4 | john: 1 5 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 2 3 | updates: 4 | # Maintain dependencies for GitHub Actions 5 | - package-ecosystem: "github-actions" 6 | directory: "/" 7 | schedule: 8 | interval: "daily" 9 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | 4 | ignore: | 5 | .yamllint 6 | tests/* 7 | 8 | 9 | rules: 10 | truthy: 11 | allowed-values: ['true', 'false'] 12 | check-keys: False 13 | level: error 14 | line-length: disable 15 | -------------------------------------------------------------------------------- /.github/labels.yml: -------------------------------------------------------------------------------- 1 | # The labels in this file are automatically synced with the repository 2 | # using the micnncim/action-label-syncer action. 3 | --- 4 | - name: C-dependency 5 | color: 1abc9c 6 | description: "Category: Dependency" 7 | - name: PR-block 8 | color: 3498db 9 | description: "Pull Request: Do not merge" 10 | - name: PR-merge 11 | color: 3498db 12 | description: "Pull Request: Merge when ready" 13 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Release Drafter 3 | 4 | on: 5 | push: 6 | # branches to consider in the event; optional, defaults to all 7 | branches: 8 | - master 9 | 10 | jobs: 11 | update_release_draft: 12 | runs-on: ubuntu-latest 13 | steps: 14 | # Drafts your next Release notes as Pull Requests are merged into "master" 15 | - uses: release-drafter/release-drafter@v5 16 | with: 17 | publish: true 18 | env: 19 | GITHUB_TOKEN: ${{ secrets.RELEASE_DRAFTER_TOKEN }} 20 | -------------------------------------------------------------------------------- /.github/workflows/repository.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Repository 3 | 4 | on: 5 | push: 6 | branches: 7 | - master 8 | paths: 9 | - .github/labels.yml 10 | 11 | jobs: 12 | labels: 13 | name: Labels 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - name: Checkout code 18 | uses: actions/checkout@v3 19 | 20 | - name: Sync labels 21 | uses: micnncim/action-label-syncer@v1 22 | env: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | with: 25 | manifest: .github/labels.yml 26 | -------------------------------------------------------------------------------- /tests/ok/ok1.yml: -------------------------------------------------------------------------------- 1 | invoice: 34843 2 | date: 2001-01-23 3 | bill-to: 4 | given: Chris 5 | family: Dumars 6 | address: 7 | lines: | 8 | 458 Walkman Dr. 9 | Suite #292 10 | city: Royal Oak 11 | state: MI 12 | postal: 48046 13 | ship-to: id001 14 | product: 15 | - sku: BL394D 16 | quantity: 4 17 | description: Basketball 18 | price: 450.0 19 | - sku: BL4438H 20 | quantity: 1 21 | description: Super Hoop 22 | price: 2392.0 23 | tax: 251.42 24 | total: 4443.52 25 | comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338. 26 | -------------------------------------------------------------------------------- /Dockerfiles/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.9 2 | LABEL \ 3 | maintainer="cytopia " \ 4 | repo="https://github.com/cytopia/docker-yamlfmt" 5 | 6 | ARG VERSION=latest 7 | RUN set -x \ 8 | && apk add --no-cache \ 9 | bash \ 10 | python3 \ 11 | && if [ "${VERSION}" = "latest" ]; then \ 12 | pip3 install --no-cache-dir --no-compile yamlfmt; \ 13 | else \ 14 | pip3 install --no-cache-dir --no-compile yamlfmt==${VERSION}; \ 15 | fi \ 16 | && find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \ 17 | && find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf 18 | 19 | COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh 20 | WORKDIR /data 21 | ENTRYPOINT ["/docker-entrypoint.sh"] 22 | CMD ["--help"] 23 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name-template: '$RESOLVED_VERSION 🌈' 3 | tag-template: '$RESOLVED_VERSION' 4 | version-template: '$MAJOR.$MINOR' 5 | categories: 6 | - title: '🚀 Features' 7 | labels: 8 | - 'feature' 9 | - 'enhancement' 10 | - title: '🐛 Bug Fixes' 11 | labels: 12 | - 'fix' 13 | - 'bugfix' 14 | - 'bug' 15 | - title: '🧰 Maintenance' 16 | label: 'chore' 17 | change-template: '- $TITLE @$AUTHOR (#$NUMBER)' 18 | change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. 19 | version-resolver: 20 | major: 21 | labels: 22 | - 'major' 23 | minor: 24 | labels: 25 | - 'minor' 26 | patch: 27 | labels: 28 | - 'patch' 29 | default: minor 30 | template: | 31 | ## Changes 32 | 33 | $CHANGES 34 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # ------------------------------------------------------------------------------------------------- 4 | # Job Name 5 | # ------------------------------------------------------------------------------------------------- 6 | name: lint 7 | 8 | 9 | # ------------------------------------------------------------------------------------------------- 10 | # When to run 11 | # ------------------------------------------------------------------------------------------------- 12 | on: 13 | # Runs on Pull Requests 14 | pull_request: 15 | 16 | 17 | # ------------------------------------------------------------------------------------------------- 18 | # What to run 19 | # ------------------------------------------------------------------------------------------------- 20 | jobs: 21 | lint: 22 | uses: devilbox/github-actions/.github/workflows/lint-generic.yml@master 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 cytopia 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/action_pull_request.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # ------------------------------------------------------------------------------------------------- 4 | # Job Name 5 | # ------------------------------------------------------------------------------------------------- 6 | name: build 7 | 8 | 9 | # ------------------------------------------------------------------------------------------------- 10 | # When to run 11 | # ------------------------------------------------------------------------------------------------- 12 | on: 13 | pull_request: 14 | 15 | 16 | jobs: 17 | 18 | # (1/2) Determine repository params 19 | params: 20 | uses: ./.github/workflows/params.yml 21 | # Only run for forks (contributor) 22 | if: github.event.pull_request.head.repo.fork 23 | 24 | # (2/2) Build 25 | docker: 26 | needs: [params] 27 | uses: devilbox/github-actions/.github/workflows/docker-name-version-flavour-arch.yml@master 28 | with: 29 | enabled: true 30 | can_deploy: false 31 | matrix: ${{ needs.params.outputs.matrix }} 32 | refs: ${{ needs.params.outputs.refs }} 33 | secrets: 34 | dockerhub_username: "" 35 | dockerhub_password: "" 36 | -------------------------------------------------------------------------------- /.github/workflows/action_schedule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # ------------------------------------------------------------------------------------------------- 4 | # Job Name 5 | # ------------------------------------------------------------------------------------------------- 6 | name: nightly 7 | 8 | 9 | # ------------------------------------------------------------------------------------------------- 10 | # When to run 11 | # ------------------------------------------------------------------------------------------------- 12 | on: 13 | # Runs daily 14 | schedule: 15 | - cron: '0 0 * * *' 16 | 17 | 18 | jobs: 19 | 20 | # (1/2) Determine repository params 21 | params: 22 | uses: ./.github/workflows/params.yml 23 | 24 | # (2/2) Build 25 | docker: 26 | needs: [params] 27 | uses: devilbox/github-actions/.github/workflows/docker-name-version-flavour-arch.yml@master 28 | with: 29 | enabled: true 30 | can_deploy: true 31 | matrix: ${{ needs.params.outputs.matrix }} 32 | refs: ${{ needs.params.outputs.refs }} 33 | secrets: 34 | dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} 35 | dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} 36 | -------------------------------------------------------------------------------- /.github/workflows/action_branch.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # ------------------------------------------------------------------------------------------------- 4 | # Job Name 5 | # ------------------------------------------------------------------------------------------------- 6 | name: build 7 | 8 | 9 | # ------------------------------------------------------------------------------------------------- 10 | # When to run 11 | # ------------------------------------------------------------------------------------------------- 12 | on: 13 | push: 14 | paths: 15 | - 'Makefile' 16 | - 'Dockerfiles/**' 17 | - 'tests/**' 18 | - '.github/workflows/action*.yml' 19 | - '.github/workflows/params.yml' 20 | 21 | jobs: 22 | 23 | # (1/2) Determine repository params 24 | params: 25 | uses: ./.github/workflows/params.yml 26 | 27 | # (2/2) Build 28 | docker: 29 | needs: [params] 30 | uses: devilbox/github-actions/.github/workflows/docker-name-version-flavour-arch.yml@master 31 | with: 32 | enabled: true 33 | can_deploy: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-') }} 34 | matrix: ${{ needs.params.outputs.matrix }} 35 | refs: ${{ needs.params.outputs.refs }} 36 | secrets: 37 | dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} 38 | dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} 39 | -------------------------------------------------------------------------------- /tests/ok/ok2.yml: -------------------------------------------------------------------------------- 1 | cloud: 2 | list: 3 | - key: 1 4 | - key: 1 5 | # Cloud Name: The cloud name must not contain spaces or special 6 | # characters. The name is used for the OpenStack region name. The 7 | # default value for the ICOS Hybrid cloud is RegionTwo. 8 | name: RegionTwo 9 | # Cloud Description 10 | description: ICOS Hybrid - Controller + N Compute Topology - x86 KVM 11 | # Cloud Administrator (admin) User's Password. For the ICOS Hybrid 12 | # cloud, the cloud administrator user's password is contained in the 13 | # password JSON file. It can be overridden here if needed. 14 | password: test 15 | # Cloud Password JSON File. This is required for the ICOS Hybrid cloud. 16 | # Copy the example password file for the ICOS Hybrid cloud located in 17 | # the ICM chef-repo to the deployment folder, rename it, and set the 18 | # password values in the file for the on premise admin user and services 19 | # required for the ICOS Hybrid cloud. Enter the fully qualified path and 20 | # file name of that password file here. 21 | password_file: YOUR_PASSWORD_FILE 22 | # Cloud Database Service Type: db2, mariadb or mysql 23 | database_service_type: db2 24 | # Cloud Messaging Service Type: rabbitmq or qpid 25 | messaging_service_type: rabbitmq 26 | features: 27 | self_service_portal: disabled 28 | platform_resource_scheduler: enabled 29 | icos_hybrid_cloud: enabled 30 | fips_compliance: enabled 31 | -------------------------------------------------------------------------------- /.github/workflows/params.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # ------------------------------------------------------------------------------------------------- 4 | # Job Name 5 | # ------------------------------------------------------------------------------------------------- 6 | name: params 7 | 8 | 9 | # ------------------------------------------------------------------------------------------------- 10 | # Custom Variables 11 | # ------------------------------------------------------------------------------------------------- 12 | env: 13 | MATRIX: >- 14 | [ 15 | { 16 | "NAME": "yf", 17 | "VERSION": ["latest"], 18 | "FLAVOUR": ["latest"], 19 | "ARCH": ["linux/amd64", "linux/386", "linux/arm64", "linux/arm/v7", "linux/arm/v6"] 20 | } 21 | ] 22 | 23 | 24 | # ------------------------------------------------------------------------------------------------- 25 | # When to run 26 | # ------------------------------------------------------------------------------------------------- 27 | on: 28 | workflow_call: 29 | outputs: 30 | matrix: 31 | description: "The determined version matrix" 32 | value: ${{ jobs.params.outputs.matrix }} 33 | refs: 34 | description: "The determined git ref matrix (only during scheduled run)" 35 | value: ${{ jobs.params.outputs.refs }} 36 | 37 | jobs: 38 | params: 39 | runs-on: ubuntu-latest 40 | 41 | outputs: 42 | matrix: ${{ steps.set-matrix.outputs.matrix }} 43 | refs: ${{ steps.set-refs.outputs.matrix }} 44 | 45 | steps: 46 | - name: "[Set-Output] Matrix" 47 | id: set-matrix 48 | run: | 49 | echo "matrix=$( echo '${{ env.MATRIX }}' | jq -M -c )" >> $GITHUB_OUTPUT 50 | 51 | - name: "[Set-Output] Matrix 'Refs' (master branch and latest tag)" 52 | id: set-refs 53 | uses: cytopia/git-ref-matrix-action@v0.1.13 54 | with: 55 | repository_default_branch: master 56 | branches: master 57 | num_latest_tags: 0 58 | if: github.event_name == 'schedule' 59 | 60 | - name: "[DEBUG] Show settings'" 61 | run: | 62 | echo 'Matrix' 63 | echo '--------------------' 64 | echo '${{ steps.set-matrix.outputs.matrix }}' 65 | echo 66 | 67 | echo 'Matrix: Refs' 68 | echo '--------------------' 69 | echo '${{ steps.set-matrix-refs.outputs.matrix }}' 70 | echo 71 | -------------------------------------------------------------------------------- /Dockerfiles/data/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Be strict 4 | set -e 5 | set -u 6 | set -o pipefail 7 | 8 | 9 | ### 10 | ### Globals 11 | ### 12 | ARG_WRITE=0 # yamlfmt arg for -w 13 | ARG_IGNORE= # yamlfmt arg to ignore files found via glob 14 | REG_GLOB='(\*.+)|(.+\*)|(.+\*.+)' # Regex pattern to identify valid glob supported by 'find' 15 | 16 | 17 | ### 18 | ### Show Usage 19 | ### 20 | print_usage() { 21 | >&2 echo "Usage: cytopia/yamlfmt [-h] [-w] [file|pattern]" 22 | >&2 echo 23 | >&2 echo "positional arguments:" 24 | >&2 echo " file file to parse" 25 | >&2 echo " pattern glob pattern for recursive scanning. (e.g.: *\\.yml)" 26 | >&2 echo 27 | >&2 echo "optional arguments:" 28 | >&2 echo " -h, --help show this help message and exit" 29 | >&2 echo " -w, --write write formatted outpout to (source) file instead of stdout" 30 | >&2 echo " -i, --ignore comma separated list of paths to ignore when using glob pattern." 31 | } 32 | 33 | 34 | ### 35 | ### Validate YAML file 36 | ### 37 | ### @param int write file (-w): 1: Yes and 0: No 38 | ### @param string Path to file. 39 | ### @return int Success (0: success, >0: Failure) 40 | ### 41 | _yamlfmt() { 42 | local write="${1}" 43 | local file="${2}" 44 | # shellcheck disable=SC2155 45 | local temp="/tmp/$(basename "${file}")" 46 | local ret=0 47 | 48 | # Overwrite original file 49 | if [ "${write}" -eq "1" ]; then 50 | local cmd="yamlfmt -w ${file}" 51 | echo "${cmd}" 52 | 53 | if ! eval "${cmd}" > "${temp}"; then 54 | ret=$(( ret + 1 )) 55 | fi 56 | 57 | # Diff file 58 | else 59 | local cmd="yamlfmt ${file}" 60 | echo "${cmd}" 61 | 62 | cp -f "${file}" "${temp}" 63 | if ! eval "yamlfmt -w ${temp}"; then 64 | ret=$(( ret + 1 )) 65 | fi 66 | 67 | # Only diff if file is not empty 68 | if [ -s "${temp}" ]; then 69 | if ! diff "${file}" "${temp}"; then 70 | ret=$(( ret + 1 )) 71 | fi 72 | fi 73 | fi 74 | 75 | return "${ret}" 76 | } 77 | 78 | 79 | ### 80 | ### Arguments appended? 81 | ### 82 | if [ "${#}" -gt "0" ]; then 83 | 84 | while [ "${#}" -gt "0" ]; do 85 | case "${1}" in 86 | # Show Help and exit 87 | --help|-h) 88 | print_usage 89 | exit 0 90 | ;; 91 | # Add yamlfmt argument to write to file 92 | --write|-w) 93 | shift 94 | ARG_WRITE=1 95 | ;; 96 | # Ignore glob patterh 97 | -i) 98 | shift 99 | if [ "${#}" -lt "1" ]; then 100 | >&2 echo "Error, -i requires an argument" 101 | exit 1 102 | fi 103 | ARG_IGNORE="${1}" 104 | shift 105 | ;; 106 | # Anything else is handled here 107 | *) 108 | # Case 1/2: Its a file 109 | if [ -f "${1}" ]; then 110 | # Argument check 111 | if [ "${#}" -gt "1" ]; then 112 | >&2 echo "Error, you cannot specify arguments after the file position." 113 | print_usage 114 | exit 1 115 | fi 116 | _yamlfmt "${ARG_WRITE}" "${1}" 117 | exit "${?}" 118 | # Case 2/2: Its a glob 119 | else 120 | # Glob check 121 | if ! echo "${1}" | grep -qE "${REG_GLOB}"; then 122 | >&2 echo "Error, invalid file or wrong glob format. Allowed: '${REG_GLOB}'" 123 | exit 1 124 | fi 125 | # Argument check 126 | if [ "${#}" -gt "1" ]; then 127 | >&2 echo "Error, you cannot specify arguments after the glob position." 128 | print_usage 129 | exit 1 130 | fi 131 | 132 | # Iterate over all files found by glob and jsonlint them 133 | if [ -z "${ARG_IGNORE}" ]; then 134 | find_cmd="find . -name \"${1}\" -type f -print0" 135 | else 136 | find_cmd="find . -not \( -path \"${ARG_IGNORE}\" \) -name \"${1}\" -type f -print0" 137 | fi 138 | 139 | echo "${find_cmd}" 140 | ret=0 141 | while IFS= read -rd '' file; do 142 | if ! _yamlfmt "${ARG_WRITE}" "${file}"; then 143 | ret=$(( ret + 1 )) 144 | fi 145 | done < <(eval "${find_cmd}") 146 | exit "${ret}" 147 | fi 148 | ;; 149 | esac 150 | done 151 | 152 | ### 153 | ### No arguments appended 154 | ### 155 | else 156 | print_usage 157 | exit 0 158 | fi 159 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ifneq (,) 2 | .error This Makefile requires GNU Make. 3 | endif 4 | 5 | # Ensure additional Makefiles are present 6 | MAKEFILES = Makefile.docker Makefile.lint 7 | $(MAKEFILES): URL=https://raw.githubusercontent.com/devilbox/makefiles/master/$(@) 8 | $(MAKEFILES): 9 | @if ! (curl --fail -sS -o $(@) $(URL) || wget -O $(@) $(URL)); then \ 10 | echo "Error, curl or wget required."; \ 11 | echo "Exiting."; \ 12 | false; \ 13 | fi 14 | include $(MAKEFILES) 15 | 16 | # Set default Target 17 | .DEFAULT_GOAL := help 18 | 19 | 20 | # ------------------------------------------------------------------------------------------------- 21 | # Default configuration 22 | # ------------------------------------------------------------------------------------------------- 23 | # Own vars 24 | TAG = latest 25 | 26 | # Makefile.docker overwrites 27 | NAME = yamlfmt 28 | VERSION = latest 29 | IMAGE = cytopia/yamlfmt 30 | FLAVOUR = latest 31 | FILE = Dockerfile 32 | DIR = Dockerfiles 33 | 34 | # Building from master branch: Tag == 'latest' 35 | ifeq ($(strip $(TAG)),latest) 36 | ifeq ($(strip $(VERSION)),latest) 37 | DOCKER_TAG = $(FLAVOUR) 38 | else 39 | ifeq ($(strip $(FLAVOUR)),latest) 40 | DOCKER_TAG = $(VERSION) 41 | else 42 | DOCKER_TAG = $(FLAVOUR)-$(VERSION) 43 | endif 44 | endif 45 | # Building from any other branch or tag: Tag == '' 46 | else 47 | ifeq ($(strip $(FLAVOUR)),latest) 48 | DOCKER_TAG = $(VERSION)-$(TAG) 49 | else 50 | DOCKER_TAG = $(FLAVOUR)-$(VERSION)-$(TAG) 51 | endif 52 | endif 53 | 54 | # Makefile.lint overwrites 55 | FL_IGNORES = .git/,.github/ 56 | SC_IGNORES = .git/,.github/ 57 | JL_IGNORES = .git/,.github/ 58 | 59 | 60 | # ------------------------------------------------------------------------------------------------- 61 | # Default Target 62 | # ------------------------------------------------------------------------------------------------- 63 | .PHONY: help 64 | help: 65 | @echo "lint Lint project files and repository" 66 | @echo 67 | @echo "build [ARCH=...] [TAG=...] Build Docker image" 68 | @echo "rebuild [ARCH=...] [TAG=...] Build Docker image without cache" 69 | @echo "push [ARCH=...] [TAG=...] Push Docker image to Docker hub" 70 | @echo 71 | @echo "manifest-create [ARCHES=...] [TAG=...] Create multi-arch manifest" 72 | @echo "manifest-push [TAG=...] Push multi-arch manifest" 73 | @echo 74 | @echo "test [ARCH=...] Test built Docker image" 75 | @echo 76 | 77 | 78 | # ------------------------------------------------------------------------------------------------- 79 | # Docker Targets 80 | # ------------------------------------------------------------------------------------------------- 81 | .PHONY: build 82 | build: ARGS=--build-arg VERSION=$(VERSION) 83 | build: docker-arch-build 84 | 85 | .PHONY: rebuild 86 | rebuild: ARGS=--build-arg VERSION=$(VERSION) 87 | rebuild: docker-arch-rebuild 88 | 89 | .PHONY: push 90 | push: docker-arch-push 91 | 92 | 93 | # ------------------------------------------------------------------------------------------------- 94 | # Manifest Targets 95 | # ------------------------------------------------------------------------------------------------- 96 | .PHONY: manifest-create 97 | manifest-create: docker-manifest-create 98 | 99 | .PHONY: manifest-push 100 | manifest-push: docker-manifest-push 101 | 102 | 103 | # ------------------------------------------------------------------------------------------------- 104 | # Test Targets 105 | # ------------------------------------------------------------------------------------------------- 106 | .PHONY: test 107 | test: _test-run-ok 108 | test: _test-run-fail 109 | 110 | .PHONY: _test-run-ok 111 | _test-run-ok: 112 | @echo "------------------------------------------------------------" 113 | @echo "- Testing valid yaml files" 114 | @echo "------------------------------------------------------------" 115 | @if ! docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE):$(DOCKER_TAG) ok1.yml ; then \ 116 | echo "Failed"; \ 117 | exit 1; \ 118 | fi; \ 119 | if ! docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE):$(DOCKER_TAG) ok2.yml ; then \ 120 | echo "Failed"; \ 121 | exit 1; \ 122 | fi; \ 123 | if ! docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE):$(DOCKER_TAG) '*.yml' ; then \ 124 | echo "Failed"; \ 125 | exit 1; \ 126 | fi; \ 127 | echo "Success"; 128 | 129 | .PHONY: _test-run-fail 130 | _test-run-fail: 131 | @echo "------------------------------------------------------------" 132 | @echo "- Testing invalid yaml files" 133 | @echo "------------------------------------------------------------" 134 | @if docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/fail:/data $(IMAGE):$(DOCKER_TAG) fail1.yml ; then \ 135 | echo "Failed"; \ 136 | exit 1; \ 137 | fi; \ 138 | if docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/fail:/data $(IMAGE):$(DOCKER_TAG) fail2.yml ; then \ 139 | echo "Failed"; \ 140 | exit 1; \ 141 | fi; \ 142 | if docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/fail:/data $(IMAGE):$(DOCKER_TAG) notexisting.yml ; then \ 143 | echo "Failed"; \ 144 | exit 1; \ 145 | fi; \ 146 | if docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/fail:/data $(IMAGE):$(DOCKER_TAG) '*.yml' ; then \ 147 | echo "Failed"; \ 148 | exit 1; \ 149 | fi; \ 150 | echo "Success"; 151 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker image for `yamlfmt` 2 | 3 | [![Tag](https://img.shields.io/github/tag/cytopia/docker-yamlfmt.svg)](https://github.com/cytopia/docker-yamlfmt/releases) 4 | [![](https://img.shields.io/badge/github-cytopia%2Fdocker--yamlfmt-red.svg)](https://github.com/cytopia/docker-yamlfmt "github.com/cytopia/docker-yamlfmt") 5 | [![License](https://img.shields.io/badge/license-MIT-%233DA639.svg)](https://opensource.org/licenses/MIT) 6 | 7 | [![lint](https://github.com/cytopia/docker-yamlfmt/workflows/lint/badge.svg)](https://github.com/cytopia/docker-yamlfmt/actions?query=workflow%3Alint) 8 | [![build](https://github.com/cytopia/docker-yamlfmt/workflows/build/badge.svg)](https://github.com/cytopia/docker-yamlfmt/actions?query=workflow%3Abuild) 9 | [![nightly](https://github.com/cytopia/docker-yamlfmt/workflows/nightly/badge.svg)](https://github.com/cytopia/docker-yamlfmt/actions?query=workflow%3Anightly) 10 | 11 | 12 | > #### All [#awesome-ci](https://github.com/topics/awesome-ci) Docker images 13 | > 14 | > [ansible-lint][alint-git-lnk] **•** 15 | > [ansible][ansible-git-lnk] **•** 16 | > [awesome-ci][aci-git-lnk] **•** 17 | > [bandit][bandit-git-lnk] **•** 18 | > [black][black-git-lnk] **•** 19 | > [checkmake][cm-git-lnk] **•** 20 | > [eslint][elint-git-lnk] **•** 21 | > [file-lint][flint-git-lnk] **•** 22 | > [gofmt][gfmt-git-lnk] **•** 23 | > [goimports][gimp-git-lnk] **•** 24 | > [golint][glint-git-lnk] **•** 25 | > [jsonlint][jlint-git-lnk] **•** 26 | > [kubeval][kubeval-git-lnk] **•** 27 | > [linkcheck][linkcheck-git-lnk] **•** 28 | > [mypy][mypy-git-lnk] **•** 29 | > [php-cs-fixer][pcsf-git-lnk] **•** 30 | > [phpcbf][pcbf-git-lnk] **•** 31 | > [phpcs][pcs-git-lnk] **•** 32 | > [phplint][plint-git-lnk] **•** 33 | > [pycodestyle][pycs-git-lnk] **•** 34 | > [pydocstyle][pyds-git-lnk] **•** 35 | > [pylint][pylint-git-lnk] **•** 36 | > [terraform-docs][tfdocs-git-lnk] **•** 37 | > [terragrunt-fmt][tgfmt-git-lnk] **•** 38 | > [terragrunt][tg-git-lnk] **•** 39 | > [yamlfmt][yfmt-git-lnk] **•** 40 | > [yamllint][ylint-git-lnk] 41 | 42 | View **[Dockerfiles](https://github.com/cytopia/docker-yamlfmt/blob/master/Dockerfiles/)** on GitHub. 43 | 44 | 45 | **Available Architectures:** `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` 46 | 47 | Tiny Alpine-based dockerized version of [yamlfmt](https://github.com/mmlb/yamlfmt)[1]. 48 | The image is built nightly against the latest stable version of `yamlfmt` and pushed to Dockerhub. 49 | 50 | [1] Official project: https://github.com/mmlb/yamlfmt 51 | 52 | ## :whale: Available Docker image versions 53 | 54 | [![](https://img.shields.io/docker/pulls/cytopia/yamlfmt.svg)](https://hub.docker.com/r/cytopia/yamlfmt) 55 | [![Docker](https://badgen.net/badge/icon/:latest?icon=docker&label=cytopia/yamlfmt)](https://hub.docker.com/r/cytopia/yamlfmt) 56 | 57 | #### Rolling releaess 58 | 59 | The following Docker image tags are rolling releases and are built and updated every night. 60 | 61 | [![nightly](https://github.com/cytopia/docker-yamlfmt/workflows/nightly/badge.svg)](https://github.com/cytopia/docker-yamlfmt/actions?query=workflow%3Anightly) 62 | 63 | 64 | | Docker Tag | Git Ref | Yamlfmt | Flavour | Available Architectures | 65 | |----------------------|-----------|--------------|---------|----------------------------------------------| 66 | | `latest` | master | latest | default | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 67 | 68 | #### Point in time releases 69 | 70 | The following Docker image tags are built once and can be used for reproducible builds. Its version never changes so you will have to update tags in your pipelines from time to time in order to stay up-to-date. 71 | 72 | [![build](https://github.com/cytopia/docker-yamlfmt/workflows/build/badge.svg)](https://github.com/cytopia/docker-yamlfmt/actions?query=workflow%3Abuild) 73 | 74 | 75 | | Docker Tag | Git Ref | Yamlfmt | Flavour | Available Architectures | 76 | |----------------------|--------------|--------------|---------|----------------------------------------------| 77 | | `latest-` | tag: `` | latest | default | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 78 | 79 | Where `` refers to the chosen git tag from this repository. 80 | 81 | 82 | ## :open_file_folder: Docker mounts 83 | 84 | The working directory inside the Docker container is **`/data/`** and should be mounted locally to 85 | the root of your project. 86 | 87 | 88 | ## :computer: Usage 89 | 90 | ```bash 91 | docker run --rm -v $(pwd):/data cytopia/yamlfmt . 92 | ``` 93 | 94 | 95 | 96 | ## :arrows_counterclockwise: Related [#awesome-ci](https://github.com/topics/awesome-ci) projects 97 | 98 | ### Docker images 99 | 100 | Save yourself from installing lot's of dependencies and pick a dockerized version of your favourite 101 | linter below for reproducible local or remote CI tests: 102 | 103 | | GitHub | DockerHub | Type | Description | 104 | |--------|-----------|------|-------------| 105 | | [awesome-ci][aci-git-lnk] | [![aci-hub-img]][aci-hub-lnk] | Basic | Tools for git, file and static source code analysis | 106 | | [file-lint][flint-git-lnk] | [![flint-hub-img]][flint-hub-lnk] | Basic | Baisc source code analysis | 107 | | [linkcheck][linkcheck-git-lnk] | [![linkcheck-hub-img]][flint-hub-lnk] | Basic | Search for URLs in files and validate their HTTP status code | 108 | | [ansible][ansible-git-lnk] | [![ansible-hub-img]][ansible-hub-lnk] | Ansible | Multiple versions and flavours of Ansible | 109 | | [ansible-lint][alint-git-lnk] | [![alint-hub-img]][alint-hub-lnk] | Ansible | Lint Ansible | 110 | | [gofmt][gfmt-git-lnk] | [![gfmt-hub-img]][gfmt-hub-lnk] | Go | Format Go source code **[1]** | 111 | | [goimports][gimp-git-lnk] | [![gimp-hub-img]][gimp-hub-lnk] | Go | Format Go source code **[1]** | 112 | | [golint][glint-git-lnk] | [![glint-hub-img]][glint-hub-lnk] | Go | Lint Go code | 113 | | [eslint][elint-git-lnk] | [![elint-hub-img]][elint-hub-lnk] | Javascript | Lint Javascript code | 114 | | [jsonlint][jlint-git-lnk] | [![jlint-hub-img]][jlint-hub-lnk] | JSON | Lint JSON files **[1]** | 115 | | [kubeval][kubeval-git-lnk] | [![kubeval-hub-img]][kubeval-hub-lnk] | K8s | Lint Kubernetes files | 116 | | [checkmake][cm-git-lnk] | [![cm-hub-img]][cm-hub-lnk] | Make | Lint Makefiles | 117 | | [phpcbf][pcbf-git-lnk] | [![pcbf-hub-img]][pcbf-hub-lnk] | PHP | PHP Code Beautifier and Fixer | 118 | | [phpcs][pcs-git-lnk] | [![pcs-hub-img]][pcs-hub-lnk] | PHP | PHP Code Sniffer | 119 | | [phplint][plint-git-lnk] | [![plint-hub-img]][plint-hub-lnk] | PHP | PHP Code Linter **[1]** | 120 | | [php-cs-fixer][pcsf-git-lnk] | [![pcsf-hub-img]][pcsf-hub-lnk] | PHP | PHP Coding Standards Fixer | 121 | | [bandit][bandit-git-lnk] | [![bandit-hub-img]][bandit-hub-lnk] | Python | A security linter from PyCQA 122 | | [black][black-git-lnk] | [![black-hub-img]][black-hub-lnk] | Python | The uncompromising Python code formatter | 123 | | [mypy][mypy-git-lnk] | [![mypy-hub-img]][mypy-hub-lnk] | Python | Static source code analysis | 124 | | [pycodestyle][pycs-git-lnk] | [![pycs-hub-img]][pycs-hub-lnk] | Python | Python style guide checker | 125 | | [pydocstyle][pyds-git-lnk] | [![pyds-hub-img]][pyds-hub-lnk] | Python | Python docstyle checker | 126 | | [pylint][pylint-git-lnk] | [![pylint-hub-img]][pylint-hub-lnk] | Python | Python source code, bug and quality checker | 127 | | [terraform-docs][tfdocs-git-lnk] | [![tfdocs-hub-img]][tfdocs-hub-lnk] | Terraform | Terraform doc generator (TF 0.12 ready) **[1]** | 128 | | [terragrunt][tg-git-lnk] | [![tg-hub-img]][tg-hub-lnk] | Terraform | Terragrunt and Terraform | 129 | | [terragrunt-fmt][tgfmt-git-lnk] | [![tgfmt-hub-img]][tgfmt-hub-lnk] | Terraform | `terraform fmt` for Terragrunt files **[1]** | 130 | | [yamlfmt][yfmt-git-lnk] | [![yfmt-hub-img]][yfmt-hub-lnk] | Yaml | Format Yaml files **[1]** | 131 | | [yamllint][ylint-git-lnk] | [![ylint-hub-img]][ylint-hub-lnk] | Yaml | Lint Yaml files | 132 | 133 | > **[1]** Uses a shell wrapper to add **enhanced functionality** not available by original project. 134 | 135 | [aci-git-lnk]: https://github.com/cytopia/awesome-ci 136 | [aci-hub-img]: https://img.shields.io/docker/pulls/cytopia/awesome-ci.svg 137 | [aci-hub-lnk]: https://hub.docker.com/r/cytopia/awesome-ci 138 | 139 | [flint-git-lnk]: https://github.com/cytopia/docker-file-lint 140 | [flint-hub-img]: https://img.shields.io/docker/pulls/cytopia/file-lint.svg 141 | [flint-hub-lnk]: https://hub.docker.com/r/cytopia/file-lint 142 | 143 | [linkcheck-git-lnk]: https://github.com/cytopia/docker-linkcheck 144 | [linkcheck-hub-img]: https://img.shields.io/docker/pulls/cytopia/linkcheck.svg 145 | [linkcheck-hub-lnk]: https://hub.docker.com/r/cytopia/linkcheck 146 | 147 | [jlint-git-lnk]: https://github.com/cytopia/docker-jsonlint 148 | [jlint-hub-img]: https://img.shields.io/docker/pulls/cytopia/jsonlint.svg 149 | [jlint-hub-lnk]: https://hub.docker.com/r/cytopia/jsonlint 150 | 151 | [ansible-git-lnk]: https://github.com/cytopia/docker-ansible 152 | [ansible-hub-img]: https://img.shields.io/docker/pulls/cytopia/ansible.svg 153 | [ansible-hub-lnk]: https://hub.docker.com/r/cytopia/ansible 154 | 155 | [alint-git-lnk]: https://github.com/cytopia/docker-ansible-lint 156 | [alint-hub-img]: https://img.shields.io/docker/pulls/cytopia/ansible-lint.svg 157 | [alint-hub-lnk]: https://hub.docker.com/r/cytopia/ansible-lint 158 | 159 | [kubeval-git-lnk]: https://github.com/cytopia/docker-kubeval 160 | [kubeval-hub-img]: https://img.shields.io/docker/pulls/cytopia/kubeval.svg 161 | [kubeval-hub-lnk]: https://hub.docker.com/r/cytopia/kubeval 162 | 163 | [gfmt-git-lnk]: https://github.com/cytopia/docker-gofmt 164 | [gfmt-hub-img]: https://img.shields.io/docker/pulls/cytopia/gofmt.svg 165 | [gfmt-hub-lnk]: https://hub.docker.com/r/cytopia/gofmt 166 | 167 | [gimp-git-lnk]: https://github.com/cytopia/docker-goimports 168 | [gimp-hub-img]: https://img.shields.io/docker/pulls/cytopia/goimports.svg 169 | [gimp-hub-lnk]: https://hub.docker.com/r/cytopia/goimports 170 | 171 | [glint-git-lnk]: https://github.com/cytopia/docker-golint 172 | [glint-hub-img]: https://img.shields.io/docker/pulls/cytopia/golint.svg 173 | [glint-hub-lnk]: https://hub.docker.com/r/cytopia/golint 174 | 175 | [elint-git-lnk]: https://github.com/cytopia/docker-eslint 176 | [elint-hub-img]: https://img.shields.io/docker/pulls/cytopia/eslint.svg 177 | [elint-hub-lnk]: https://hub.docker.com/r/cytopia/eslint 178 | 179 | [cm-git-lnk]: https://github.com/cytopia/docker-checkmake 180 | [cm-hub-img]: https://img.shields.io/docker/pulls/cytopia/checkmake.svg 181 | [cm-hub-lnk]: https://hub.docker.com/r/cytopia/checkmake 182 | 183 | [pcbf-git-lnk]: https://github.com/cytopia/docker-phpcbf 184 | [pcbf-hub-img]: https://img.shields.io/docker/pulls/cytopia/phpcbf.svg 185 | [pcbf-hub-lnk]: https://hub.docker.com/r/cytopia/phpcbf 186 | 187 | [pcs-git-lnk]: https://github.com/cytopia/docker-phpcs 188 | [pcs-hub-img]: https://img.shields.io/docker/pulls/cytopia/phpcs.svg 189 | [pcs-hub-lnk]: https://hub.docker.com/r/cytopia/phpcs 190 | 191 | [plint-git-lnk]: https://github.com/cytopia/docker-phplint 192 | [plint-hub-img]: https://img.shields.io/docker/pulls/cytopia/phplint.svg 193 | [plint-hub-lnk]: https://hub.docker.com/r/cytopia/phplint 194 | 195 | [pcsf-git-lnk]: https://github.com/cytopia/docker-php-cs-fixer 196 | [pcsf-hub-img]: https://img.shields.io/docker/pulls/cytopia/php-cs-fixer.svg 197 | [pcsf-hub-lnk]: https://hub.docker.com/r/cytopia/php-cs-fixer 198 | 199 | [bandit-git-lnk]: https://github.com/cytopia/docker-bandit 200 | [bandit-hub-img]: https://img.shields.io/docker/pulls/cytopia/bandit.svg 201 | [bandit-hub-lnk]: https://hub.docker.com/r/cytopia/bandit 202 | 203 | [black-git-lnk]: https://github.com/cytopia/docker-black 204 | [black-hub-img]: https://img.shields.io/docker/pulls/cytopia/black.svg 205 | [black-hub-lnk]: https://hub.docker.com/r/cytopia/black 206 | 207 | [mypy-git-lnk]: https://github.com/cytopia/docker-mypy 208 | [mypy-hub-img]: https://img.shields.io/docker/pulls/cytopia/mypy.svg 209 | [mypy-hub-lnk]: https://hub.docker.com/r/cytopia/mypy 210 | 211 | [pycs-git-lnk]: https://github.com/cytopia/docker-pycodestyle 212 | [pycs-hub-img]: https://img.shields.io/docker/pulls/cytopia/pycodestyle.svg 213 | [pycs-hub-lnk]: https://hub.docker.com/r/cytopia/pycodestyle 214 | 215 | [pyds-git-lnk]: https://github.com/cytopia/docker-pydocstyle 216 | [pyds-hub-img]: https://img.shields.io/docker/pulls/cytopia/pydocstyle.svg 217 | [pyds-hub-lnk]: https://hub.docker.com/r/cytopia/pydocstyle 218 | 219 | [pylint-git-lnk]: https://github.com/cytopia/docker-pylint 220 | [pylint-hub-img]: https://img.shields.io/docker/pulls/cytopia/pylint.svg 221 | [pylint-hub-lnk]: https://hub.docker.com/r/cytopia/pylint 222 | 223 | [tfdocs-git-lnk]: https://github.com/cytopia/docker-terraform-docs 224 | [tfdocs-hub-img]: https://img.shields.io/docker/pulls/cytopia/terraform-docs.svg 225 | [tfdocs-hub-lnk]: https://hub.docker.com/r/cytopia/terraform-docs 226 | 227 | [tg-git-lnk]: https://github.com/cytopia/docker-terragrunt 228 | [tg-hub-img]: https://img.shields.io/docker/pulls/cytopia/terragrunt.svg 229 | [tg-hub-lnk]: https://hub.docker.com/r/cytopia/terragrunt 230 | 231 | [tgfmt-git-lnk]: https://github.com/cytopia/docker-terragrunt-fmt 232 | [tgfmt-hub-img]: https://img.shields.io/docker/pulls/cytopia/terragrunt-fmt.svg 233 | [tgfmt-hub-lnk]: https://hub.docker.com/r/cytopia/terragrunt-fmt 234 | 235 | [yfmt-git-lnk]: https://github.com/cytopia/docker-yamlfmt 236 | [yfmt-hub-img]: https://img.shields.io/docker/pulls/cytopia/yamlfmt.svg 237 | [yfmt-hub-lnk]: https://hub.docker.com/r/cytopia/yamlfmt 238 | 239 | [ylint-git-lnk]: https://github.com/cytopia/docker-yamllint 240 | [ylint-hub-img]: https://img.shields.io/docker/pulls/cytopia/yamllint.svg 241 | [ylint-hub-lnk]: https://hub.docker.com/r/cytopia/yamllint 242 | 243 | 244 | ### Makefiles 245 | 246 | Visit **[cytopia/makefiles](https://github.com/cytopia/makefiles)** for dependency-less, seamless project integration and minimum required best-practice code linting for CI. 247 | The provided Makefiles will only require GNU Make and Docker itself removing the need to install anything else. 248 | 249 | 250 | ## :page_facing_up: License 251 | 252 | 253 | **[MIT License](LICENSE)** 254 | 255 | Copyright (c) 2019 [cytopia](https://github.com/cytopia) 256 | --------------------------------------------------------------------------------