Page MenuHomeDevCentral

D3330.id8564.diff
No OneTemporary

D3330.id8564.diff

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -35,12 +35,10 @@
roles/webserver-core/nginx/files/ocsp-ca-certs.pem \
.git/hooks/pre-commit
-roles/webserver-content/init.sls: webserver-content-index
+webserver-content-index: clean-webserver-content-index roles/webserver-content/init.sls
-webserver-content-index:
- tmpfile=`mktemp /tmp/make-rOPS-generate-webcontent-index.XXXXXX` ; \
- utils/generate-webcontent-index.py > "$$tmpfile" ;\
- ${MV} "$$tmpfile" roles/webserver-content/init.sls
+roles/webserver-content/init.sls:
+ utils/generate-webcontent-index.py > roles/webserver-content/init.sls
roles/webserver-core/nginx/files/ocsp-ca-certs.pem:
utils/generate-ocsp-bundle.sh > roles/webserver-core/nginx/files/ocsp-ca-certs.pem
@@ -48,8 +46,11 @@
.git/hooks/pre-commit:
pre-commit install
-clean-repo:
- ${RM} roles/webserver-content/init.sls .git/hooks/pre-commit
+clean-webserver-content-index:
+ ${RM} roles/webserver-content/init.sls
+
+clean-repo: clean-webserver-content-index
+ ${RM} .git/hooks/pre-commit
${RM} roles/webserver-core/nginx/files/ocsp-ca-certs.pem
# -------------------------------------------------------------
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -73,6 +73,8 @@
E. Units and integration tests are stored in `_tests/`
+F. Resources used by automated tasks are stored in `_resources/`
+
Contribute
----------
diff --git a/_resources/headers/webserver-content-init b/_resources/headers/webserver-content-init
new file mode 100644
--- /dev/null
+++ b/_resources/headers/webserver-content-init
@@ -0,0 +1,11 @@
+# -------------------------------------------------------------
+# Salt — Webserver content
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is auto-generated by running
+# `make webserver-content-index`.
+# </auto-generated>
diff --git a/_tests/Makefile b/_tests/Makefile
--- a/_tests/Makefile
+++ b/_tests/Makefile
@@ -7,6 +7,7 @@
test-bats:
bats scripts/bats/test_edit_acme_dns_accounts.sh
+ bats roles/bats/test_webserver_content.sh
# -------------------------------------------------------------
# Configuration test specific to the primary server
diff --git a/_tests/roles/bats/test_webserver_content.sh b/_tests/roles/bats/test_webserver_content.sh
new file mode 100755
--- /dev/null
+++ b/_tests/roles/bats/test_webserver_content.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bats
+
+SCRIPT="utils/generate-webcontent-index.py"
+INDEX="roles/webserver-content/init.sls"
+
+@test "Ensure webserver-content index is up-to-date" {
+ cd ..
+ run diff -u <($SCRIPT) <(cat $INDEX)
+ [ "$status" -eq 0 ]
+}
diff --git a/roles/webserver-content/init.sls b/roles/webserver-content/init.sls
--- a/roles/webserver-content/init.sls
+++ b/roles/webserver-content/init.sls
@@ -1,10 +1,14 @@
# -------------------------------------------------------------
# Salt — Webserver content
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-# Project: Eglide
-# Created: 2017-11-23
+# Project: Nasqueron
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is auto-generated by running
+# `make webserver-content-index`.
+# </auto-generated>
include:
- .be/dereckson
diff --git a/utils/generate-webcontent-index.py b/utils/generate-webcontent-index.py
--- a/utils/generate-webcontent-index.py
+++ b/utils/generate-webcontent-index.py
@@ -30,6 +30,7 @@
config = {
+ "header": "_resources/headers/webserver-content-init",
"pillar": "pillar/webserver/sites.sls",
"states": "roles/webserver-content/init.sls",
}
@@ -40,8 +41,9 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-def do_update(pillar_file, file_to_update):
- print_header(file_to_update)
+def do_update(header_file, pillar_file, file_to_update):
+ print_file(header_file)
+
print("\ninclude:")
for site in get_sites(pillar_file):
print(" - {}".format(site))
@@ -62,18 +64,17 @@
))
-def print_header(file_to_update):
- with open(file_to_update) as fd:
+def print_file(file_path):
+ with open(file_path) as fd:
for line in fd:
if not line.startswith("#"):
break
print(line, end="")
-
# -------------------------------------------------------------
# Run task
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if __name__ == "__main__":
- do_update(config["pillar"], config["states"])
+ do_update(config["header"], config["pillar"], config["states"])

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 10:04 (14 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2259973
Default Alt Text
D3330.id8564.diff (4 KB)

Event Timeline