git.fiddlerwoaroof.com
Browse code

Fix parameter and output printers to be more flexible

The parameter and output lists aren't necessarily pairs...

Ed Langley authored on 09/05/2018 20:57:09
Showing 2 changed files
... ...
@@ -88,7 +88,7 @@
88 88
    (%rollback-configuration :initarg :rollback-configuration :reader rollback-configuration)
89 89
    (%drift-information :initarg :drift-information :reader drift-information)
90 90
    (%enable-termination-protection :initarg :enable-termination-protection :reader enable-termination-protection)
91
-   (%parameters :initarg :parameters :reader parameters)))
91
+   (%parameters :initarg :parameters :reader parameters :initform (list))))
92 92
 
93 93
 (defclass timeline ()
94 94
   ((%start-date-time :initarg :start-date-time :reader start-date-time)
... ...
@@ -22,18 +22,24 @@
22 22
          (the-stack (extract-stack aws-result)))
23 23
     the-stack))
24 24
 
25
-(defun print-kvs (formatter stream data)
26
-  (mapcar (destructuring-lambda (((_ k) (__ . v)))
27
-            (declare (ignore _ __))
28
-            (funcall formatter stream k (car v)))
29
-          data))
25
+(defun print-kvs (prefix formatter stream data)
26
+  (let ((key-key (format nil "~aKey" prefix))
27
+        (value-key (format nil "~aValue" prefix)))
28
+    (mapcar (lambda (inp)
29
+              (declare (ignore _ __))
30
+              (let ((k (cadr (assoc key-key inp :test #'equal)))
31
+                    (v (cadr (assoc value-key inp :test #'equal))))
32
+                (funcall formatter stream k v)))
33
+            data)))
30 34
 
31 35
 (defun stack-outputs (the-stack)
32
-  (print-kvs (tagged-kv-formatter "OUTPUT") t
36
+  (print-kvs "Output"
37
+             (tagged-kv-formatter "OUTPUT") t
33 38
              (outputs the-stack)))
34 39
 
35 40
 (defun stack-parameters (the-stack)
36
-  (print-kvs (tagged-kv-formatter "PARAMETERS") t
41
+  (print-kvs "Parameter"
42
+             (tagged-kv-formatter "PARAMETERS") t
37 43
              (parameters the-stack)))
38 44
 
39 45
 (defun lt-format (a b &key &allow-other-keys)