Commit c624a110d9a7c1f9a2a57bbad3581cf7af736e34

Thomas de Grivel 2018-07-14T15:52:53

get-specified

diff --git a/core/defs.lisp b/core/defs.lisp
index 13cde8d..8d9eb10 100644
--- a/core/defs.lisp
+++ b/core/defs.lisp
@@ -163,8 +163,8 @@
 
 ;;  Specifying resources
 
-(defgeneric specified-property (resource property))
-(defgeneric (setf specified-property) (value resource property))
+(defgeneric get-specified (resource property))
+(defgeneric (setf get-specified) (value resource property))
 
 (defvar *specification*)
 (defgeneric parse-next-specification (resource spec))
diff --git a/core/host.lisp b/core/host.lisp
index 75fceac..a9a0b24 100644
--- a/core/host.lisp
+++ b/core/host.lisp
@@ -42,11 +42,11 @@
   (setf *host* (localhost)))
 
 (defun host-user (host)
-  (specified-property host :user))
+  (get-specified host :user))
 
 (defun host-connect (host)
   (let* ((id (resource-id host))
-         (locale (specified-property host :locale))
+         (locale (get-specified host :locale))
          (shell (cond ((string-equal (local-hostname) id)
                        (make-shell "/bin/sh"))
                       (:otherwise
diff --git a/core/spec.lisp b/core/spec.lisp
index 88b4750..7198fd6 100644
--- a/core/spec.lisp
+++ b/core/spec.lisp
@@ -20,16 +20,16 @@
 
 ;;  Specified properties, what all specifications amount to.
 
-(defmethod specified-property ((res resource)
-			       (property symbol))
+(defmethod get-specified ((res resource)
+                          (property symbol))
   (let ((value (get-property property (specified-properties res))))
     (if (eq +undefined+ value)
-        (values nil value)
+        (values nil +undefined+)
         value)))
 
-(defmethod (setf specified-property) (value
-				      (res resource)
-				      (property symbol))
+(defmethod (setf get-specified) (value
+                                 (res resource)
+                                 (property symbol))
   (let ((p (specified-properties res)))
     (setf (get-property property p) value)
     (setf (specified-properties res) p)))
@@ -39,7 +39,7 @@
 (defmethod parse-next-specification ((res resource) spec)
   (let ((property (pop spec))
 	(value (pop spec)))
-    (setf (specified-property res property) value)
+    (setf (get-specified res property) value)
     spec))
 
 (defmethod parse-next-specification ((res resource-container) spec)
diff --git a/package.lisp b/package.lisp
index 35e0038..4466baf 100644
--- a/package.lisp
+++ b/package.lisp
@@ -77,7 +77,6 @@
    #:resource
    #:resource-type
    #:specified-properties
-   #:specified-property
    #:sync
    ;;  Resource container
    #:*parent-resource*
@@ -85,6 +84,7 @@
    #:resource-container
    #:with-parent-resource
    ;;  Specification
+   #:get-specified
    #:specify
    #:parse-specification
    #:parse-next-specification
diff --git a/unix/ssh.lisp b/unix/ssh.lisp
index 5de8c8d..2de01c0 100644
--- a/unix/ssh.lisp
+++ b/unix/ssh.lisp
@@ -37,8 +37,8 @@
 
 (defmethod probe-ssh-authorized-key ((res ssh-authorized-key)
                                      (os os-unix))
-  (let* ((spec-type (the string (specified-property res :type)))
-         (spec-pubkey (the string (specified-property res :pubkey)))
+  (let* ((spec-type (the string (get-specified res :type)))
+         (spec-pubkey (the string (get-specified res :pubkey)))
          (user *parent-resource*)
          (home (resource-id (get-probed user :home)))
          (path (str home "/.ssh/authorized_keys"))
@@ -65,14 +65,9 @@
          (ak (str dot-ssh "/authorized_keys"))
          (sh-ak (sh-quote ak))
          (sh-ak-tmp (sh-quote (str ak ".tmp"))))
-    (setf type (specified-property res :type)
-          pubkey (specified-property res :pubkey)
-          name (specified-property res :name))
-    (with-parent-resource *host*
-      (sync (resource 'directory dot-ssh :ensure :present
-                      :mode #o700))
-      (sync (resource 'file ak :ensure :present :mode #o600)))
-    (format t "~&ensure ~S~%" ensure)
+    (setf type (get-specified res :type)
+          pubkey (get-specified res :pubkey)
+          name (get-specified res :name))
     (force-output)
     (when (position ensure '(:absent nil))
       (run "grep -v " (sh-quote pubkey) " " sh-ak " > " sh-ak-tmp)