summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Heinen <theinen@tecracer.de>2022-07-19 17:37:34 +0200
committerPrajakta Purohit <prajakta@chef.io>2022-10-24 11:35:06 -0700
commitf091fb0a405ae24273ea371fe5656d7ebb7b6bf9 (patch)
tree22dc4bd91874c503868aa9e17976431b7673ffd9
parent7d7f11e09f537200fa85f054336b062d5c7b7b5c (diff)
downloadchef-theinen/rest-fixes.tar.gz
Fix error on wrong URLs in REST DSLtheinen/rest-fixes
Signed-off-by: Thomas Heinen <theinen@tecracer.de>
-rw-r--r--lib/chef/dsl/rest_resource.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/chef/dsl/rest_resource.rb b/lib/chef/dsl/rest_resource.rb
index 96eba24eac..2c435930e9 100644
--- a/lib/chef/dsl/rest_resource.rb
+++ b/lib/chef/dsl/rest_resource.rb
@@ -31,13 +31,20 @@ class Chef
# URL to collection
def rest_api_collection(rest_api_collection = NOT_PASSED)
- @rest_api_collection = rest_api_collection if rest_api_collection != NOT_PASSED
+ if rest_api_collection != NOT_PASSED
+ raise ArgumentError, "You must pass an absolute path to rest_api_collection" unless rest_api_collection.start_with? "/"
+
+ @rest_api_collection = rest_api_collection
+ end
+
@rest_api_collection
end
# RFC6570-Templated URL to document
def rest_api_document(rest_api_document = NOT_PASSED, first_element_only: false)
if rest_api_document != NOT_PASSED
+ raise ArgumentError, "You must pass an absolute path to rest_api_document" unless rest_api_document.start_with? "/"
+
@rest_api_document = rest_api_document
@rest_api_document_first_element_only = first_element_only
end