vmfloaty/lib/vmfloaty/http.rb
isaac-jha 731ee3f014
Bump faraday from ~> 1.5 to ~> 2 (#256)
* Bump faraday from ~> 1.5 to ~> 2

Updates the basic-auth middleware call to the Faraday 2 form
(`request :authorization, :basic, ...`). Faraday 2.x requires Ruby >=
3.0, so drop Ruby 2.7 from the CI matrix and pin
`required_ruby_version = '>= 3.0'` in the gemspec.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* Remove ensure_label workflow

The reusable workflow it referenced
(puppetlabs/release-engineering-repo-standards/.github/workflows/ensure_label.yml@v1)
no longer exists.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* Add CLAUDE.md

Documents common dev/test/release commands and the Service/backend
architecture for future Claude Code sessions in this repo.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-01 08:58:05 -04:00

45 lines
1.2 KiB
Ruby

# frozen_string_literal: true
require 'faraday'
require 'uri'
class Http
def self.url?(url)
# This method exists because it seems like Farady
# has no handling around if a user gives us a URI
# with no protocol on the beginning of the URL
uri = URI.parse(url)
return true if uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
false
end
def self.get_conn(verbose, url)
raise 'Did not provide a url to connect to' if url.nil?
url = "https://#{url}" unless url?(url)
Faraday.new(url: url, ssl: { verify: false }) do |faraday|
faraday.request :url_encoded
faraday.response :logger if verbose
faraday.adapter Faraday.default_adapter
end
end
def self.get_conn_with_auth(verbose, url, user, password)
raise 'Did not provide a url to connect to' if url.nil?
raise 'You did not provide a user to authenticate with' if user.nil?
url = "https://#{url}" unless url?(url)
Faraday.new(url: url, ssl: { verify: false }) do |faraday|
faraday.request :url_encoded
faraday.request :authorization, :basic, user, password
faraday.response :logger if verbose
faraday.adapter Faraday.default_adapter
end
end
end