diff --git a/.github/workflows/ruby.yml b/.github/workflows/ci.yml similarity index 95% rename from .github/workflows/ruby.yml rename to .github/workflows/ci.yml index fd7cddc..982736e 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ci.yml @@ -5,11 +5,9 @@ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby -name: Ruby +name: CI on: - push: - branches: [ master ] pull_request: branches: [ master ] @@ -38,7 +36,7 @@ jobs: - name: Test Image run: rspec spec/endpoints/image_spec.rb:1 - name: Test Image authentication - run: rspec spec/endpoints/image_spec.rb:194 + run: rspec spec/endpoints/image_spec.rb:196 continue-on-error: true - name: Test Container run: rspec spec/endpoints/container_spec.rb diff --git a/Rakefile b/Rakefile index b7e9ed5..130635d 100644 --- a/Rakefile +++ b/Rakefile @@ -4,3 +4,7 @@ require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) task :default => :spec + +task :version do + p "v#{Docker::API::GEM_VERSION}" +end \ No newline at end of file diff --git a/lib/docker/api/system.rb b/lib/docker/api/system.rb index 6d329d0..344ee8f 100644 --- a/lib/docker/api/system.rb +++ b/lib/docker/api/system.rb @@ -58,8 +58,8 @@ def version # # Docker API: GET /system/df # @see https://docs.docker.com/engine/api/v1.40/#operation/SystemDataUsage - def df - @connection.get("/system/df") + def df params = {} + @connection.get(build_path("/system/df", params)) end end \ No newline at end of file diff --git a/lib/docker/api/version.rb b/lib/docker/api/version.rb index 8b0b2d1..45b9f23 100644 --- a/lib/docker/api/version.rb +++ b/lib/docker/api/version.rb @@ -2,7 +2,7 @@ module Docker module API GEM_VERSION = "0.19.0" - API_VERSION = "1.41" + API_VERSION = "1.43" VERSION = "Gem: #{Docker::API::GEM_VERSION} | API: #{Docker::API::API_VERSION}" end diff --git a/lib/dockerapi.rb b/lib/dockerapi.rb index c14f5c5..769151e 100644 --- a/lib/dockerapi.rb +++ b/lib/dockerapi.rb @@ -39,14 +39,14 @@ module API "Docker::API::Image" => { "build" => [:dockerfile, :t, :extrahosts, :remote, :q, :nocache, :cachefrom, :pull, :rm, :forcerm, :memory, :memswap, :cpushares, :cpusetcpus, :cpuperiod, :cpuquota, :buildargs, :shmsize, :squash, :labels, :networkmode, :platform, :target, :outputs], "prune" => [:filters], - "list" => [:all, :filters, :digests], + "list" => [:all, :filters, "shared-size", :digests], "search" => [:term, :limit, :filters], "tag" => [:repo, :tag], "remove" => [:force, :noprune], "import" => [:quiet], "push" => [:tag], "commit" => [:container, :repo, :tag, :comment, :author, :pause, :changes], - "create" => [:fromImage, :fromSrc, :repo, :tag, :message, :platform], + "create" => [:fromImage, :fromSrc, :repo, :tag, :message, :changes, :platform], "delete_cache" => [:all, "keep-storage", :filters] }, "Docker::API::Container" => { @@ -54,8 +54,8 @@ module API "details" => [:size], "top" => [:ps_args], "start" => [:detachKeys], - "stop" => [:t], - "restart" => [:t], + "stop" => [:signal, :t], + "restart" => [:signal, :t], "kill" => [:signal], "wait" => [:condition], "rename" => [:name], @@ -64,10 +64,10 @@ module API "remove" => [:v, :force, :link], "logs" => [:follow, :stdout, :stderr, :since, :until, :timestamps, :tail], "attach" => [:detachKeys, :logs, :stream, :stdin, :stdout, :stderr], - "stats" => [:stream], + "stats" => [:stream, "one-shot"], "get_archive" => [:path], "put_archive" => [:path, :noOverwriteDirNonDir, :copyUIDGID], - "create" => [:name] + "create" => [:name, :platform] }, "Docker::API::Volume" => { "list" => [:filters], @@ -80,7 +80,8 @@ module API "prune" => [:filters] }, "Docker::API::System" => { - "events" => [:since, :until, :filters] + "events" => [:since, :until, :filters], + "df" => [:type] }, "Docker::API::Exec" => { "resize" => [:w, :h] @@ -95,7 +96,7 @@ module API "delete" => [:force] }, "Docker::API::Service" => { - "list" => [:filters], + "list" => [:filters, :status], "update" => [:version, :registryAuthFrom, :rollback], "details" => [:insertDefaults], "logs" => [:details, :follow, :stdout, :stderr, :since, :timestamps, :tail] @@ -130,10 +131,10 @@ module API }, "Docker::API::Container" => { "create" => [:Hostname,:Domainname,:User,:AttachStdin,:AttachStdout,:AttachStderr,:ExposedPorts,:Tty,:OpenStdin,:StdinOnce,:Env,:Cmd,:HealthCheck,:ArgsEscaped,:Image,:Volumes,:WorkingDir,:Entrypoint,:NetworkDisabled,:MacAddress,:OnBuild,:Labels,:StopSignal,:StopTimeout,:Shell,:HostConfig,:NetworkingConfig], - "update" => [:CpuShares, :Memory, :CgroupParent, :BlkioWeight, :BlkioWeightDevice, :BlkioWeightReadBps, :BlkioWeightWriteBps, :BlkioWeightReadOps, :BlkioWeightWriteOps, :CpuPeriod, :CpuQuota, :CpuRealtimePeriod, :CpuRealtimeRuntime, :CpusetCpus, :CpusetMems, :Devices, :DeviceCgroupRules, :DeviceRequest, :Kernel, :Memory, :KernelMemoryTCP, :MemoryReservation, :MemorySwap, :MemorySwappiness, :NanoCPUs, :OomKillDisable, :Init, :PidsLimit, :ULimits, :CpuCount, :CpuPercent, :IOMaximumIOps, :IOMaximumBandwidth, :RestartPolicy] + "update" => [:CpuShares, :Memory, :CgroupParent, :BlkioWeight, :BlkioWeightDevice, :BlkioDeviceReadBps, :BlkioDeviceWriteBps, :BlkioDeviceReadIOps, :BlkioDeviceWriteIOps, :CpuPeriod, :CpuQuota, :CpuRealtimePeriod, :CpuRealtimeRuntime, :CpusetCpus, :CpusetMems, :Devices, :DeviceCgroupRules, :DeviceRequest, :Memory, :KernelMemoryTCP, :MemoryReservation, :MemorySwap, :MemorySwappiness, :NanoCPUs, :OomKillDisable, :Init, :PidsLimit, :ULimits, :CpuCount, :CpuPercent, :IOMaximumIOps, :IOMaximumBandwidth, :RestartPolicy] }, "Docker::API::Volume" => { - "create" => [:Name, :Driver, :DriverOpts, :Labels] + "create" => [:Name, :Driver, :DriverOpts, :Labels, :ClusterVolumeSpec] }, "Docker::API::Network" => { "create" => [:Name, :CheckDuplicate, :Driver, :Internal, :Attachable, :Ingress, :IPAM, :EnableIPv6, :Options, :Labels], @@ -144,8 +145,8 @@ module API "auth" => [:username, :password, :email, :serveraddress, :identitytoken] }, "Docker::API::Exec" => { - "create" => [:AttachStdin, :AttachStdout, :AttachStderr, :DetachKeys, :Tty, :Env, :Cmd, :Privileged, :User, :WorkingDir], - "start" => [:Detach, :Tty] + "create" => [:AttachStdin, :AttachStdout, :AttachStderr, :ConsoleSize, :DetachKeys, :Tty, :Env, :Cmd, :Privileged, :User, :WorkingDir], + "start" => [:Detach, :Tty, :ConsoleSize] }, "Docker::API::Swarm" => { "init" => [:ListenAddr, :AdvertiseAddr, :DataPathAddr, :DataPathPort, :DefaultAddrPool, :ForceNewCluster, :SubnetSize, :Spec], @@ -166,7 +167,7 @@ module API }, "Docker::API::Config" => { "create" => [:Name, :Labels, :Data, :Templating], - "update" => [:Name, :Labels, :Data, :Driver, :Templating] + "update" => [:Name, :Labels, :Data, :Templating] } } diff --git a/spec/endpoints/container_spec.rb b/spec/endpoints/container_spec.rb index e7a72ec..694087f 100644 --- a/spec/endpoints/container_spec.rb +++ b/spec/endpoints/container_spec.rb @@ -33,11 +33,18 @@ it { expect(subject.status).to eq(201) } it { expect(id).not_to be(nil) } it { expect(described_class.new.remove(id).success?).to eq(true) } + + end + context "still no name given" do + it { expect(subject.create( {platform: "os/no-arch"}, {Image: image}).status).to eq(404) } end after(:each) { described_class.new.remove(name) } - it { expect{subject.create( {name: name}, {invalid: "invalid"})}.to raise_error(Docker::API::InvalidRequestBody) } - it { expect(subject.create( {name: name}, {Image: image}).status).to eq(201) } + it { expect{subject.create( {name: name}, {invalid: "invalid"})}.to raise_error(Docker::API::InvalidRequestBody) } + it { expect{subject.create( {name: name, invalid: "invalid"}, {Image: image})}.to raise_error(Docker::API::InvalidParameter) } + it { expect(subject.create( {name: name, platform: "linux/amd64"}, {Image: image}).status).to eq(201) } + it { expect(subject.create( {name: name, platform: "os/no-arch"}, {Image: image}).status).to eq(404) } + it { expect(subject.create( {name: name}, {Image: image}).status).to eq(201) } it do response = subject.create( {name: name}, @@ -105,8 +112,10 @@ describe ".stop" do it { expect(subject.stop(name).status).to be(204) } - it { expect(subject.stop("doesn-exist").status).to be(404) } + it { expect(subject.stop(name, {t: 1}).status).to be(204) } + it { expect(subject.stop(name, {signal: "SIGINT"}).status).to be(204) } it { expect{subject.stop(name, {invalid_value: "invalid"})}.to raise_error(Docker::API::InvalidParameter) } + it { expect(subject.stop("doesn-exist").status).to be(404) } it do subject.stop(name) expect(subject.stop(name).status).to be(304) @@ -129,6 +138,7 @@ it { expect(subject.restart(name).status).to be(204) } it { expect(subject.restart("doesn-exist").status).to be(404) } it { expect(subject.restart(name, {t: 2}).status).to eq(204) } + it { expect(subject.restart(name, {signal: "SIGINT"}).status).to eq(204) } it { expect(subject.restart(name, {t: 2}).path).to eq("/containers/#{name}/restart?t=2") } it { expect{subject.restart(name, {invalid_value: "invalid"})}.to raise_error(Docker::API::InvalidParameter) } end @@ -227,6 +237,8 @@ #TODO: implement test to stream response it { expect(subject.stats(name, {stream: false}).status).to eq(200) } it { expect(subject.stats(name, {stream: false}).body).not_to be(nil) } + it { expect(subject.stats(name, {stream: false, "one-shot": true}).status).to eq(200) } + it { expect(subject.stats(name, {stream: false, "one-shot": true}).body).not_to be(nil) } it { expect(subject.stats("doesn-exist", {stream: false}).status).to eq(404) } it { expect{subject.stats(name, {invalid_value: "invalid"})}.to raise_error(Docker::API::InvalidParameter) } end diff --git a/spec/endpoints/image_spec.rb b/spec/endpoints/image_spec.rb index 3488b51..dfab483 100644 --- a/spec/endpoints/image_spec.rb +++ b/spec/endpoints/image_spec.rb @@ -31,6 +31,7 @@ describe "status code" do it { expect(subject.list.status).to eq(200) } it { expect(subject.list(all: true).status).to eq(200) } + it { expect(subject.list(all: true, "shared-size": true).status).to eq(200) } it { expect(subject.list(digests: true).status).to eq(200) } it { expect(subject.list(all: true, digests: true).status).to eq(200) } it { expect(subject.list(all: true, filters: {dangling: {"true": true}}).status).to eq(200) } @@ -41,6 +42,7 @@ end describe "request path" do it { expect(subject.list(all: true).path).to eq("/images/json?all=true") } + it { expect(subject.list(all: true, "shared-size": true).path).to eq("/images/json?all=true&shared-size=true") } it { expect(subject.list(digests: true).path).to eq("/images/json?digests=true") } it { expect(subject.list(all: true, digests: true).path).to eq("/images/json?all=true&digests=true") } it { expect(subject.list(all: true, filters: {dangling: {"true": true}}).path).to eq("/images/json?all=true&filters={\"dangling\":{\"true\":true}}") } @@ -63,7 +65,7 @@ it { expect(subject.history("doesn-exist").status).to eq(404) } end describe ".tag" do - it { expect(subject.tag(image).status).to eq(500) } + it { expect(subject.tag(image).status).to eq(200) } it { expect(subject.tag(image, repo: "dockerapi/tag:1").status).to eq(201) } it { expect(subject.tag(image, repo: "dockerapi/tag", tag: "2").status).to eq(201) } it { expect(subject.tag("doesn-exist", repo: "dockerapi/tag").status).to eq(404) } diff --git a/spec/endpoints/service_spec.rb b/spec/endpoints/service_spec.rb index 05338c5..cd4e4e8 100644 --- a/spec/endpoints/service_spec.rb +++ b/spec/endpoints/service_spec.rb @@ -21,6 +21,7 @@ describe ".list" do it { expect(subject.list.status).to eq(200) } + it { expect(subject.list(status:true).status).to eq(200) } it { expect(subject.list(filters: {id: ["9mnpnzenvg8p8tdbtq4wvbkcz"]}).status).to eq(200) } it { expect(subject.list(filters: {label: ["key=value"]}).status).to eq(200) } it { expect(subject.list(filters: {mode: ["replicated", "global"]}).status).to eq(200) } diff --git a/spec/endpoints/system_spec.rb b/spec/endpoints/system_spec.rb index 2cb0bad..302bd80 100644 --- a/spec/endpoints/system_spec.rb +++ b/spec/endpoints/system_spec.rb @@ -46,5 +46,8 @@ it { expect(subject.df.success?).to eq(true) } it { expect(subject.df.json).to be_kind_of(Hash) } it { expect(subject.df.path).to eq("/system/df") } + it { expect{subject.df(invalid: "true")}.to raise_error(Docker::API::InvalidParameter) } + it { expect{subject.df(type: "container")}.not_to raise_error } + it { expect(subject.df(type: "container").path).to eq("/system/df?type=container" )} end end \ No newline at end of file