Class: PropertiesFileOutThingy

Inherits:
OutThingy show all
Defined in:
lib/conan/output.rb

Instance Attribute Summary

Attributes inherited from OutThingy

#output_dir, #time

Instance Method Summary collapse

Methods inherited from OutThingy

#initialize, #loadAppMetadataFromDeploymentIfExists, #outputToFile

Constructor Details

This class inherits a constructor from OutThingy

Instance Method Details

#clean(app, environment) ⇒ Object



119
120
121
122
# File 'lib/conan/output.rb', line 119

def clean(app, environment)
  # cleanup current
  FileUtils.rm Dir.glob("#{@output_dir}/#{app.id}-deploy-#{environment.id}-*.properties")
end

#fileName(app, deploy) ⇒ Object



124
125
126
# File 'lib/conan/output.rb', line 124

def fileName(app, deploy)
  "#{app.id}-deploy-#{deploy.environment.id}-#{deploy.shipcloud}.properties"
end

#loadAppMetadataFromDeployment(app, deploy, fail_silent = false) ⇒ Object



128
129
130
131
132
133
134
135
136
# File 'lib/conan/output.rb', line 128

def loadAppMetadataFromDeployment(app, deploy, fail_silent=false)
  path = File.join(@output_dir, fileName(app, deploy))
  if (File.exists? path)
    props = Utils::Properties.load_from_file(path, true)
    app.version = props.get(:DEPLOY_VERSION) # TODO: preserve SHA1
  else
    raise "File not found: #{path}" unless fail_silent
  end
end

#provision(app) ⇒ Object



173
174
175
# File 'lib/conan/output.rb', line 173

def provision(app)
  #noop
end

#writeArtifactMetadata(app, deploy) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/conan/output.rb', line 138

def (app, deploy)
  file_name = fileName(app, deploy)
  out_file = File.join(@output_dir, file_name)
  if (!deploy.enabled?)
    if (File.exists? out_file)
      File.delete(out_file)
    end
    out_file = File.join(@output_dir, "DISABLED-#{file_name}")
  end
  puts "Write: #{out_file}"
  File.open(out_file, 'w') { |f|
    # TODO: would like @time in the manifest as audit field, but not sure it's such a good idea yet
    # f << "\# #{file_name}\n\# #{@time}\n"
    f << "\# #{file_name}\n"
    f << "DEPLOY_ENV=#{deploy.environment.id}\n"
    f << "DEPLOY_INFRA=#{deploy.shipcloud}\n"
    if (deploy.facility_id)
      f << "FACILITY=facility-#{deploy.facility_id}\n"
    end
    unless (deploy.options.empty?)
      options = []
      deploy.options.each do |k, v|
        options << k + '|' + v.join(',')
      end
      p options.join(';')
      f << "OPTIONS=#{options.join(';')}\n"
    end
    f << "APP=#{app.id}\n"
    f << "DEPLOY_SHA1=#{app.sha1}\n"
    f << "DEPLOY_VERSION=#{app.version}\n"
    f << "TYPE=#{app.platform_type}\n"
    f << "\n"
  }
end

#writeConfiguration(app, deploy) ⇒ Object



177
178
179
# File 'lib/conan/output.rb', line 177

def writeConfiguration(app, deploy)
  # noop
end