diff options
author | Tim Smith <tsmith@chef.io> | 2018-03-28 20:34:32 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-03-28 20:34:32 -0700 |
commit | 55ac0da13539f5a80080809ee9059b676dabc5a8 (patch) | |
tree | 9c3002ab7d40a098081197bc08f3d1070a01dd3e /lib/chef/resource/hostname.rb | |
parent | ff4656d9ae70d2e8810ec0a45f322b394c31083d (diff) | |
download | chef-55ac0da13539f5a80080809ee9059b676dabc5a8.tar.gz |
Add basic hostname validation
alphanumeric, -, . or _
Starts with an alphanumeric
We could get a lot more complex here and that might not be a bad idea, but this is probably a step in the right direction.
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef/resource/hostname.rb')
-rw-r--r-- | lib/chef/resource/hostname.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/chef/resource/hostname.rb b/lib/chef/resource/hostname.rb index f785d1b620..1c91e412a8 100644 --- a/lib/chef/resource/hostname.rb +++ b/lib/chef/resource/hostname.rb @@ -11,6 +11,8 @@ class Chef introduced "14.0" property :hostname, String, + regex: /^([A-Za-z0-9])+([A-Za-z0-9-._])*$/, # http://rubular.com/r/c5xKppWX4i + validation_message: "Hostnames can contain alphanumeric characters, -, ., and _ ,but must start with an alphanumeric character.", description: "The hostname if different than the resource's name", name_property: true |