summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-11-03 20:30:44 -0700
committerTim Smith <tsmith@chef.io>2018-11-05 09:36:21 -0800
commit6d3ef217651140613012c8017b0d05edca5f759c (patch)
tree9f994ba57505ca1768173ee29385a28b59a1324b
parente0cd94da5fc055945d0829eeff8383312a076951 (diff)
downloadchef-6d3ef217651140613012c8017b0d05edca5f759c.tar.gz
Add more validation_messages to properties
Provide users with more helpful messages Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/apt_preference.rb3
-rw-r--r--lib/chef/resource/homebrew_cask.rb1
-rw-r--r--lib/chef/resource/homebrew_tap.rb2
-rw-r--r--lib/chef/resource/openssl_rsa_private_key.rb2
-rw-r--r--lib/chef/resource/windows_service.rb1
-rw-r--r--lib/chef/resource/yum_repository.rb18
6 files changed, 18 insertions, 9 deletions
diff --git a/lib/chef/resource/apt_preference.rb b/lib/chef/resource/apt_preference.rb
index 0169fb73c2..7ece829ba2 100644
--- a/lib/chef/resource/apt_preference.rb
+++ b/lib/chef/resource/apt_preference.rb
@@ -31,7 +31,8 @@ class Chef
property :package_name, String,
name_property: true,
description: "The name of the package.",
- regex: [/^([a-z]|[A-Z]|[0-9]|_|-|\.|\*|\+)+$/]
+ regex: [/^([a-z]|[A-Z]|[0-9]|_|-|\.|\*|\+)+$/],
+ validation_message: "The provided package name is not valid. Package names can only contain alphanumeric characters as well as _, -, +, or *!"
property :glob, String,
description: "Pin by glob() expression or with regular expressions surrounded by /."
diff --git a/lib/chef/resource/homebrew_cask.rb b/lib/chef/resource/homebrew_cask.rb
index 626ae02a69..7c47fbbfcd 100644
--- a/lib/chef/resource/homebrew_cask.rb
+++ b/lib/chef/resource/homebrew_cask.rb
@@ -34,6 +34,7 @@ class Chef
property :cask_name, String,
description: "The name of the Homebrew cask, if it differs from the resource block name.",
regex: %r{^[\w/-]+$},
+ validation_message: "The provided Homebrew cask name is not valid. Cask names can contain alphanumeric characters, _, -, or / only!",
name_property: true
property :options, String,
diff --git a/lib/chef/resource/homebrew_tap.rb b/lib/chef/resource/homebrew_tap.rb
index 20ac0bb5d5..a4591e9ed8 100644
--- a/lib/chef/resource/homebrew_tap.rb
+++ b/lib/chef/resource/homebrew_tap.rb
@@ -33,7 +33,7 @@ class Chef
property :tap_name, String,
description: "Optional tap name to override the resource name",
- validation_message: "Homebrew tap names must be in the form REPO/TAP",
+ validation_message: "Homebrew tap names must be in the form REPO/TAP format!",
regex: %r{^[\w-]+(?:\/[\w-]+)+$},
name_property: true
diff --git a/lib/chef/resource/openssl_rsa_private_key.rb b/lib/chef/resource/openssl_rsa_private_key.rb
index f2c1400a30..f0d54dbe37 100644
--- a/lib/chef/resource/openssl_rsa_private_key.rb
+++ b/lib/chef/resource/openssl_rsa_private_key.rb
@@ -36,7 +36,7 @@ class Chef
property :key_length, Integer,
equal_to: [1024, 2048, 4096, 8192],
- validation_message: "key_length (bits) must be 1024, 2048, 4096, or 8192.",
+ validation_message: "key_length (bits) must be 1024, 2048, 4096, or 8192!",
description: "The desired bit length of the generated key.",
default: 2048
diff --git a/lib/chef/resource/windows_service.rb b/lib/chef/resource/windows_service.rb
index 1e7271b1fe..7b6593f037 100644
--- a/lib/chef/resource/windows_service.rb
+++ b/lib/chef/resource/windows_service.rb
@@ -50,6 +50,7 @@ class Chef
# The display name to be used by user interface programs to identify the
# service. This string has a maximum length of 256 characters.
property :display_name, String, regex: /^.{1,256}$/,
+ validation_message: "The display_name can only be a maximum of 256 characters!",
introduced: "14.0"
# https://github.com/djberg96/win32-service/blob/ffi/lib/win32/windows/constants.rb#L19-L29
diff --git a/lib/chef/resource/yum_repository.rb b/lib/chef/resource/yum_repository.rb
index df3bfb6454..a4b78e2ca4 100644
--- a/lib/chef/resource/yum_repository.rb
+++ b/lib/chef/resource/yum_repository.rb
@@ -45,7 +45,8 @@ class Chef
default: true
property :cost, String, regex: /^\d+$/,
- description: "Relative cost of accessing this repository. Useful for weighing one repo's packages as greater/less than any other."
+ description: "Relative cost of accessing this repository. Useful for weighing one repo's packages as greater/less than any other.",
+ validation_message: "The cost property must be a numeric value!"
property :description, String,
description: "Descriptive name for the repository channel and maps to the 'name' parameter in a repository .conf.",
@@ -95,16 +96,19 @@ class Chef
description: "Number of times any attempt to retrieve a file should retry before returning an error. Setting this to '0' makes Yum try forever."
property :metadata_expire, String, regex: [/^\d+$/, /^\d+[mhd]$/, /never/],
- description: "Time (in seconds) after which the metadata will expire. If the current metadata downloaded is less than the value specified, then Yum will not update the metadata against the repository. If you find that Yum is not downloading information on updates as often as you would like lower the value of this option. You can also change from the default of using seconds to using days, hours or minutes by appending a 'd', 'h' or 'm' respectively. The default is six hours to compliment yum-updates running once per hour. It is also possible to use the word ``never``, meaning that the metadata will never expire. Note: When using a metalink file, the metalink must always be newer than the metadata for the repository due to the validation, so this timeout also applies to the metalink file."
+ description: "Time (in seconds) after which the metadata will expire. If the current metadata downloaded is less than the value specified, then Yum will not update the metadata against the repository. If you find that Yum is not downloading information on updates as often as you would like lower the value of this option. You can also change from the default of using seconds to using days, hours or minutes by appending a 'd', 'h' or 'm' respectively. The default is six hours to compliment yum-updates running once per hour. It is also possible to use the word ``never``, meaning that the metadata will never expire. Note: When using a metalink file, the metalink must always be newer than the metadata for the repository due to the validation, so this timeout also applies to the metalink file.",
+ validation_message: "The metadata_expire property must be a numeric value for time in seconds, the string 'never', or a numeric value appended with with 'd', 'h', or 'm'!"
property :metalink, String,
description: "Specifies a URL to a metalink file for the repomd.xml, a list of mirrors for the entire repository are generated by converting the mirrors for the repomd.xml file to a baseurl."
property :mirror_expire, String, regex: [/^\d+$/, /^\d+[mhd]$/],
- description: "Time (in seconds) after which the mirrorlist locally cached will expire. If the current mirrorlist is less than this many seconds old then Yum will not download another copy of the mirrorlist, it has the same extra format as metadata_expire. If you find that Yum is not downloading the mirrorlists as often as you would like lower the value of this option."
+ description: "Time (in seconds) after which the mirrorlist locally cached will expire. If the current mirrorlist is less than this many seconds old then Yum will not download another copy of the mirrorlist, it has the same extra format as metadata_expire. If you find that Yum is not downloading the mirrorlists as often as you would like lower the value of this option. You can also change from the default of using seconds to using days, hours or minutes by appending a 'd', 'h' or 'm' respectively.",
+ validation_message: "The mirror_expire property must be a numeric value for time in seconds, the string 'never', or a numeric value appended with with 'd', 'h', or 'm'!"
property :mirrorlist_expire, String, regex: [/^\d+$/, /^\d+[mhd]$/],
- description: "Specifies the time (in seconds) after which the mirrorlist locally cached will expire. If the current mirrorlist is less than the value specified, then Yum will not download another copy of the mirrorlist."
+ description: "Specifies the time (in seconds) after which the mirrorlist locally cached will expire. If the current mirrorlist is less than the value specified, then Yum will not download another copy of the mirrorlist. You can also change from the default of using seconds to using days, hours or minutes by appending a 'd', 'h' or 'm' respectively.",
+ validation_message: "The mirrorlist_expire property must be a numeric value for time in seconds, the string 'never', or a numeric value appended with with 'd', 'h', or 'm'!"
property :mirrorlist, String,
description: "URL to a file containing a list of baseurls. This can be used instead of or with the baseurl option. Substitution variables, described below, can be used with this option."
@@ -120,7 +124,8 @@ class Chef
description: "Password to use with the username for basic authentication."
property :priority, String, regex: /^(\d?[1-9]|[0-9][0-9])$/,
- description: "Assigns a priority to a repository where the priority value is between '1' and '99' inclusive. Priorities are used to enforce ordered protection of repositories. Packages from repositories with a lower priority (higher numerical value) will never be used to upgrade packages that were installed from a repository with a higher priority (lower numerical value). The repositories with the lowest numerical priority number have the highest priority."
+ description: "Assigns a priority to a repository where the priority value is between '1' and '99' inclusive. Priorities are used to enforce ordered protection of repositories. Packages from repositories with a lower priority (higher numerical value) will never be used to upgrade packages that were installed from a repository with a higher priority (lower numerical value). The repositories with the lowest numerical priority number have the highest priority.",
+ validation_message: "The priority property must be a numeric value from 1-99!"
property :proxy_password, String,
description: "Password for this proxy."
@@ -164,7 +169,8 @@ class Chef
description: "Enable bandwidth throttling for downloads."
property :timeout, String, regex: /^\d+$/,
- description: "Number of seconds to wait for a connection before timing out. Defaults to 30 seconds. This may be too short of a time for extremely overloaded sites."
+ description: "Number of seconds to wait for a connection before timing out. Defaults to 30 seconds. This may be too short of a time for extremely overloaded sites.",
+ validation_message: "The timeout property must be a numeric value!"
property :username, String,
description: "Username to use for basic authentication to a repository."