docker-api 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/docker/exec.rb +1 -1
- data/lib/docker/image.rb +1 -1
- data/lib/docker/util.rb +45 -16
- data/lib/docker/version.rb +1 -1
- data/lib/excon/middlewares/hijack.rb +4 -2
- metadata +9 -9
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 8bcdc6793c2627d187d2844a679965abf7903c58b89dc26de88f411feb8d0fd6
         | 
| 4 | 
            +
              data.tar.gz: 3cc8a8aadeee74ab3ba28b25d147b795dae8aff22e53923a2911f36f7bbc3d5d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 6fb00d23f25120f8341002958a9abedbff05bc27e11d5992308063569a640b9e51c3a492a0fdd00dae15e8f6ddbb62bc8c706b8fbe25d6a7c79719178194b328
         | 
| 7 | 
            +
              data.tar.gz: f8fee2e81864164601e6cccd2e3cd3235df383217a2fd0c362a06a9da8448f0ef452306fa6a2d370c02ea95dbe9b9db1669d1ab39cdd4d1b880265fd0e57752d
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,10 +1,10 @@ | |
| 1 1 | 
             
            docker-api
         | 
| 2 2 | 
             
            ==========
         | 
| 3 | 
            -
            [](https://badge.fury.io/rb/docker-api) [](https://badge.fury.io/rb/docker-api) [](https://codeclimate.com/github/upserve/docker-api)
         | 
| 4 4 |  | 
| 5 5 | 
             
            This gem provides an object-oriented interface to the [Docker Engine API](https://docs.docker.com/develop/sdk/). Every method listed there is implemented. At the time of this writing, docker-api is meant to interface with Docker version 1.4.*
         | 
| 6 6 |  | 
| 7 | 
            -
            If you're interested in using Docker to package your apps, we recommend the [dockly](https://github.com/ | 
| 7 | 
            +
            If you're interested in using Docker to package your apps, we recommend the [dockly](https://github.com/upserve/dockly) gem. Dockly provides a simple DSL for describing Docker containers that install as Debian packages and are controlled by upstart scripts.
         | 
| 8 8 |  | 
| 9 9 | 
             
            Installation
         | 
| 10 10 | 
             
            ------------
         | 
    
        data/lib/docker/exec.rb
    CHANGED
    
    | @@ -21,7 +21,7 @@ class Docker::Exec | |
| 21 21 | 
             
                container = options.delete('Container')
         | 
| 22 22 |  | 
| 23 23 | 
             
                # Podman does not attach these by default but does require them to be attached
         | 
| 24 | 
            -
                if ::Docker.podman?
         | 
| 24 | 
            +
                if ::Docker.podman?(conn)
         | 
| 25 25 | 
             
                  options['AttachStderr'] = true if options['AttachStderr'].nil?
         | 
| 26 26 | 
             
                  options['AttachStdout'] = true if options['AttachStdout'].nil?
         | 
| 27 27 | 
             
                end
         | 
    
        data/lib/docker/image.rb
    CHANGED
    
    
    
        data/lib/docker/util.rb
    CHANGED
    
    | @@ -1,8 +1,10 @@ | |
| 1 | 
            +
            require 'set'
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            # This module holds shared logic that doesn't really belong anywhere else in the
         | 
| 2 4 | 
             
            # gem.
         | 
| 3 5 | 
             
            module Docker::Util
         | 
| 4 6 | 
             
              # http://www.tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm#STANDARD-WILDCARDS
         | 
| 5 | 
            -
              GLOB_WILDCARDS = /[\?\*\[\{]/
         | 
| 7 | 
            +
              GLOB_WILDCARDS = /[\?\*\[\{\]\}]/
         | 
| 6 8 |  | 
| 7 9 | 
             
              include Docker::Error
         | 
| 8 10 |  | 
| @@ -142,10 +144,35 @@ module Docker::Util | |
| 142 144 | 
             
                File.new(tempfile.path, 'r')
         | 
| 143 145 | 
             
              end
         | 
| 144 146 |  | 
| 147 | 
            +
             | 
| 148 | 
            +
              # return the set of files that form the docker context
         | 
| 149 | 
            +
              # implement this logic https://docs.docker.com/engine/reference/builder/#dockerignore-file
         | 
| 150 | 
            +
              def docker_context(directory)
         | 
| 151 | 
            +
                all_files = glob_all_files(File.join(directory, "**/*"))
         | 
| 152 | 
            +
                dockerignore = File.join(directory, '.dockerignore')
         | 
| 153 | 
            +
                return all_files unless all_files.include?(dockerignore)
         | 
| 154 | 
            +
             | 
| 155 | 
            +
                # Iterate over valid lines, starting with the initial glob as working set
         | 
| 156 | 
            +
                File
         | 
| 157 | 
            +
                  .read(dockerignore)                # https://docs.docker.com/engine/reference/builder/#dockerignore-file
         | 
| 158 | 
            +
                  .each_line                         # "a newline-separated list of patterns"
         | 
| 159 | 
            +
                  .map(&:strip)                      # "A preprocessing step removes leading and trailing whitespace"
         | 
| 160 | 
            +
                  .reject(&:empty?)                  # "Lines that are blank after preprocessing are ignored"
         | 
| 161 | 
            +
                  .reject { |p| p.start_with?('#') } # "if [a line starts with `#`], then this line is considered as a comment"
         | 
| 162 | 
            +
                  .each_with_object(Set.new(all_files)) do |p, working_set|
         | 
| 163 | 
            +
                    # determine the pattern (p) and whether it is to be added or removed from context
         | 
| 164 | 
            +
                    add = p.start_with?("!")
         | 
| 165 | 
            +
                    # strip leading "!" from pattern p, then prepend the base directory
         | 
| 166 | 
            +
                    matches = dockerignore_compatible_glob(File.join(directory, add ? p[1..-1] : p))
         | 
| 167 | 
            +
                    # add or remove the matched items as indicated in the ignore file
         | 
| 168 | 
            +
                    add ? working_set.merge(matches) : working_set.replace(working_set.difference(matches))
         | 
| 169 | 
            +
                  end
         | 
| 170 | 
            +
                .to_a
         | 
| 171 | 
            +
              end
         | 
| 172 | 
            +
             | 
| 145 173 | 
             
              def create_relative_dir_tar(directory, output)
         | 
| 146 174 | 
             
                Gem::Package::TarWriter.new(output) do |tar|
         | 
| 147 | 
            -
                  files =  | 
| 148 | 
            -
                  remove_ignored_files!(directory, files)
         | 
| 175 | 
            +
                  files = docker_context(directory)
         | 
| 149 176 |  | 
| 150 177 | 
             
                  files.each do |prefixed_file_name|
         | 
| 151 178 | 
             
                    stat = File.stat(prefixed_file_name)
         | 
| @@ -259,21 +286,23 @@ module Docker::Util | |
| 259 286 | 
             
                }
         | 
| 260 287 | 
             
              end
         | 
| 261 288 |  | 
| 262 | 
            -
               | 
| 263 | 
            -
             | 
| 289 | 
            +
              # do a directory glob that matches .dockerignore behavior
         | 
| 290 | 
            +
              # specifically: matched directories are considered a recursive match
         | 
| 291 | 
            +
              def dockerignore_compatible_glob(pattern)
         | 
| 292 | 
            +
                begin
         | 
| 293 | 
            +
                  some_dirs, some_files = glob_all_files(pattern).partition { |f| File.directory?(f) }
         | 
| 294 | 
            +
                  # since all directories will be re-processed with a /**/* glob, we can preemptively
         | 
| 295 | 
            +
                  # eliminate any whose parent directory is already in this set.  This saves significant time.
         | 
| 296 | 
            +
                  some_files + some_dirs.reject { |d| some_dirs.any? { |pd| d.start_with?(pd) && d != pd } }
         | 
| 297 | 
            +
                end.each_with_object(Set.new) do |f, acc|
         | 
| 298 | 
            +
                  # expand any directories by globbing; flatten results
         | 
| 299 | 
            +
                  acc.merge(File.directory?(f) ? glob_all_files("#{f}/**/*") : [f])
         | 
| 300 | 
            +
                end
         | 
| 264 301 | 
             
              end
         | 
| 265 302 |  | 
| 266 | 
            -
              def  | 
| 267 | 
            -
                 | 
| 268 | 
            -
                 | 
| 269 | 
            -
                ignored_files(directory, ignore).each { |f| files.delete(f) }
         | 
| 303 | 
            +
              def glob_all_files(pattern)
         | 
| 304 | 
            +
                # globs of "a_dir/**/*" can return "a_dir/.", so explicitly reject those
         | 
| 305 | 
            +
                (Dir.glob(pattern, File::FNM_DOTMATCH) - ['..', '.']).reject { |p| p.end_with?("/.") }
         | 
| 270 306 | 
             
              end
         | 
| 271 307 |  | 
| 272 | 
            -
              def ignored_files(directory, ignore_file)
         | 
| 273 | 
            -
                patterns = File.read(ignore_file).split("\n").each(&:strip!)
         | 
| 274 | 
            -
                patterns.reject! { |p| p.empty? || p.start_with?('#') }
         | 
| 275 | 
            -
                patterns.map! { |p| File.join(directory, p) }
         | 
| 276 | 
            -
                patterns.map! { |p| File.directory?(p) ? "#{p}/**/*" : p }
         | 
| 277 | 
            -
                patterns.flat_map { |p| p =~ GLOB_WILDCARDS ? glob_all_files(p) : p }
         | 
| 278 | 
            -
              end
         | 
| 279 308 | 
             
            end
         | 
    
        data/lib/docker/version.rb
    CHANGED
    
    
| @@ -1,11 +1,13 @@ | |
| 1 1 | 
             
            module Excon
         | 
| 2 | 
            -
              VALID_REQUEST_KEYS << :hijack_block
         | 
| 3 | 
            -
             | 
| 4 2 | 
             
              module Middleware
         | 
| 5 3 | 
             
                # Hijack is an Excon middleware which parses response headers and then
         | 
| 6 4 | 
             
                # yields the underlying TCP socket for raw TCP communication (used to
         | 
| 7 5 | 
             
                # attach to STDIN of containers).
         | 
| 8 6 | 
             
                class Hijack < Base
         | 
| 7 | 
            +
                  def self.valid_parameter_keys
         | 
| 8 | 
            +
                    [:hijack_block].freeze
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
             | 
| 9 11 | 
             
                  def build_response(status, socket)
         | 
| 10 12 | 
             
                    response = {
         | 
| 11 13 | 
             
                      :body          => '',
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: docker-api
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2. | 
| 4 | 
            +
              version: 2.3.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Swipely, Inc.
         | 
| 8 | 
            -
            autorequire:
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2024-07-08 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: excon
         | 
| @@ -16,14 +16,14 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - ">="
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: 0. | 
| 19 | 
            +
                    version: 0.64.0
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 24 | 
             
                - - ">="
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version: 0. | 
| 26 | 
            +
                    version: 0.64.0
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: multi_json
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -175,11 +175,11 @@ files: | |
| 175 175 | 
             
            - lib/docker/version.rb
         | 
| 176 176 | 
             
            - lib/docker/volume.rb
         | 
| 177 177 | 
             
            - lib/excon/middlewares/hijack.rb
         | 
| 178 | 
            -
            homepage: https://github.com/ | 
| 178 | 
            +
            homepage: https://github.com/upserve/docker-api
         | 
| 179 179 | 
             
            licenses:
         | 
| 180 180 | 
             
            - MIT
         | 
| 181 181 | 
             
            metadata: {}
         | 
| 182 | 
            -
            post_install_message:
         | 
| 182 | 
            +
            post_install_message: 
         | 
| 183 183 | 
             
            rdoc_options: []
         | 
| 184 184 | 
             
            require_paths:
         | 
| 185 185 | 
             
            - lib
         | 
| @@ -194,8 +194,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 194 194 | 
             
                - !ruby/object:Gem::Version
         | 
| 195 195 | 
             
                  version: '0'
         | 
| 196 196 | 
             
            requirements: []
         | 
| 197 | 
            -
            rubygems_version: 3. | 
| 198 | 
            -
            signing_key:
         | 
| 197 | 
            +
            rubygems_version: 3.1.6
         | 
| 198 | 
            +
            signing_key: 
         | 
| 199 199 | 
             
            specification_version: 4
         | 
| 200 200 | 
             
            summary: A simple REST client for the Docker Remote API
         | 
| 201 201 | 
             
            test_files: []
         |