Method: Indocker::Configurations::ConfigurationBuilder#artifacts

Defined in:
lib/indocker/configurations/configuration_builder.rb

#artifacts(server_artifacts) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/indocker/configurations/configuration_builder.rb', line 42

def artifacts(server_artifacts)
  if !server_artifacts.is_a?(Hash)
    Indocker.logger.error("artifacts should be a hash for configuration :#{@configuration.name}")
    exit 1
  end

  server_artifacts.each do |artifact_name, server_names|
    artifact = Indocker.artifacts.detect do |a|
      a.name == artifact_name
    end

    if !artifact
      Indocker.logger.error("artifact :#{artifact_name} was not found")
      exit 1
    end

    if @configuration.servers.empty?
      Indocker.logger.error("artifacts should go after enabled_containers section")
      exit 1
    end

    servers = @configuration.servers.select do |s|
      server_names.include?(s.name)
    end

    servers += @configuration.build_servers.select do |s|
      server_names.include?(s.name)
    end

    extra_servers = server_names - servers.map(&:name)

    if !extra_servers.empty?
      Indocker.logger.error("invalid servers #{extra_servers.inspect} provided for artifact :#{artifact_name}")
      exit 1
    end

    @configuration.set_artifact_servers(artifact, servers)
  end

  self
end