Class: KuberKit::Core::Artifacts::Git

Inherits:
AbstractArtifact show all
Defined in:
lib/kuber_kit/core/artifacts/git.rb

Constant Summary collapse

DEFAULT_SSH_KEY =
"id_rsa"
DEFAULT_REMOTE_NAME =
"origin"
DEFAULT_BRANCH =
"master"

Instance Attribute Summary collapse

Attributes inherited from AbstractArtifact

#name

Instance Method Summary collapse

Methods inherited from AbstractArtifact

#initialize, #namespace

Methods included from Extensions::Inspectable

#inspect

Constructor Details

This class inherits a constructor from KuberKit::Core::Artifacts::AbstractArtifact

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



2
3
4
# File 'lib/kuber_kit/core/artifacts/git.rb', line 2

def branch
  @branch
end

#emailObject (readonly)

Returns the value of attribute email.



2
3
4
# File 'lib/kuber_kit/core/artifacts/git.rb', line 2

def email
  @email
end

#passwordObject (readonly)

Returns the value of attribute password.



2
3
4
# File 'lib/kuber_kit/core/artifacts/git.rb', line 2

def password
  @password
end

#remote_nameObject (readonly)

Returns the value of attribute remote_name.



2
3
4
# File 'lib/kuber_kit/core/artifacts/git.rb', line 2

def remote_name
  @remote_name
end

#remote_urlObject (readonly)

Returns the value of attribute remote_url.



2
3
4
# File 'lib/kuber_kit/core/artifacts/git.rb', line 2

def remote_url
  @remote_url
end

#ssh_keyObject (readonly)

Returns the value of attribute ssh_key.



2
3
4
# File 'lib/kuber_kit/core/artifacts/git.rb', line 2

def ssh_key
  @ssh_key
end

Instance Method Details

#cleanup_needed?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/kuber_kit/core/artifacts/git.rb', line 28

def cleanup_needed?
  !@cache_result
end

#cloned_pathObject



18
19
20
21
22
# File 'lib/kuber_kit/core/artifacts/git.rb', line 18

def cloned_path
  # TODO: We should refactor to not call container here
  configs = KuberKit::Container['configs']
  "#{configs.artifact_clone_dir}/#{name}"
end

#setup(remote_url:, remote_name: DEFAULT_REMOTE_NAME, branch: DEFAULT_BRANCH, clone_path: nil, ssh_key: DEFAULT_SSH_KEY, cache_result: true) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/kuber_kit/core/artifacts/git.rb', line 8

def setup(remote_url:, remote_name: DEFAULT_REMOTE_NAME, branch: DEFAULT_BRANCH, clone_path: nil, ssh_key: DEFAULT_SSH_KEY, cache_result: true)
  @remote_name = remote_name
  @remote_url = remote_url
  @branch = branch
  @clone_path = clone_path
  @ssh_key = ssh_key
  @cache_result = cache_result
  self
end

#sync_descriptionObject



24
25
26
# File 'lib/kuber_kit/core/artifacts/git.rb', line 24

def sync_description
  "#{remote_url}:#{branch}"
end