From 87daa0d823c8f92eda8190f2d9b482b3d85a7a0c Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 14 May 2020 19:53:15 +0100 Subject: [PATCH 1/1] Limit required attributes to the actions that need them --- cookbooks/apache/resources/conf.rb | 2 +- cookbooks/apache/resources/site.rb | 2 +- cookbooks/imagery/resources/layer.rb | 2 +- cookbooks/imagery/resources/site.rb | 4 ++-- cookbooks/mediawiki/resources/site.rb | 6 +++--- cookbooks/munin/resources/plugin_conf.rb | 2 +- cookbooks/nginx/resources/site.rb | 2 +- cookbooks/ohai/resources/plugin.rb | 2 +- cookbooks/postgresql/resources/database.rb | 2 +- cookbooks/postgresql/resources/table.rb | 2 +- cookbooks/postgresql/resources/tablespace.rb | 2 +- cookbooks/squid/resources/fragment.rb | 2 +- cookbooks/ssl/resources/certificate.rb | 2 +- cookbooks/systemd/resources/path.rb | 2 +- cookbooks/systemd/resources/timer.rb | 2 +- cookbooks/systemd/resources/tmpfile.rb | 2 +- cookbooks/wordpress/resources/site.rb | 4 ++-- 17 files changed, 21 insertions(+), 21 deletions(-) diff --git a/cookbooks/apache/resources/conf.rb b/cookbooks/apache/resources/conf.rb index a163b4496..12daf87ab 100644 --- a/cookbooks/apache/resources/conf.rb +++ b/cookbooks/apache/resources/conf.rb @@ -21,7 +21,7 @@ default_action [:create, :enable] property :conf, :kind_of => String, :name_property => true property :cookbook, :kind_of => String -property :template, :kind_of => String, :required => true +property :template, :kind_of => String, :required => [:create] property :variables, :kind_of => Hash, :default => {} property :reload_apache, :kind_of => [TrueClass, FalseClass], :default => true diff --git a/cookbooks/apache/resources/site.rb b/cookbooks/apache/resources/site.rb index 96cf872f4..e039e3ac5 100644 --- a/cookbooks/apache/resources/site.rb +++ b/cookbooks/apache/resources/site.rb @@ -22,7 +22,7 @@ default_action [:create, :enable] property :site, :kind_of => String, :name_property => true property :directory, :kind_of => String property :cookbook, :kind_of => String -property :template, :kind_of => String, :required => true +property :template, :kind_of => String, :required => [:create] property :variables, :kind_of => Hash, :default => {} property :reload_apache, :kind_of => [TrueClass, FalseClass], :default => true diff --git a/cookbooks/imagery/resources/layer.rb b/cookbooks/imagery/resources/layer.rb index 05a0452ee..2cc90df56 100644 --- a/cookbooks/imagery/resources/layer.rb +++ b/cookbooks/imagery/resources/layer.rb @@ -23,7 +23,7 @@ default_action :create property :layer, String, :name_property => true property :site, String, :required => true -property :source, String, :required => true +property :source, String, :required => [:create] property :root_layer, [true, false], :default => false property :title, String property :copyright, String, :default => "Copyright" diff --git a/cookbooks/imagery/resources/site.rb b/cookbooks/imagery/resources/site.rb index 711ae3e50..50bfd24b8 100644 --- a/cookbooks/imagery/resources/site.rb +++ b/cookbooks/imagery/resources/site.rb @@ -22,9 +22,9 @@ require "yaml" default_action :create property :site, String, :name_property => true -property :title, String, :required => true +property :title, String, :required => [:create] property :aliases, [String, Array], :default => [] -property :bbox, Array, :required => true +property :bbox, Array, :required => [:create] action :create do directory "/srv/#{new_resource.site}" do diff --git a/cookbooks/mediawiki/resources/site.rb b/cookbooks/mediawiki/resources/site.rb index a7cb8cf40..472e8c3d8 100644 --- a/cookbooks/mediawiki/resources/site.rb +++ b/cookbooks/mediawiki/resources/site.rb @@ -24,8 +24,8 @@ property :aliases, :kind_of => [String, Array] property :directory, :kind_of => String property :version, :kind_of => String, :default => "1.33" property :database_name, :kind_of => String, :required => true -property :database_user, :kind_of => String, :required => true -property :database_password, :kind_of => String, :required => true +property :database_user, :kind_of => String, :required => [:create, :update] +property :database_password, :kind_of => String, :required => [:create, :update] property :sitename, :kind_of => String, :default => "OpenStreetMap Wiki" property :metanamespace, :kind_of => String, :default => "OpenStreetMap" property :logo, :kind_of => String, :default => "$wgStylePath/common/images/wiki.png" @@ -37,7 +37,7 @@ property :skin, :kind_of => String, :default => "vector" property :site_notice, :kind_of => [String, TrueClass, FalseClass], :default => false property :site_readonly, :kind_of => [String, TrueClass, FalseClass], :default => false property :admin_user, :kind_of => String, :default => "Admin" -property :admin_password, :kind_of => String, :required => true +property :admin_password, :kind_of => String, :required => [:create] property :private_accounts, :kind_of => [TrueClass, FalseClass], :default => false property :private_site, :kind_of => [TrueClass, FalseClass], :default => false property :recaptcha_public_key, :kind_of => String diff --git a/cookbooks/munin/resources/plugin_conf.rb b/cookbooks/munin/resources/plugin_conf.rb index e58a42889..6105f0d2b 100644 --- a/cookbooks/munin/resources/plugin_conf.rb +++ b/cookbooks/munin/resources/plugin_conf.rb @@ -21,7 +21,7 @@ default_action :create property :plugin_conf, :kind_of => String, :name_property => true property :cookbook, :kind_of => [String, nil] -property :template, :kind_of => String, :required => true +property :template, :kind_of => String, :required => [:create] property :variables, :kind_of => Hash, :default => {} property :restart_munin, :kind_of => [TrueClass, FalseClass], :default => true diff --git a/cookbooks/nginx/resources/site.rb b/cookbooks/nginx/resources/site.rb index 25066f459..45422434a 100644 --- a/cookbooks/nginx/resources/site.rb +++ b/cookbooks/nginx/resources/site.rb @@ -22,7 +22,7 @@ default_action :create property :site, :kind_of => String, :name_property => true property :directory, :kind_of => String property :cookbook, :kind_of => String -property :template, :kind_of => String, :required => true +property :template, :kind_of => String, :required => [:create] property :variables, :kind_of => Hash, :default => {} action :create do diff --git a/cookbooks/ohai/resources/plugin.rb b/cookbooks/ohai/resources/plugin.rb index 580d4912f..5d550371f 100644 --- a/cookbooks/ohai/resources/plugin.rb +++ b/cookbooks/ohai/resources/plugin.rb @@ -20,7 +20,7 @@ default_action :create property :plugin, :kind_of => String, :name_property => true -property :template, :kind_of => String, :required => true +property :template, :kind_of => String, :required => [:create] action :create do ohai new_resource.plugin do diff --git a/cookbooks/postgresql/resources/database.rb b/cookbooks/postgresql/resources/database.rb index c0e7e0de4..c73250464 100644 --- a/cookbooks/postgresql/resources/database.rb +++ b/cookbooks/postgresql/resources/database.rb @@ -21,7 +21,7 @@ default_action :create property :database, :kind_of => String, :name_property => true property :cluster, :kind_of => String, :required => true -property :owner, :kind_of => String, :required => true +property :owner, :kind_of => String, :required => [:create] property :encoding, :kind_of => String, :default => "UTF8" property :collation, :kind_of => String, :default => "en_GB.UTF8" property :ctype, :kind_of => String, :default => "en_GB.UTF8" diff --git a/cookbooks/postgresql/resources/table.rb b/cookbooks/postgresql/resources/table.rb index 4bb2431ee..ed2655932 100644 --- a/cookbooks/postgresql/resources/table.rb +++ b/cookbooks/postgresql/resources/table.rb @@ -23,7 +23,7 @@ property :table, :kind_of => String, :name_property => true property :cluster, :kind_of => String, :required => true property :database, :kind_of => String, :required => true property :schema, :kind_of => String, :default => "public" -property :owner, :kind_of => String, :required => true +property :owner, :kind_of => String, :required => [:create] property :permissions, :kind_of => Hash, :default => {} action :create do diff --git a/cookbooks/postgresql/resources/tablespace.rb b/cookbooks/postgresql/resources/tablespace.rb index 82e901228..69e0ce2b0 100644 --- a/cookbooks/postgresql/resources/tablespace.rb +++ b/cookbooks/postgresql/resources/tablespace.rb @@ -21,7 +21,7 @@ default_action :create property :tablespace, :kind_of => String, :name_property => true property :cluster, :kind_of => String, :required => true -property :location, :kind_of => String, :required => true +property :location, :kind_of => String, :required => [:create] action :create do unless cluster.tablespaces.include?(new_resource.tablespace) diff --git a/cookbooks/squid/resources/fragment.rb b/cookbooks/squid/resources/fragment.rb index 22c31ba47..f4099ad7b 100644 --- a/cookbooks/squid/resources/fragment.rb +++ b/cookbooks/squid/resources/fragment.rb @@ -20,7 +20,7 @@ default_action :create property :fragment, :kind_of => String, :name_property => true -property :template, :kind_of => String, :required => true +property :template, :kind_of => String, :required => [:create] property :variables, :kind_of => Hash, :default => {} action :create do diff --git a/cookbooks/ssl/resources/certificate.rb b/cookbooks/ssl/resources/certificate.rb index fd1bff0e4..116c2bd4d 100644 --- a/cookbooks/ssl/resources/certificate.rb +++ b/cookbooks/ssl/resources/certificate.rb @@ -20,7 +20,7 @@ default_action :create property :certificate, String, :name_property => true -property :domains, [String, Array], :required => true +property :domains, [String, Array], :required => [:create] action :create do node.default[:letsencrypt][:certificates][new_resource.certificate] = { diff --git a/cookbooks/systemd/resources/path.rb b/cookbooks/systemd/resources/path.rb index 918e5f801..29bbfa51c 100644 --- a/cookbooks/systemd/resources/path.rb +++ b/cookbooks/systemd/resources/path.rb @@ -20,7 +20,7 @@ default_action :create property :path, String, :name_property => true -property :description, String, :required => true +property :description, String, :required => [:create] property :after, [String, Array] property :wants, [String, Array] property :path_exists, [String, Array] diff --git a/cookbooks/systemd/resources/timer.rb b/cookbooks/systemd/resources/timer.rb index c18db64c8..7dc4cab65 100644 --- a/cookbooks/systemd/resources/timer.rb +++ b/cookbooks/systemd/resources/timer.rb @@ -20,7 +20,7 @@ default_action :create property :timer, String, :name_property => true -property :description, String, :required => true +property :description, String, :required => [:create] property :after, [String, Array] property :wants, [String, Array] property :on_active_sec, [Integer, String] diff --git a/cookbooks/systemd/resources/tmpfile.rb b/cookbooks/systemd/resources/tmpfile.rb index 2c294b5ba..8eaf47316 100644 --- a/cookbooks/systemd/resources/tmpfile.rb +++ b/cookbooks/systemd/resources/tmpfile.rb @@ -19,7 +19,7 @@ default_action :create -property :type, String, :required => true +property :type, String, :required => [:create] property :path, String, :name_property => true property :mode, String, :default => "-" property :owner, String, :default => "-" diff --git a/cookbooks/wordpress/resources/site.rb b/cookbooks/wordpress/resources/site.rb index c86705d5d..1771c2a1b 100644 --- a/cookbooks/wordpress/resources/site.rb +++ b/cookbooks/wordpress/resources/site.rb @@ -25,8 +25,8 @@ property :aliases, :kind_of => [String, Array] property :directory, :kind_of => String property :version, :kind_of => String property :database_name, :kind_of => String, :required => true -property :database_user, :kind_of => String, :required => true -property :database_password, :kind_of => String, :required => true +property :database_user, :kind_of => String, :required => [:create] +property :database_password, :kind_of => String, :required => [:create] property :database_prefix, :kind_of => String, :default => "wp_" property :urls, :kind_of => Hash, :default => {} property :reload_apache, :kind_of => [TrueClass, FalseClass], :default => true -- 2.39.5