diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-05-29 15:12:54 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-05-30 10:03:03 -0700 |
commit | edbba484918f6de83680a5b29e561fba981e05e9 (patch) | |
tree | 9418abacd664e22fe7dde4137d8962825943d168 /src | |
parent | dc396f800b11fc9aa4bae07df268ad51a2740d8b (diff) | |
download | consfigurator-edbba484918f6de83680a5b29e561fba981e05e9.tar.gz |
factor out ENSURE-HOST & call it in hostattrs accessors
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src')
-rw-r--r-- | src/deployment.lisp | 4 | ||||
-rw-r--r-- | src/host.lisp | 7 | ||||
-rw-r--r-- | src/package.lisp | 1 | ||||
-rw-r--r-- | src/property.lisp | 2 | ||||
-rw-r--r-- | src/propspec.lisp | 2 |
5 files changed, 11 insertions, 5 deletions
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))) |