Class: UffizziCore::ContainerRegistry::DockerHubService
- Inherits:
-
Object
- Object
- UffizziCore::ContainerRegistry::DockerHubService
- Defined in:
- app/services/uffizzi_core/container_registry/docker_hub_service.rb
Class Method Summary collapse
- .accounts(credential) ⇒ Object
- .credential_correct?(credential) ⇒ Boolean
- .digest(credential, image, tag) ⇒ Object
- .image_available?(credential, image_data) ⇒ Boolean
- .user_client(credential) ⇒ Object
Class Method Details
.accounts(credential) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'app/services/uffizzi_core/container_registry/docker_hub_service.rb', line 5 def accounts(credential) client = user_client(credential) response = client.accounts Rails.logger.info("DockerHubService accounts response=#{response.inspect} credential_id=#{credential.id}") accounts_response = response.result accounts_response.nil? ? [] : accounts_response.namespaces end |
.credential_correct?(credential) ⇒ Boolean
45 46 47 |
# File 'app/services/uffizzi_core/container_registry/docker_hub_service.rb', line 45 def credential_correct?(credential) client(credential).authenticated? end |
.digest(credential, image, tag) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'app/services/uffizzi_core/container_registry/docker_hub_service.rb', line 35 def digest(credential, image, tag) docker_hub_client = client(credential) token = docker_hub_client.get_token(image).result.token response = docker_hub_client.digest(image: image, tag: tag, token: token) response.headers['docker-content-digest'] # FIXME: can't get digest for private image: {"code":"UNAUTHORIZED","message":"authentication required"...} rescue UffizziCore::ContainerRegistryError 'unknown' end |
.image_available?(credential, image_data) ⇒ Boolean
14 15 16 17 18 19 20 |
# File 'app/services/uffizzi_core/container_registry/docker_hub_service.rb', line 14 def image_available?(credential, image_data) namespace = image_data[:namespace] repo_name = image_data[:name] client(credential).repository(namespace: namespace, image: repo_name) true end |
.user_client(credential) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/uffizzi_core/container_registry/docker_hub_service.rb', line 22 def user_client(credential) return @client if @client&.credential&.username == credential.username @client = client(credential) unless @client.authenticated? Rails.logger.warn("broken credentials, DockerHubService credential_id=#{credential.id}") credential. unless credential. end @client end |