Class: UffizziCore::ComposeFile::ContainerService
- Inherits:
-
Object
- Object
- UffizziCore::ComposeFile::ContainerService
- Defined in:
- app/services/uffizzi_core/compose_file/container_service.rb
Class Method Summary collapse
- .amazon?(container) ⇒ Boolean
- .azure?(container) ⇒ Boolean
- .credential_for_container(container, credentials) ⇒ Object
- .detect_credential(credentials, type) ⇒ Object
- .docker_hub?(container) ⇒ Boolean
- .github_container_registry?(container) ⇒ Boolean
- .google?(container) ⇒ Boolean
- .has_secret?(container, secret) ⇒ Boolean
- .update_secret(container, secret) ⇒ Object
Class Method Details
.amazon?(container) ⇒ Boolean
17 18 19 20 21 |
# File 'app/services/uffizzi_core/compose_file/container_service.rb', line 17 def amazon?(container) registry_url = container.dig(:image, :registry_url) registry_url.present? && registry_url.include?('amazonaws.com') end |
.azure?(container) ⇒ Boolean
5 6 7 8 9 |
# File 'app/services/uffizzi_core/compose_file/container_service.rb', line 5 def azure?(container) registry_url = container.dig(:image, :registry_url) registry_url.present? && registry_url.include?('azurecr.io') end |
.credential_for_container(container, credentials) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'app/services/uffizzi_core/compose_file/container_service.rb', line 47 def credential_for_container(container, credentials) if UffizziCore::ComposeFile::ContainerService.azure?(container) detect_credential(credentials, :azure) elsif UffizziCore::ComposeFile::ContainerService.docker_hub?(container) detect_credential(credentials, :docker_hub) elsif UffizziCore::ComposeFile::ContainerService.google?(container) detect_credential(credentials, :google) end end |
.detect_credential(credentials, type) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'app/services/uffizzi_core/compose_file/container_service.rb', line 57 def detect_credential(credentials, type) credential = credentials.detect do |item| item.send("#{type}?") end = "Invalid credential: #{type}" raise UffizziCore::ComposeFile::CredentialError.new() if credential.nil? credential end |
.docker_hub?(container) ⇒ Boolean
23 24 25 26 27 28 |
# File 'app/services/uffizzi_core/compose_file/container_service.rb', line 23 def docker_hub?(container) registry_url = container.dig(:image, :registry_url) repository_url = container.dig(:build, :repository_url) registry_url.nil? && repository_url.nil? end |
.github_container_registry?(container) ⇒ Boolean
30 31 32 33 34 |
# File 'app/services/uffizzi_core/compose_file/container_service.rb', line 30 def github_container_registry?(container) registry_url = container.dig(:image, :registry_url) registry_url.present? && registry_url.include?('ghcr.io') end |
.google?(container) ⇒ Boolean
11 12 13 14 15 |
# File 'app/services/uffizzi_core/compose_file/container_service.rb', line 11 def google?(container) registry_url = container.dig(:image, :registry_url) registry_url.present? && registry_url.include?('gcr.io') end |
.has_secret?(container, secret) ⇒ Boolean
36 37 38 |
# File 'app/services/uffizzi_core/compose_file/container_service.rb', line 36 def has_secret?(container, secret) container['secret_variables'].any? { |container_secret| container_secret['name'] == secret['name'] } end |
.update_secret(container, secret) ⇒ Object
40 41 42 43 44 45 |
# File 'app/services/uffizzi_core/compose_file/container_service.rb', line 40 def update_secret(container, secret) secret_index = container['secret_variables'].find_index { |container_secret| container_secret['name'] == secret['name'] } container['secret_variables'][secret_index] = secret container end |