From 0c94eef7be75aa110ddbe6d6b58a0de39c83b713 Mon Sep 17 00:00:00 2001
From: Ian Wienand <iwienand@redhat.com>
Date: Thu, 28 May 2020 16:41:01 +1000
Subject: [PATCH] Revert "dib-lint: use yamllint to parse YAML files"

This reverts commit 6ee2995214ee5512c64244ce0ccc7fda639c2d36 and
e85c2a6f035a016f80de3d5aebc026f28dfb6bc1.

I missed that if you pip install and then run dib-lint, it's not going
to pick up the .yamllint file shipped here.  Thus it gives spurious
errors.

The reason for this was simply better duplicate key detection in yaml
files, which caused us problems with the kernel installs.  However, at
this point it seems just the old "does it load" test from pyyaml will
be enough.

Change-Id: I87a9fc9bb119cfeffad48fc0fa0df31f0181825d
---
 .yamllint                                     | 20 -------------------
 bin/dib-lint                                  | 12 ++++++++++-
 .../dib-run-parts/package-installs.yaml       |  2 +-
 .../elements/growroot/package-installs.yaml   |  2 +-
 .../yum-minimal/package-installs.yaml         |  2 +-
 .../notes/yamllint-c07fd31780ec8d10.yaml      |  5 -----
 requirements.txt                              |  3 +--
 test-requirements.txt                         |  2 ++
 8 files changed, 17 insertions(+), 31 deletions(-)
 delete mode 100644 .yamllint
 delete mode 100644 releasenotes/notes/yamllint-c07fd31780ec8d10.yaml

diff --git a/.yamllint b/.yamllint
deleted file mode 100644
index e31949dcc..000000000
--- a/.yamllint
+++ /dev/null
@@ -1,20 +0,0 @@
-extends: default
-ignore: |
-  .tox
-
-rules:
-  braces:
-    max-spaces-inside: 1
-    level: error
-  brackets:
-    max-spaces-inside: 1
-    level: error
-  document-start: disable
-  empty-lines:
-    max: 1
-    max-end: 2
-  indentation:
-    level: error
-    indent-sequences: consistent
-  line-length: disable
-  truthy: false
diff --git a/bin/dib-lint b/bin/dib-lint
index 5048bc9bf..5cdeb0c2a 100755
--- a/bin/dib-lint
+++ b/bin/dib-lint
@@ -276,7 +276,17 @@ fi
 echo "Checking YAML parsing..."
 for i in $(find $ELEMENTS_DIR -type f -name '*.yaml'); do
     echo "Parsing  $i"
-    yamllint -s -f parsable $i
+    py_check="
+import yaml
+import sys
+try:
+    objs = yaml.safe_load(open('$i'))
+except yaml.parser.ParserError:
+    sys.exit(1)
+"
+    if ! python -c "$py_check"; then
+        error "$i is not a valid YAML file"
+    fi
 done
 echo "Checking pkg-map files..."
 for i in $(find $ELEMENTS_DIR -type f \
diff --git a/diskimage_builder/elements/dib-run-parts/package-installs.yaml b/diskimage_builder/elements/dib-run-parts/package-installs.yaml
index 327cbd245..fbeb930b1 100644
--- a/diskimage_builder/elements/dib-run-parts/package-installs.yaml
+++ b/diskimage_builder/elements/dib-run-parts/package-installs.yaml
@@ -1 +1 @@
-dib-utils:
+dib-utils:
\ No newline at end of file
diff --git a/diskimage_builder/elements/growroot/package-installs.yaml b/diskimage_builder/elements/growroot/package-installs.yaml
index a427345c9..3482d8f68 100644
--- a/diskimage_builder/elements/growroot/package-installs.yaml
+++ b/diskimage_builder/elements/growroot/package-installs.yaml
@@ -1,2 +1,2 @@
 growpart:
-e2fsprogs:
+e2fsprogs:
\ No newline at end of file
diff --git a/diskimage_builder/elements/yum-minimal/package-installs.yaml b/diskimage_builder/elements/yum-minimal/package-installs.yaml
index 3ed6955ef..1b66417cb 100644
--- a/diskimage_builder/elements/yum-minimal/package-installs.yaml
+++ b/diskimage_builder/elements/yum-minimal/package-installs.yaml
@@ -17,4 +17,4 @@ linux-firmware-whence:
 # mirrors the default packages installed in upstream cloud images
 # to facilitate a basic network.
 NetworkManager:
-dhcp-client:
+dhcp-client:
\ No newline at end of file
diff --git a/releasenotes/notes/yamllint-c07fd31780ec8d10.yaml b/releasenotes/notes/yamllint-c07fd31780ec8d10.yaml
deleted file mode 100644
index 6033750ba..000000000
--- a/releasenotes/notes/yamllint-c07fd31780ec8d10.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-fixes:
-  - |
-    A dependency on ``yamllint`` was added because it is now
-    required by dib-lint.
diff --git a/requirements.txt b/requirements.txt
index b8e8eafa0..f4db11840 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -8,6 +8,5 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0
 PyYAML>=3.12 # MIT
 six>=1.10.0 # MIT
 stevedore>=1.20.0 # Apache-2.0
-# NOTE(ianw) in here because dib-lint uses flake8 and yamllint
+# NOTE(ianw) in here because dib-lint uses flake8
 flake8<4.0.0,>=3.6.0 # MIT
-yamllint>=1.23.0
diff --git a/test-requirements.txt b/test-requirements.txt
index 560a57ad5..31ac5c985 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -12,3 +12,5 @@ testrepository>=0.0.18 # Apache-2.0/BSD
 testtools>=2.2.0 # MIT
 
 coverage!=4.4,>=4.0 # Apache-2.0
+
+yamllint>=1.23.0