Sha256: 9132ddbf08c7cc0ff49e62408257925e5796a433d74259aec556040671c32ce8

Contents?: true

Size: 883 Bytes

Versions: 4

Compression:

Stored size: 883 Bytes

Contents

# frozen_string_literal: true

module Cocov
  module PluginKit
    # :nodoc:
    class Realloc
      def self.bindings
        secrets_path = Pathname.new("/secrets")
        bindings_path = secrets_path.join("bindings")
        return {} if !bindings_path.exist? || bindings_path.directory?

        bindings_path.read.split("\0").to_h do |entry|
          from, to = entry.split("=", 2)
          from_path = secrets_path.join(from)
          to_path = Pathname.new(File.expand_path(to))
          [from_path, to_path]
        end
      end

      def self.mounts!
        bindings.each do |from_path, to_path|
          unless from_path.exist?
            puts "Expected binding of #{from_path} to exist, but could not locate it"
            exit 1
          end

          to_path.dirname.mkpath

          FileUtils.cp from_path, to_path
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cocov_plugin_kit-0.1.6 lib/cocov/plugin_kit/realloc.rb
cocov_plugin_kit-0.1.5 lib/cocov/plugin_kit/realloc.rb
cocov_plugin_kit-0.1.4 lib/cocov/plugin_kit/realloc.rb
cocov_plugin_kit-0.1.3 lib/cocov/plugin_kit/realloc.rb