Module: UffizziCore::RepoService

Defined in:
app/services/uffizzi_core/repo_service.rb

Class Method Summary collapse

Class Method Details

.credential(repo) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/uffizzi_core/repo_service.rb', line 11

def credential(repo)
  credentials = repo.project..credentials

  case repo.type
  when UffizziCore::Repo::GithubContainerRegistry.name
    credentials.github_container_registry.first
  when UffizziCore::Repo::DockerHub.name
    credentials.docker_hub.first
  when UffizziCore::Repo::Azure.name
    credentials.azure.first
  when UffizziCore::Repo::Google.name
    credentials.google.first
  when UffizziCore::Repo::Amazon.name
    credentials.amazon.first
  end
end

.image(repo) ⇒ Object



37
38
39
40
41
# File 'app/services/uffizzi_core/repo_service.rb', line 37

def image(repo)
  repo_credential = credential(repo)

  "#{repo_credential.registry_url}/#{image_name(repo)}"
end

.image_name(repo) ⇒ Object



28
29
30
31
# File 'app/services/uffizzi_core/repo_service.rb', line 28

def image_name(repo)
  "e#{repo.container.deployment_id}r#{repo.id}-#{Digest::SHA256.hexdigest("#{self.class}:#{repo.branch}:
  #{repo.project_id}:#{repo.id}")[0, 10]}"
end

.needs_target_port?(repo) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
# File 'app/services/uffizzi_core/repo_service.rb', line 5

def needs_target_port?(repo)
  return false if repo.nil?

  !repo.dockerfile?
end

.tag(repo) ⇒ Object



33
34
35
# File 'app/services/uffizzi_core/repo_service.rb', line 33

def tag(repo)
  repo&.builds&.deployed&.last&.commit || 'latest'
end