Dev set up
This commit is contained in:
		
							
								
								
									
										45
									
								
								ops/cookbooks/vendor/packagecloud/libraries/helper.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								ops/cookbooks/vendor/packagecloud/libraries/helper.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,45 @@ | ||||
| require 'net/https' | ||||
|  | ||||
| module PackageCloud | ||||
|   module Helper | ||||
|     def get(uri, params) | ||||
|       uri.query     = URI.encode_www_form(params) | ||||
|       req           = Net::HTTP::Get.new(uri.request_uri) | ||||
|  | ||||
|       req.basic_auth uri.user, uri.password if uri.user | ||||
|  | ||||
|       proxy = node['packagecloud'].values_at('proxy_host', 'proxy_port') | ||||
|       http = Net::HTTP.new(uri.hostname, uri.port, *(proxy if proxy.first)) | ||||
|       http.use_ssl = true | ||||
|  | ||||
|       resp = http.start { |h| h.request(req) } | ||||
|  | ||||
|       case resp | ||||
|       when Net::HTTPSuccess | ||||
|         resp | ||||
|       else | ||||
|         raise resp.inspect | ||||
|       end | ||||
|     end | ||||
|  | ||||
|     def post(uri, params) | ||||
|       req           = Net::HTTP::Post.new(uri.request_uri) | ||||
|       req.form_data = params | ||||
|  | ||||
|       req.basic_auth uri.user, uri.password if uri.user | ||||
|  | ||||
|       proxy = node['packagecloud'].values_at('proxy_host', 'proxy_port') | ||||
|       http = Net::HTTP.new(uri.hostname, uri.port, *(proxy if proxy.first)) | ||||
|       http.use_ssl = true | ||||
|  | ||||
|       resp = http.start { |h| h.request(req) } | ||||
|  | ||||
|       case resp | ||||
|       when Net::HTTPSuccess | ||||
|         resp | ||||
|       else | ||||
|         raise resp.inspect | ||||
|       end | ||||
|     end | ||||
|   end | ||||
| end | ||||
							
								
								
									
										11
									
								
								ops/cookbooks/vendor/packagecloud/libraries/matchers.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								ops/cookbooks/vendor/packagecloud/libraries/matchers.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
| if defined?(ChefSpec) | ||||
|   ChefSpec.define_matcher :packagecloud_repo | ||||
|  | ||||
|   def create_packagecloud_repo(resource_name) | ||||
|     ChefSpec::Matchers::ResourceMatcher.new(:packagecloud_repo, :add, resource_name) | ||||
|   end | ||||
|  | ||||
|   def add_packagecloud_repo(resource_name) | ||||
|     ChefSpec::Matchers::ResourceMatcher.new(:packagecloud_repo, :add, resource_name) | ||||
|   end | ||||
| end | ||||
		Reference in New Issue
	
	Block a user