Skip to content
Merged
6 changes: 2 additions & 4 deletions .github/workflows/ruby.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions lib/docker/api/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/docker/api/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 14 additions & 13 deletions lib/dockerapi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ 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" => {
"list" => [:all, :limit, :size, :filters],
"details" => [:size],
"top" => [:ps_args],
"start" => [:detachKeys],
"stop" => [:t],
"restart" => [:t],
"stop" => [:signal, :t],
"restart" => [:signal, :t],
"kill" => [:signal],
"wait" => [:condition],
"rename" => [:name],
Expand All @@ -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],
Expand All @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -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],
Expand All @@ -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],
Expand All @@ -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]
}
}

Expand Down
18 changes: 15 additions & 3 deletions spec/endpoints/container_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion spec/endpoints/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand All @@ -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}}") }
Expand All @@ -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) }
Expand Down
1 change: 1 addition & 0 deletions spec/endpoints/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
3 changes: 3 additions & 0 deletions spec/endpoints/system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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