aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-05-29 15:12:54 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-05-30 10:03:03 -0700
commitedbba484918f6de83680a5b29e561fba981e05e9 (patch)
tree9418abacd664e22fe7dde4137d8962825943d168
parentdc396f800b11fc9aa4bae07df268ad51a2740d8b (diff)
downloadconsfigurator-edbba484918f6de83680a5b29e561fba981e05e9.tar.gz
factor out ENSURE-HOST & call it in hostattrs accessors
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--doc/hosts.rst8
-rw-r--r--src/deployment.lisp4
-rw-r--r--src/host.lisp7
-rw-r--r--src/package.lisp1
-rw-r--r--src/property.lisp2
-rw-r--r--src/propspec.lisp2
6 files changed, 19 insertions, 5 deletions
diff --git a/doc/hosts.rst b/doc/hosts.rst
index af5104b..1f8a56c 100644
--- a/doc/hosts.rst
+++ b/doc/hosts.rst
@@ -37,3 +37,11 @@ keyword symbols. The semantics of these attributes are documented here:
- ``:APT.MIRROR``: for hosts running Debian or a Debian derivative, the host's
preferred apt mirror
+
+Host designators
+----------------
+
+A string designates a host with that hostname and no properties. Using
+strings to designate hosts is not valid in all contexts -- some macros and
+properties where it might be useful to pass a string instead of a ``HOST``
+object call ``ENSURE-HOST`` to convert, but this is not done everywhere.
diff --git a/src/deployment.lisp b/src/deployment.lisp
index 226c55d..8f95f3f 100644
--- a/src/deployment.lisp
+++ b/src/deployment.lisp
@@ -156,9 +156,7 @@ The evaluation of PROPERTIES to produce a property application specification
may retrieve existing hostattrs, but should not set any new ones (not to be
confused with how the :HOSTATTRS subroutines of properties in PROPERTIES may
set additional hostattrs)."
- (once-only ((host (if (stringp host)
- `(make-host :hostattrs (list :hostname (list ,host)))
- host)))
+ (once-only ((host `(ensure-host ,host)))
`(deploy-these* ',connections
,host
(let ((*host* (shallow-copy-host ,host)))
diff --git a/src/host.lisp b/src/host.lisp
index a449d3c..50155c8 100644
--- a/src/host.lisp
+++ b/src/host.lisp
@@ -49,6 +49,13 @@
(:documentation
"A host whose :PREPROCESS and :HOSTATTRS subroutines have not been run."))
+(defgeneric ensure-host (host)
+ (:documentation "Return the HOST value designated by HOST.")
+ (:method ((host host))
+ host)
+ (:method ((hostname string))
+ (make-host :hostattrs `(:hostname (,hostname)))))
+
(defmethod shallow-copy-host ((host host))
(make-instance (type-of host)
:hostattrs (copy-list (hostattrs host))
diff --git a/src/package.lisp b/src/package.lisp
index 417267e..90f5608 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -192,6 +192,7 @@
#:hostattrs
#:host-propspec
#:preprocess-host
+ #:ensure-host
#:with-preserve-hostattrs
#:with-replace-hostattrs
diff --git a/src/property.lisp b/src/property.lisp
index c3a6a5d..9fe0c72 100644
--- a/src/property.lisp
+++ b/src/property.lisp
@@ -453,7 +453,7 @@ other than constant values and propapps to property combinators."
this property cannot be applied to this host. E.g. the property will try to
install an apt package but the host is FreeBSD.")
-(defun get-hostattrs (k &optional (host *host*))
+(defun get-hostattrs (k &optional (host *host*) &aux (host (ensure-host host)))
"Retrieve the list of static informational attributes of type KEY.
Called by property :HOSTATTRS, :APPLY and :UNAPPLY subroutines."
diff --git a/src/propspec.lisp b/src/propspec.lisp
index e4e8832..92a73e8 100644
--- a/src/propspec.lisp
+++ b/src/propspec.lisp
@@ -207,7 +207,7 @@ PRINT-OBJECT."))
"Convert a property application specification expression into a property
application specification proper by associating it with a list of ASDF
systems."
- (if systems-supplied-p
+ (if (or systems-supplied-p (not propspec))
(make-instance 'unpreprocessed-propspec
:systems systems :propspec propspec)
(make-instance 'unpreprocessed-propspec :propspec propspec)))