From ab469268b42d8fc8b0a180990be40e925a65935a Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 27 Aug 2021 14:32:16 -0700 Subject: rework PUSHNEW-HOSTATTRS to use EQUAL not EQL & add PUSHNEW-HOSTATTR Previously, PUSHNEW-HOSTATTRS always used EQL to determine whether a hostattr was already pushed, which would give the wrong answer for many common cases. Now default to using EQUAL, and provide a way for the caller to specify the test function. PUSHNEW-HOSTATTRS now takes a list of hostattrs as a single parameter, rather than using &REST, in order to make room for the new :TEST keyword parameter. To mitigate the inconvenience of no longer using &REST, add PUSHNEW-HOSTATTR. Also fix some parameter and function names in docstrings. Signed-off-by: Sean Whitton --- src/property.lisp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/property.lisp') diff --git a/src/property.lisp b/src/property.lisp index 9e517f2..ac66c38 100644 --- a/src/property.lisp +++ b/src/property.lisp @@ -512,19 +512,24 @@ Called by property :HOSTATTRS subroutines." (setf (getf (slot-value *host* 'hostattrs) k) (append vs (get-hostattrs k)))) -(defun pushnew-hostattrs (k &rest vs) - "Push new static informational attributes VS of type KEY. - -Called by property :HOSTATTRS subroutines." +(defun pushnew-hostattr (k v &key (test #'equal)) + "Push new static informational attribute V of type K. +TEST is passed on to PUSHNEW. Called by property :HOSTATTRS subroutines." + (pushnew-hostattrs k (list v) :test test)) + +(defun pushnew-hostattrs (k vs &key (test #'equal)) + "Push new static informational attributes VS of type K. +VS is a list of items. TEST is passed on to PUSHNEW. Called by property +:HOSTATTRS subroutines." (dolist (v (reverse vs)) - (pushnew v (getf (slot-value *host* 'hostattrs) k)))) + (pushnew v (getf (slot-value *host* 'hostattrs) k) :test test))) (defun require-data (iden1 iden2) - "Wrapper around PUSH-HOSTATTRS to indicate that a piece of prerequisite data + "Wrapper around PUSHNEW-HOSTATTR to indicate that a piece of prerequisite data is needed to deploy a property. Called by property :HOSTATTRS subroutines." - (pushnew-hostattrs :data (cons iden1 iden2))) + (pushnew-hostattr :data (cons iden1 iden2))) (defun get-hostname (&optional (host *host*)) "Get the hostname of HOST, defaulting to the host to which properties are -- cgit v1.2.3