Add YAML linting
Change-Id: If210e3d102b085505a550f514141a8fc9f0f809b
This commit is contained in:
parent
185d2bd626
commit
87d99ca508
|
@ -1,2 +1,3 @@
|
||||||
# Unit test / coverage reports
|
# Unit test / coverage reports
|
||||||
.tox/
|
.tox/
|
||||||
|
build/
|
||||||
|
|
15
.zuul.yaml
15
.zuul.yaml
|
@ -9,14 +9,14 @@
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
---
|
||||||
- project:
|
- project:
|
||||||
check:
|
check:
|
||||||
jobs:
|
jobs:
|
||||||
- noop
|
- treasuremap-lint
|
||||||
gate:
|
gate:
|
||||||
jobs:
|
jobs:
|
||||||
- noop
|
- treasuremap-lint
|
||||||
post:
|
post:
|
||||||
jobs:
|
jobs:
|
||||||
- treasuremap-upload-git-mirror
|
- treasuremap-upload-git-mirror
|
||||||
|
@ -27,6 +27,14 @@
|
||||||
nodes:
|
nodes:
|
||||||
- name: ubuntu-bionic
|
- name: ubuntu-bionic
|
||||||
label: ubuntu-bionic
|
label: ubuntu-bionic
|
||||||
|
- job:
|
||||||
|
name: treasuremap-lint
|
||||||
|
description: Lint treasuremap using kubeval
|
||||||
|
nodeset: treasuremap-single-node
|
||||||
|
timeout: 900
|
||||||
|
pre-run:
|
||||||
|
- tools/gate/playbooks/deploy-kubeval.yaml
|
||||||
|
run: tools/gate/playbooks/yaml-lint.yaml
|
||||||
|
|
||||||
- secret:
|
- secret:
|
||||||
name: airshipit-github-secret
|
name: airshipit-github-secret
|
||||||
|
@ -86,4 +94,3 @@
|
||||||
- name: git_mirror_credentials
|
- name: git_mirror_credentials
|
||||||
secret: airshipit-github-secret
|
secret: airshipit-github-secret
|
||||||
pass-to-parent: true
|
pass-to-parent: true
|
||||||
|
|
||||||
|
|
11
Makefile
11
Makefile
|
@ -12,12 +12,16 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
SHELL := /bin/bash
|
||||||
|
BUILD_DIR := build
|
||||||
|
KUBEVAL_BIN := $(BUILD_DIR)/bin
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: docs
|
all: docs
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf doc/build
|
rm -rf doc/build $(BUILD_DIR)
|
||||||
|
|
||||||
.PHONY: docs
|
.PHONY: docs
|
||||||
docs: clean build_docs
|
docs: clean build_docs
|
||||||
|
@ -30,3 +34,8 @@ build_docs:
|
||||||
.PHONY: format
|
.PHONY: format
|
||||||
format:
|
format:
|
||||||
tox -e fmt
|
tox -e fmt
|
||||||
|
|
||||||
|
lint:
|
||||||
|
mkdir -p build
|
||||||
|
./tools/gate/install-kubeval.sh $(BUILD_DIR)
|
||||||
|
./tools/gate/run-lint.sh
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright 2019 AT&T Intellectual Property. All other rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
set -xe
|
||||||
|
|
||||||
|
INSTALL_PREFIX=$1
|
||||||
|
INSTALL_PREFIX=${INSTALL_PREFIX:-'/tmp/kubeval'}
|
||||||
|
KUBEVAL_URL=https://github.com/instrumenta/kubeval/releases/download
|
||||||
|
KUBEVAL_VER=${KUBEVAL_VER:-'0.14.0'}
|
||||||
|
URL="${KUBEVAL_URL}/${KUBEVAL_VER}/kubeval-linux-amd64.tar.gz"
|
||||||
|
|
||||||
|
TMP=$(mktemp -d)
|
||||||
|
pushd $TMP
|
||||||
|
curl -fL $URL | tar -xz
|
||||||
|
install -D -t ${INSTALL_PREFIX}/bin kubeval
|
||||||
|
popd
|
||||||
|
rm -rf $TMP
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
---
|
||||||
|
- hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: Install KubeVal
|
||||||
|
shell: |
|
||||||
|
set -xe
|
||||||
|
./tools/gate/install-kubeval.sh
|
||||||
|
args:
|
||||||
|
chdir: "{{ zuul.project.src_dir }}"
|
||||||
|
become: yes
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Copyright 2019 AT&T Intellectual Property. All other rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
---
|
||||||
|
- hosts: ubuntu-bionic
|
||||||
|
tasks:
|
||||||
|
- name: Lint site
|
||||||
|
shell: |
|
||||||
|
set -xe
|
||||||
|
./tools/gate/run-lint.sh
|
||||||
|
args:
|
||||||
|
chdir: "{{ zuul.project.src_dir }}"
|
||||||
|
become: yes
|
|
@ -0,0 +1,38 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright 2019 AT&T Intellectual Property. All other rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
set -xe
|
||||||
|
|
||||||
|
ROOT=$1
|
||||||
|
KUBEVAL_BIN=${KUBEVAL_BIN:-/tmp/kubeval/bin}
|
||||||
|
PATH=${KUBEVAL_BIN}:$PATH
|
||||||
|
|
||||||
|
EXCLUDE_DIRS=(
|
||||||
|
'*/\.git/*'
|
||||||
|
'*/kustomizeconfig/*'
|
||||||
|
'*/tools/*'
|
||||||
|
)
|
||||||
|
|
||||||
|
EXCLUDE_FILES=(
|
||||||
|
'.zuul.yaml'
|
||||||
|
'kustomization.yaml'
|
||||||
|
)
|
||||||
|
|
||||||
|
function join { local d=$1; shift; printf '%s' "${@/#/$d}"; }
|
||||||
|
|
||||||
|
FILTER="$(join ' -not -path ' ${EXCLUDE_DIRS[*]})"
|
||||||
|
FILTER="$FILTER $(join ' -not -name ' ${EXCLUDE_FILES[*]})"
|
||||||
|
find $ROOT -type f \( -name "*\.yaml" $FILTER \) | xargs -r kubeval
|
Loading…
Reference in New Issue