From b62604caa520dd25806fa5bc2d834f987750bfc9 Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Mon, 26 Jun 2023 19:30:09 -0400 Subject: [PATCH 01/18] Upgrade Docker API version to 1.43 --- .github/workflows/{ruby.yml => ci.yml} | 6 ++---- lib/docker/api/version.rb | 2 +- spec/endpoints/image_spec.rb | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) rename .github/workflows/{ruby.yml => ci.yml} (96%) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ci.yml similarity index 96% rename from .github/workflows/ruby.yml rename to .github/workflows/ci.yml index fd7cddc..357966f 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 ] @@ -39,7 +37,7 @@ jobs: run: rspec spec/endpoints/image_spec.rb:1 - name: Test Image authentication run: rspec spec/endpoints/image_spec.rb:194 - continue-on-error: true + #continue-on-error: true - name: Test Container run: rspec spec/endpoints/container_spec.rb - name: Test Volume 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/spec/endpoints/image_spec.rb b/spec/endpoints/image_spec.rb index 3488b51..c4b2d7d 100644 --- a/spec/endpoints/image_spec.rb +++ b/spec/endpoints/image_spec.rb @@ -63,7 +63,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) } From b0f686b761f151b2f3ddafa1e098f5ced66adde5 Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Wed, 28 Jun 2023 00:04:17 -0400 Subject: [PATCH 02/18] Review container API --- lib/dockerapi.rb | 10 +++++----- spec/endpoints/container_spec.rb | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/dockerapi.rb b/lib/dockerapi.rb index c14f5c5..52ab399 100644 --- a/lib/dockerapi.rb +++ b/lib/dockerapi.rb @@ -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], @@ -130,7 +130,7 @@ 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] 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 From c538ad84fe8428fab47f550aa2ce6a370dfd05cf Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Wed, 5 Jul 2023 22:39:22 -0400 Subject: [PATCH 03/18] Review Image endpoint --- lib/dockerapi.rb | 4 ++-- spec/endpoints/image_spec.rb | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/dockerapi.rb b/lib/dockerapi.rb index 52ab399..a4fc9ab 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" => { diff --git a/spec/endpoints/image_spec.rb b/spec/endpoints/image_spec.rb index c4b2d7d..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}}") } From 4d2a44e16ef15ac10822adc7dc6f72b22bc24d35 Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Wed, 5 Jul 2023 22:44:36 -0400 Subject: [PATCH 04/18] Run tests in a container --- .github/workflows/ci.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 357966f..01517c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,10 +12,8 @@ on: branches: [ master ] jobs: - test: - + misc: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - name: Set up Ruby @@ -31,6 +29,14 @@ jobs: run: | bin/setup sudo bin/setup + endpoints: + runs-on: ubuntu-latest + container: + image: ruby:2.6-alpine + volumes: + - /var/run/docker.sock:/var/run/docker.sock + steps: + - uses: actions/checkout@v3 - name: Test misc run: rspec spec/misc/*.rb - name: Test Image From d478649da057572f13c4e7fedcb8f0907636fb59 Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Wed, 5 Jul 2023 22:46:42 -0400 Subject: [PATCH 05/18] Run tests in a container --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01517c2..f440e31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,9 @@ jobs: run: | bin/setup sudo bin/setup + - uses: actions/checkout@v3 + - name: Test misc + run: rspec spec/misc/*.rb endpoints: runs-on: ubuntu-latest container: @@ -37,8 +40,8 @@ jobs: - /var/run/docker.sock:/var/run/docker.sock steps: - uses: actions/checkout@v3 - - name: Test misc - run: rspec spec/misc/*.rb + - name: Install dependencies + run: bundle install - name: Test Image run: rspec spec/endpoints/image_spec.rb:1 - name: Test Image authentication From d1f4c827bf69e88fd2789007f4ecdc1ff554df4f Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Wed, 5 Jul 2023 22:49:41 -0400 Subject: [PATCH 06/18] Add bundler gem --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f440e31..e7d5de4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Install dependencies - run: bundle install + run: gem install bundler:2.1.4 && bundle install - name: Test Image run: rspec spec/endpoints/image_spec.rb:1 - name: Test Image authentication From 56f8af512e16b501791fe6d61d9fb5bd307390bc Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Wed, 5 Jul 2023 22:54:43 -0400 Subject: [PATCH 07/18] Add git --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7d5de4..ddd88e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Install dependencies - run: gem install bundler:2.1.4 && bundle install + run: apk add git && gem install bundler:2.1.4 && bundle install - name: Test Image run: rspec spec/endpoints/image_spec.rb:1 - name: Test Image authentication From 9db8945fdd253db526287c9a7ec335da0eb0d964 Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Wed, 5 Jul 2023 23:06:48 -0400 Subject: [PATCH 08/18] Add git --- .github/workflows/ci.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ddd88e1..4599738 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,17 +35,19 @@ jobs: endpoints: runs-on: ubuntu-latest container: - image: ruby:2.6-alpine - volumes: - - /var/run/docker.sock:/var/run/docker.sock + image: docker:24.0.2-dind # API version 1.43 steps: + - name: Set up Ruby + uses: ruby/setup-ruby@21351ecc0a7c196081abca5dc55b08f085efe09a + with: + ruby-version: 2.6 - uses: actions/checkout@v3 - name: Install dependencies run: apk add git && gem install bundler:2.1.4 && bundle install - name: Test Image run: rspec spec/endpoints/image_spec.rb:1 - - name: Test Image authentication - run: rspec spec/endpoints/image_spec.rb:194 + #- name: Test Image authentication + # run: rspec spec/endpoints/image_spec.rb:194 #continue-on-error: true - name: Test Container run: rspec spec/endpoints/container_spec.rb From 6276451770ac2c1976559e572d182d36b5f48289 Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Wed, 5 Jul 2023 23:10:42 -0400 Subject: [PATCH 09/18] Remove container --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4599738..7bcffb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,8 +34,6 @@ jobs: run: rspec spec/misc/*.rb endpoints: runs-on: ubuntu-latest - container: - image: docker:24.0.2-dind # API version 1.43 steps: - name: Set up Ruby uses: ruby/setup-ruby@21351ecc0a7c196081abca5dc55b08f085efe09a @@ -43,7 +41,7 @@ jobs: ruby-version: 2.6 - uses: actions/checkout@v3 - name: Install dependencies - run: apk add git && gem install bundler:2.1.4 && bundle install + run: gem install bundler:2.1.4 && bundle install - name: Test Image run: rspec spec/endpoints/image_spec.rb:1 #- name: Test Image authentication From 4b701f9ea4558bc33a0aedc7eed522a03352b223 Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Thu, 6 Jul 2023 09:20:39 -0400 Subject: [PATCH 10/18] Revert changes to CI pipeline --- .github/workflows/ci.yml | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7bcffb6..357966f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,10 @@ on: branches: [ master ] jobs: - misc: + test: + runs-on: ubuntu-latest + steps: - uses: actions/checkout@v2 - name: Set up Ruby @@ -29,23 +31,12 @@ jobs: run: | bin/setup sudo bin/setup - - uses: actions/checkout@v3 - name: Test misc run: rspec spec/misc/*.rb - endpoints: - runs-on: ubuntu-latest - steps: - - name: Set up Ruby - uses: ruby/setup-ruby@21351ecc0a7c196081abca5dc55b08f085efe09a - with: - ruby-version: 2.6 - - uses: actions/checkout@v3 - - name: Install dependencies - run: gem install bundler:2.1.4 && bundle install - name: Test Image run: rspec spec/endpoints/image_spec.rb:1 - #- name: Test Image authentication - # run: rspec spec/endpoints/image_spec.rb:194 + - name: Test Image authentication + run: rspec spec/endpoints/image_spec.rb:194 #continue-on-error: true - name: Test Container run: rspec spec/endpoints/container_spec.rb From 54a9484f36728fc899193ff0a03ab95ad4767495 Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Thu, 6 Jul 2023 09:22:38 -0400 Subject: [PATCH 11/18] Update Image tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 357966f..9929cad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,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 From f99193ff17f6dd58735a16e2c9e91980aa9f1dbe Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Mon, 10 Jul 2023 22:53:47 -0400 Subject: [PATCH 12/18] Review endpoints --- lib/docker/api/system.rb | 4 ++-- lib/dockerapi.rb | 13 +++++++------ spec/endpoints/service_spec.rb | 1 + spec/endpoints/system_spec.rb | 3 +++ 4 files changed, 13 insertions(+), 8 deletions(-) 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/dockerapi.rb b/lib/dockerapi.rb index a4fc9ab..769151e 100644 --- a/lib/dockerapi.rb +++ b/lib/dockerapi.rb @@ -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] @@ -133,7 +134,7 @@ module API "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/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 From 45cc08309711f051402cea83e2234012427301d1 Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Mon, 10 Jul 2023 23:12:41 -0400 Subject: [PATCH 13/18] Add version check --- .github/workflows/ci.yml | 50 +++++++++++----------------------------- Rakefile | 4 ++++ 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9929cad..8feec79 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,10 +12,8 @@ on: branches: [ master ] jobs: - test: - + unit-tests: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - name: Set up Ruby @@ -27,39 +25,19 @@ jobs: ruby-version: 2.6 - name: Install Docker run: curl https://get.docker.com | sh - - name: Install dependencies + - name: Setup docker run: | bin/setup sudo bin/setup - - name: Test misc - run: rspec spec/misc/*.rb - - name: Test Image - run: rspec spec/endpoints/image_spec.rb:1 - - name: Test Image authentication - run: rspec spec/endpoints/image_spec.rb:196 - #continue-on-error: true - - name: Test Container - run: rspec spec/endpoints/container_spec.rb - - name: Test Volume - run: rspec spec/endpoints/volume_spec.rb - - name: Test Network - run: rspec spec/endpoints/network_spec.rb - - name: Test System - run: rspec spec/endpoints/system_spec.rb - - name: Test Exec - run: rspec spec/endpoints/exec_spec.rb - - name: Test Swarm - run: rspec spec/endpoints/swarm_spec.rb - - name: Test Node - run: rspec spec/endpoints/node_spec.rb - - name: Test Service - run: rspec spec/endpoints/service_spec.rb - - name: Test Task - run: rspec spec/endpoints/task_spec.rb - - name: Test Secret - run: rspec spec/endpoints/secret_spec.rb - - name: Test Config - run: rspec spec/endpoints/config_spec.rb - - name: Test Plugin - run: rspec spec/endpoints/plugin_spec.rb - \ No newline at end of file + - name: Run tests + run: rspec + + version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install SVU + run: echo 'deb [trusted=yes] https://apt.fury.io/caarlos0/ /' | tee /etc/apt/sources.list.d/caarlos0.list && apt update -y && apt install svu -y + - name: Check version + run: | + [ $(svu n) != $(rake version | tr -d '"') ] && echo "Need to update version.rb file. Exiting... ";exit 1 \ No newline at end of file diff --git a/Rakefile b/Rakefile index b7e9ed5..6d2c608 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 From 48721086535c66ff31356a8950fbc3e8e0ba611e Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Mon, 10 Jul 2023 23:13:30 -0400 Subject: [PATCH 14/18] Add sudo --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8feec79..7175ff8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Install SVU - run: echo 'deb [trusted=yes] https://apt.fury.io/caarlos0/ /' | tee /etc/apt/sources.list.d/caarlos0.list && apt update -y && apt install svu -y + run: echo 'deb [trusted=yes] https://apt.fury.io/caarlos0/ /' | sudo tee /etc/apt/sources.list.d/caarlos0.list && sudo apt update -y && sudo apt install svu -y - name: Check version run: | [ $(svu n) != $(rake version | tr -d '"') ] && echo "Need to update version.rb file. Exiting... ";exit 1 \ No newline at end of file From 7e54b5215286e18e723e7d26bda5a98a5c9219e4 Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Mon, 10 Jul 2023 23:16:20 -0400 Subject: [PATCH 15/18] Add sudo --- .github/workflows/ci.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7175ff8..c5ad65b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ on: branches: [ master ] jobs: - unit-tests: + ci: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -31,13 +31,8 @@ jobs: sudo bin/setup - name: Run tests run: rspec - - version: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - name: Install SVU run: echo 'deb [trusted=yes] https://apt.fury.io/caarlos0/ /' | sudo tee /etc/apt/sources.list.d/caarlos0.list && sudo apt update -y && sudo apt install svu -y - name: Check version run: | - [ $(svu n) != $(rake version | tr -d '"') ] && echo "Need to update version.rb file. Exiting... ";exit 1 \ No newline at end of file + [ $(svu n) != $(rake version | tr -d '"') ] && echo "Need to update version.rb file to $(svu n). Exiting... ";exit 1 \ No newline at end of file From 85387671541c4245b50f3958439cc0782a1f6825 Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Tue, 11 Jul 2023 15:49:14 -0400 Subject: [PATCH 16/18] Revert test --- .github/workflows/ci.yml | 50 ++++++++++++++++++++++++++++++++-------- Rakefile | 2 +- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5ad65b..15fe147 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,10 +12,17 @@ on: branches: [ master ] jobs: - ci: + test: + runs-on: ubuntu-latest + steps: - uses: actions/checkout@v2 + - name: Install SVU + run: echo 'deb [trusted=yes] https://apt.fury.io/caarlos0/ /' | sudo tee /etc/apt/sources.list.d/caarlos0.list && sudo apt update -y && sudo apt install svu -y + - name: Check version + run: | + [ $(svu n) != $(rake version | tr -d '"') ] && echo "Need to update version.rb file to $(svu n). Exiting... ";exit 1 - name: Set up Ruby # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, # change this to (see https://github.com/ruby/setup-ruby#versioning): @@ -25,14 +32,39 @@ jobs: ruby-version: 2.6 - name: Install Docker run: curl https://get.docker.com | sh - - name: Setup docker + - name: Install dependencies run: | bin/setup sudo bin/setup - - name: Run tests - run: rspec - - name: Install SVU - run: echo 'deb [trusted=yes] https://apt.fury.io/caarlos0/ /' | sudo tee /etc/apt/sources.list.d/caarlos0.list && sudo apt update -y && sudo apt install svu -y - - name: Check version - run: | - [ $(svu n) != $(rake version | tr -d '"') ] && echo "Need to update version.rb file to $(svu n). Exiting... ";exit 1 \ No newline at end of file + - name: Test misc + run: rspec spec/misc/*.rb + - name: Test Image + run: rspec spec/endpoints/image_spec.rb:1 + - name: Test Image authentication + run: rspec spec/endpoints/image_spec.rb:196 + #continue-on-error: true + - name: Test Container + run: rspec spec/endpoints/container_spec.rb + - name: Test Volume + run: rspec spec/endpoints/volume_spec.rb + - name: Test Network + run: rspec spec/endpoints/network_spec.rb + - name: Test System + run: rspec spec/endpoints/system_spec.rb + - name: Test Exec + run: rspec spec/endpoints/exec_spec.rb + - name: Test Swarm + run: rspec spec/endpoints/swarm_spec.rb + - name: Test Node + run: rspec spec/endpoints/node_spec.rb + - name: Test Service + run: rspec spec/endpoints/service_spec.rb + - name: Test Task + run: rspec spec/endpoints/task_spec.rb + - name: Test Secret + run: rspec spec/endpoints/secret_spec.rb + - name: Test Config + run: rspec spec/endpoints/config_spec.rb + - name: Test Plugin + run: rspec spec/endpoints/plugin_spec.rb + \ No newline at end of file diff --git a/Rakefile b/Rakefile index 6d2c608..130635d 100644 --- a/Rakefile +++ b/Rakefile @@ -7,4 +7,4 @@ task :default => :spec task :version do p "v#{Docker::API::GEM_VERSION}" -end +end \ No newline at end of file From cb8aee37594c3aca42b8a37e8d97fd9754de344b Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Tue, 11 Jul 2023 15:50:53 -0400 Subject: [PATCH 17/18] Remove version check --- .github/workflows/ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15fe147..9929cad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,11 +18,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Install SVU - run: echo 'deb [trusted=yes] https://apt.fury.io/caarlos0/ /' | sudo tee /etc/apt/sources.list.d/caarlos0.list && sudo apt update -y && sudo apt install svu -y - - name: Check version - run: | - [ $(svu n) != $(rake version | tr -d '"') ] && echo "Need to update version.rb file to $(svu n). Exiting... ";exit 1 - name: Set up Ruby # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, # change this to (see https://github.com/ruby/setup-ruby#versioning): From 7980ab2da3fa0402fcb3e66b8012aef9d2a61223 Mon Sep 17 00:00:00 2001 From: nu12 <34694287+nu12@users.noreply.github.com> Date: Tue, 11 Jul 2023 16:06:13 -0400 Subject: [PATCH 18/18] Allow authentication to fail --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9929cad..982736e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: run: rspec spec/endpoints/image_spec.rb:1 - name: Test Image authentication run: rspec spec/endpoints/image_spec.rb:196 - #continue-on-error: true + continue-on-error: true - name: Test Container run: rspec spec/endpoints/container_spec.rb - name: Test Volume