Class: Dapp::Dimg::Config::Directive::ArtifactGroup

Inherits:
DimgGroup show all
Defined in:
lib/dapp/dimg/config/directive/artifact_group.rb

Instance Attribute Summary collapse

Attributes included from Dimg::InstanceMethods

#_artifact, #_artifact_groups, #_builder, #_chef, #_git_artifact, #_mount

Instance Method Summary collapse

Methods inherited from DimgGroup

#artifact, #chef, #docker, #git, #mount, #shell

Methods included from Dimg::InstanceMethods

#_context_artifact_groups, #_import_artifact, #artifact, #artifacts_after_parsing!, #chef, #docker, #git, #import, #mount, #shell

Methods included from DimgGroupBase

#_dimg, #_dimg_group, #dimg, #dimg_group

Methods inherited from Base

#clone_to_artifact

Methods inherited from Config::Directive::Base

#clone, #encode_with

Constructor Details

#initialize(name = nil, dapp:) ⇒ ArtifactGroup

Returns a new instance of ArtifactGroup.



8
9
10
11
# File 'lib/dapp/dimg/config/directive/artifact_group.rb', line 8

def initialize(name = nil, dapp:)
  super(dapp: dapp)
  @_name = name
end

Instance Attribute Details

#_nameObject (readonly)

Returns the value of attribute _name.



6
7
8
# File 'lib/dapp/dimg/config/directive/artifact_group.rb', line 6

def _name
  @_name
end

Instance Method Details

#_artifact_configObject



17
18
19
20
# File 'lib/dapp/dimg/config/directive/artifact_group.rb', line 17

def _artifact_config
  artifact_config_name = "artifact-#{[_name, SecureRandom.hex(2)].compact.join('-')}"
  pass_to(ArtifactDimg.new(artifact_config_name, dapp: dapp))
end

#_artifact_export(artifact_config, *args, &blk) ⇒ Object



22
23
24
25
26
27
# File 'lib/dapp/dimg/config/directive/artifact_group.rb', line 22

def _artifact_export(artifact_config, *args, &blk)
  artifact = Artifact.new(dapp: dapp, config: artifact_config)
  artifact.export(*args, &blk).tap do
    _export.concat artifact._export
  end
end

#_docker(&blk) ⇒ Object



33
34
35
# File 'lib/dapp/dimg/config/directive/artifact_group.rb', line 33

def _docker(&blk)
  @_docker ||= Docker::Artifact.new(dapp: dapp, &blk)
end

#_exportObject



37
38
39
# File 'lib/dapp/dimg/config/directive/artifact_group.rb', line 37

def _export
  @_export ||= []
end

#_shell(&blk) ⇒ Object



29
30
31
# File 'lib/dapp/dimg/config/directive/artifact_group.rb', line 29

def _shell(&blk)
  @_shell ||= Shell::Artifact.new(dapp: dapp, &blk)
end

#export(*args, &blk) ⇒ Object



13
14
15
# File 'lib/dapp/dimg/config/directive/artifact_group.rb', line 13

def export(*args, &blk)
  _artifact_export(_artifact_config, *args, &blk)
end

#validate!Object



41
42
43
# File 'lib/dapp/dimg/config/directive/artifact_group.rb', line 41

def validate!
  _export.each(&:validate!)
end