def gen
      log("Creating zip archivement", env_conf.name)
      start = Time.now
      ebextensions = env_conf.ebextensions
      tmp_file = raw_zip_archive
      tmp_folder = Dir.mktmpdir
      Zip::File.open(tmp_file.path) do |z|
        ebextensions.each do |ex_folder|
          z.remove_folder ex_folder unless ex_folder == ".ebextensions"
          Dir.glob("#{ex_folder}/*.config*") do |fname|
            next unless File.file?(fname)

            basename = File.basename(fname)
            source_file = fname

            if fname.match(/\.erb$/)
              next unless y = YAML::load(ErbHelper.new(File.read(fname), env_conf).result)
              basename = basename.gsub(/\.erb$/,'')
              source_file = "#{tmp_folder}/#{basename}"
              File.open(source_file, 'w') do |f|
                f.write y.to_yaml
              end
            end

            target = ".ebextensions/#{basename}"

            z.remove target if z.find_entry target
            z.remove fname if z.find_entry fname
            z.add target, source_file
          end
        end
        dockerrun_file = env_conf.dockerrun || "Dockerrun.aws.json"

        if File.exists?(dockerrun_file)
          dockerrun = JSON.parse ErbHelper.new(File.read(dockerrun_file), env_conf).result
          tmp_dockerrun = "#{tmp_folder}/Dockerrun.aws.json"
          File.open(tmp_dockerrun, 'w') do |f|
            f.write dockerrun.to_json
          end
          z.remove env_conf.dockerrun if z.find_entry env_conf.dockerrun
          z.remove "Dockerrun.aws.json" if z.find_entry "Dockerrun.aws.json"
          z.add "Dockerrun.aws.json", tmp_dockerrun
        end

      end

      FileUtils.rm_rf tmp_folder
      log("Zip was created in: #{Time.now - start}s", env_conf.name)
      return {
        label: Time.now.strftime("app_#{env_conf.name}_#{version_label}_%Y%m%d_%H%M%S"),
        file: File.open(tmp_file.path),
        message: message,
      }
    end
def gen
      log("Creating zip archivement", env_conf.name)
      start = Time.now
      ebextensions = env_conf.ebextensions
      tmp_file = raw_zip_archive
      tmp_folder = Dir.mktmpdir
      Zip::File.open(tmp_file.path) do |z|
        ebextensions.each do |ex_folder|
          z.remove_folder ex_folder unless ex_folder == ".ebextensions"
          Dir.glob("#{ex_folder}/*.config*") do |fname|
            next unless File.file?(fname)

            basename = File.basename(fname)
            source_file = fname

            if fname.match(/\.erb$/)
              next unless y = YAML::load(ErbHelper.new(File.read(fname), env_conf).result)
              basename = basename.gsub(/\.erb$/,'')
              source_file = "#{tmp_folder}/#{basename}"
              File.open(source_file, 'w') do |f|
                f.write y.to_yaml
              end
            end

            target = ".ebextensions/#{basename}"

            z.remove target if z.find_entry target
            z.remove fname if z.find_entry fname
            z.add target, source_file
          end
        end
        dockerrun_file = env_conf.dockerrun || "Dockerrun.aws.json"

        if File.exists?(dockerrun_file)
          dockerrun = JSON.parse ErbHelper.new(File.read(dockerrun_file), env_conf).result
          tmp_dockerrun = "#{tmp_folder}/Dockerrun.aws.json"
          File.open(tmp_dockerrun, 'w') do |f|
            f.write dockerrun.to_json
          end
          z.remove env_conf.dockerrun if z.find_entry env_conf.dockerrun
          z.remove "Dockerrun.aws.json" if z.find_entry "Dockerrun.aws.json"
          z.add "Dockerrun.aws.json", tmp_dockerrun
        end

      end

      FileUtils.rm_rf tmp_folder
      log("Zip was created in: #{Time.now - start}s", env_conf.name)
      return {
        label: Time.now.strftime("app_#{env_conf.name}_#{version_label}_%Y%m%d_%H%M%S"),
        file: File.open(tmp_file.path),
        message: message,
      }
    end
Create zip archivement