From aa5205529059f177db2f07e88b4fc3c4639618d1 Mon Sep 17 00:00:00 2001 From: James Adams Date: Mon, 11 Jun 2018 17:30:09 +0100 Subject: [PATCH] ncm-sysconfig: Update and clarify schema * Break apart schema into sub-types for clarification * Disallow empty values * Make use of schema in tests * Add annotations based on paraphrased description from pod. --- .../main/pan/components/sysconfig/schema.pan | 26 ++++++++++++++++--- .../src/test/resources/configure.pan | 2 ++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ncm-sysconfig/src/main/pan/components/sysconfig/schema.pan b/ncm-sysconfig/src/main/pan/components/sysconfig/schema.pan index a2740866fc..6a462e35d4 100755 --- a/ncm-sysconfig/src/main/pan/components/sysconfig/schema.pan +++ b/ncm-sysconfig/src/main/pan/components/sysconfig/schema.pan @@ -2,16 +2,34 @@ # ${developer-info} # ${author-info} - declaration template components/sysconfig/schema; include 'quattor/schema'; +@documentation{ +Contents of a sysconfig file modelled as a dict of key-value pairs. + +Two reserved keys `prologue` and `epilogue` are treated specially, +their values will be copied verbatim into the file before or after the key-pair definitions. + +Example: + +'/software/components/sysconfig/files/scfg' = dict( + 'epilogue', 'export LANG=C', + 'KEY', 'VALUE', +); + +This will create the file `/etc/sysconfig/scfg` which contains: + +KEY=VALUE +export LANG=C +} +type component_sysconfig_file = string(1..){}; + type component_sysconfig = { include structure_component - 'files' ? string{}{} + @{ dict of dicts with a file name as the first key and the contents of each file as the child dict. } + 'files' ? component_sysconfig_file{} }; bind '/software/components/sysconfig' = component_sysconfig; - - diff --git a/ncm-sysconfig/src/test/resources/configure.pan b/ncm-sysconfig/src/test/resources/configure.pan index 8ce521239a..4a41d6130f 100644 --- a/ncm-sysconfig/src/test/resources/configure.pan +++ b/ncm-sysconfig/src/test/resources/configure.pan @@ -1,5 +1,7 @@ object template configure; +include 'components/sysconfig/schema'; + prefix '/software/components/sysconfig'; 'files/examplefile/key1' = 'testvalue';