Class: Dependabot::Docker::Utils::CredentialsFinder
- Inherits:
-
Object
- Object
- Dependabot::Docker::Utils::CredentialsFinder
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/docker/utils/credentials_finder.rb
Constant Summary collapse
- AWS_ECR_URL =
/dkr\.ecr\.(?<region>[^.]+)\.amazonaws\.com/
- DEFAULT_DOCKER_HUB_REGISTRY =
"registry.hub.docker.com"
Instance Method Summary collapse
- #base_registry ⇒ Object
- #credentials_for_registry(registry_hostname) ⇒ Object
-
#initialize(credentials) ⇒ CredentialsFinder
constructor
A new instance of CredentialsFinder.
- #using_dockerhub?(registry) ⇒ Boolean
Constructor Details
#initialize(credentials) ⇒ CredentialsFinder
Returns a new instance of CredentialsFinder.
21 22 23 |
# File 'lib/dependabot/docker/utils/credentials_finder.rb', line 21 def initialize(credentials) @credentials = credentials end |
Instance Method Details
#base_registry ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dependabot/docker/utils/credentials_finder.rb', line 38 def base_registry @base_registry ||= T.let( credentials.find do |cred| cred["type"] == "docker_registry" && cred.replaces_base? end, T.nilable(Dependabot::Credential) ) @base_registry ||= Dependabot::Credential.new({ "registry" => DEFAULT_DOCKER_HUB_REGISTRY, "credentials" => nil }) @base_registry["registry"] end |
#credentials_for_registry(registry_hostname) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dependabot/docker/utils/credentials_finder.rb', line 26 def credentials_for_registry(registry_hostname) registry_details = credentials .select { |cred| cred["type"] == "docker_registry" } .find { |cred| cred.fetch("registry") == registry_hostname } return unless registry_details return registry_details unless registry_hostname.match?(AWS_ECR_URL) build_aws_credentials(registry_details) end |
#using_dockerhub?(registry) ⇒ Boolean
51 52 53 |
# File 'lib/dependabot/docker/utils/credentials_finder.rb', line 51 def using_dockerhub?(registry) registry == DEFAULT_DOCKER_HUB_REGISTRY end |