Sha256: ccd44427042379c45af5ebd15b50224fc7959da024c81a930058ac2a16860704

Contents?: true

Size: 902 Bytes

Versions: 1

Compression:

Stored size: 902 Bytes

Contents

module TargetIO
  class Deploy
    def create(file)
      Chef::Log.trace("Touching #{file} to create it")
      TargetIO::FileUtils.touch(file)
    end

    def deploy(src, dst)
      Chef::Log.trace("Reading modes from remote file #{dst}")
      stat = ::TargetIO::File.stat(dst)
      mode = stat.mode & 07777
      uid  = stat.uid
      gid  = stat.gid

      # TODO: Switch to TargetIO::File.open as soon as writing is implemented
      Chef::Log.trace("Uploading local temporary file #{src} as remote file #{dst}")
      connection = Chef.run_context&.transport_connection
      connection.upload(src, dst)

      Chef::Log.trace("Applying mode = #{mode.to_s(8)}, uid = #{uid}, gid = #{gid} to #{dst}")
      ::TargetIO::File.chown(uid, nil, dst)
      ::TargetIO::File.chown(nil, gid, dst)
      ::TargetIO::File.chmod(mode, dst)

      # Local clean up
      File.delete(src)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chef-18.5.0 lib/chef/file_content_management/deploy/target_io.rb