kitchen-docker 3.2.4 → 3.3.1

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.release-please-manifest.json +1 -1
  4. data/.rubocop.yml +0 -1
  5. data/.yardopts +11 -0
  6. data/CHANGELOG.md +385 -18
  7. data/CONTRIBUTING.md +203 -0
  8. data/Gemfile +5 -3
  9. data/README.md +418 -519
  10. data/Rakefile +18 -0
  11. data/kitchen-docker.gemspec +3 -2
  12. data/lib/kitchen/docker/container/linux.rb +50 -0
  13. data/lib/kitchen/docker/container/windows.rb +27 -0
  14. data/lib/kitchen/docker/container.rb +34 -0
  15. data/lib/kitchen/docker/docker_version.rb +4 -2
  16. data/lib/kitchen/docker/erb_context.rb +9 -0
  17. data/lib/kitchen/docker/helpers/cli_helper.rb +56 -3
  18. data/lib/kitchen/docker/helpers/container_helper.rb +91 -19
  19. data/lib/kitchen/docker/helpers/dockerfile_helper.rb +54 -0
  20. data/lib/kitchen/docker/helpers/file_helper.rb +8 -0
  21. data/lib/kitchen/docker/helpers/image_helper.rb +28 -0
  22. data/lib/kitchen/docker/helpers/inspec_helper.rb +1 -0
  23. data/lib/kitchen/driver/docker.rb +27 -0
  24. data/lib/kitchen/transport/docker.rb +92 -2
  25. data/spec/cli_helper_spec.rb +312 -0
  26. data/spec/container_helper_spec.rb +178 -0
  27. data/spec/dockerfile_helper_spec.rb +97 -61
  28. data/spec/erb_context_spec.rb +60 -0
  29. data/spec/image_helper_spec.rb +142 -0
  30. data/spec/inspec_helper_spec.rb +14 -11
  31. data/spec/linux_container_spec.rb +194 -0
  32. data/spec/spec_helper.rb +28 -1
  33. data/spec/support/argv.rb +55 -0
  34. data/spec/support/docker_output.rb +117 -0
  35. data/spec/support/harness.rb +70 -0
  36. data/spec/transport_docker_spec.rb +130 -0
  37. data/spec/windows_container_spec.rb +101 -0
  38. metadata +16 -7
  39. data/test/integration/capabilities/disabled/capabilities_drop_spec.rb +0 -24
  40. data/test/integration/default/disabled/default_spec.rb +0 -24
  41. data/test/integration/default/disabled/spec_helper.rb +0 -21
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,203 @@
1
+ # Contributing to kitchen-docker
2
+
3
+ Thanks for your interest in improving kitchen-docker. Bug reports, feature
4
+ requests, and pull requests are all welcome.
5
+
6
+ ## Contents
7
+
8
+ * [Reporting issues](#reporting-issues)
9
+ * [Development setup](#development-setup)
10
+ * [Running the unit tests](#running-the-unit-tests)
11
+ * [Running the integration tests](#running-the-integration-tests)
12
+ * [Manual testing](#manual-testing)
13
+ * [Code style](#code-style)
14
+ * [Documentation](#documentation)
15
+ * [Commit messages](#commit-messages)
16
+ * [Submitting changes](#submitting-changes)
17
+ * [Release process](#release-process)
18
+
19
+ ## Reporting issues
20
+
21
+ Source is hosted on [GitHub](https://github.com/test-kitchen/kitchen-docker).
22
+ Report issues, questions, and feature requests on
23
+ [GitHub Issues](https://github.com/test-kitchen/kitchen-docker/issues).
24
+
25
+ For bugs, please include:
26
+
27
+ * the version of kitchen-docker and Test Kitchen you are using
28
+ * your Docker version and host platform (Linux, macOS, Windows, or a remote
29
+ daemon)
30
+ * your `kitchen.yml`
31
+ * the output of the failing command, ideally with `-l debug`
32
+
33
+ The driver builds an image and then runs a container, so the generated
34
+ Dockerfile and the `docker run` command line from a debug run are usually the
35
+ most useful things to attach.
36
+
37
+ ## Development setup
38
+
39
+ ```sh
40
+ git clone https://github.com/test-kitchen/kitchen-docker.git
41
+ cd kitchen-docker
42
+ bundle install
43
+ ```
44
+
45
+ Docker is not needed for the unit tests, only for the integration tests.
46
+
47
+ ## Running the unit tests
48
+
49
+ ```sh
50
+ bundle exec rake # style and unit tests — what CI runs
51
+ bundle exec rake test # unit tests only (alias: rake unit)
52
+ bundle exec rake style # Cookstyle / RuboCop only
53
+ ```
54
+
55
+ To run a single spec file, or a single example:
56
+
57
+ ```sh
58
+ bundle exec rspec spec/docker_spec.rb
59
+ bundle exec rspec spec/docker_spec.rb:42
60
+ ```
61
+
62
+ Specs live in `spec/`, in a flat directory rather than mirroring `lib/`.
63
+
64
+ The unit tests assert on the Dockerfiles and command lines the driver
65
+ generates. They do not talk to a Docker daemon, so they run anywhere and take
66
+ well under a second. Anything that shells out to `docker` belongs in the
67
+ integration tests instead.
68
+
69
+ Examples run in a random order, and the seed is printed at the end of each run.
70
+ If you hit an order-dependent failure, reproduce it with that seed:
71
+
72
+ ```sh
73
+ bundle exec rspec --seed 12345
74
+ ```
75
+
76
+ ## Running the integration tests
77
+
78
+ The integration tests use Test Kitchen to drive this driver against real
79
+ containers, using the `kitchen.yml` in the repository root. They need a working
80
+ Docker daemon.
81
+
82
+ ```sh
83
+ bundle exec kitchen list # every suite/platform combination
84
+ bundle exec kitchen test default-ubuntu-2404 # one of them, end to end
85
+ bundle exec kitchen converge default-ubuntu-2404 # leave it running to poke at
86
+ bundle exec kitchen login default-ubuntu-2404
87
+ bundle exec kitchen destroy default-ubuntu-2404
88
+ ```
89
+
90
+ The suites each exercise a different path through the driver:
91
+
92
+ | Suite | What it covers |
93
+ | --- | --- |
94
+ | `default` | The ordinary path: generated Dockerfile, build, run, converge, verify. |
95
+ | `no-build-context` | `build_context: false`, the path taken against a remote daemon. |
96
+ | `capabilities` | `cap_drop`, and privilege handling generally. |
97
+ | `arm64`, `amd64` | `docker_platform`, i.e. cross-architecture builds under emulation. |
98
+ | `inspec` | The InSpec/Cinc Auditor verifier against the Docker transport. |
99
+ | `docker-test` | The driver used from within a cookbook, via `test/cookbooks/docker_test`. |
100
+
101
+ The `dockerfile` platform covers a user-supplied `dockerfile:`, rendered
102
+ through ERB — see [`test/Dockerfile`](test/Dockerfile).
103
+
104
+ Windows containers use a separate configuration and a Windows host:
105
+
106
+ ```sh
107
+ KITCHEN_YAML=kitchen.windows.yml bundle exec kitchen test
108
+ ```
109
+
110
+ CI runs the full matrix — every suite across roughly eighteen Linux platforms,
111
+ plus Windows — on each pull request, after the lint and unit job passes. See
112
+ [`.github/workflows/lint.yml`](.github/workflows/lint.yml). Running one or two
113
+ suites locally before pushing is usually enough; let CI cover the rest.
114
+
115
+ ## Manual testing
116
+
117
+ The unit tests only check generated commands, so changes affecting the image
118
+ build or container run should also be exercised against a real daemon. These
119
+ take meaningfully different paths through the driver and are worth checking
120
+ separately:
121
+
122
+ * **Linux and Windows containers**, which use different container classes and
123
+ generate different Dockerfiles
124
+ * **a remote daemon**, via `socket`, as well as the local default — this also
125
+ flips the `build_context` default
126
+ * **privileged options** such as `cap_add`, `security_opt`, and `devices`
127
+
128
+ ## Code style
129
+
130
+ The project uses [Cookstyle](https://github.com/chef/cookstyle), a RuboCop
131
+ distribution with Chef's defaults.
132
+
133
+ ```sh
134
+ bundle exec rake style
135
+ bundle exec rake style:autocorrect # safe corrections only
136
+ bundle exec rake style:autocorrect_all # includes unsafe corrections
137
+ ```
138
+
139
+ ## Documentation
140
+
141
+ Public API documentation is written as [YARD](https://yardoc.org) comments in
142
+ `lib/`, and options are documented for users in `README.md`.
143
+
144
+ ```sh
145
+ bundle exec rake doc # generate HTML into doc/
146
+ bundle exec rake doc_coverage # list anything in lib/ still undocumented
147
+ ```
148
+
149
+ `rake doc` should complete with no errors and no warnings. Options and the file
150
+ list live in `.yardopts`, so a bare `yard` produces exactly what `rake doc`
151
+ does.
152
+
153
+ When you add or change a configuration option, update the relevant table in
154
+ `README.md` in the same pull request. If the option needs more than a one-line
155
+ explanation, add a worked example to the README's Examples section.
156
+
157
+ ## Commit messages
158
+
159
+ This project releases with
160
+ [release-please](https://github.com/googleapis/release-please), which builds
161
+ the changelog and picks the next version from commit messages. They must follow
162
+ [Conventional Commits](https://www.conventionalcommits.org/):
163
+
164
+ ```text
165
+ feat: support the --gpus flag
166
+ fix: quote environment variable values containing spaces
167
+ docs: document the transport's TLS options
168
+ chore: bump rubocop
169
+ ```
170
+
171
+ * `feat:` — a new feature; bumps the minor version.
172
+ * `fix:` — a bug fix; bumps the patch version.
173
+ * `docs:`, `chore:`, `test:`, `refactor:` — no release on their own.
174
+ * `feat!:`, or a `BREAKING CHANGE:` footer — bumps the major version.
175
+
176
+ Pull request titles matter too: squash-merged commits take the PR title, so it
177
+ needs the same prefix.
178
+
179
+ ## Submitting changes
180
+
181
+ 1. Fork the repository.
182
+ 2. Create a feature branch off `main`.
183
+ 3. Make your change, adding or updating tests to cover it.
184
+ 4. Make sure `bundle exec rake` passes.
185
+ 5. Push the branch to your fork and open a pull request.
186
+
187
+ Please keep pull requests focused on a single change — it makes review much
188
+ faster.
189
+
190
+ ## Release process
191
+
192
+ Releases are automated; maintainers do not bump versions or edit the changelog
193
+ by hand.
194
+
195
+ 1. release-please opens and maintains a release pull request against `main`,
196
+ with the next version and the generated changelog entries.
197
+ 2. Merging that pull request tags the release and updates
198
+ `lib/kitchen/docker/docker_version.rb` and `CHANGELOG.md`.
199
+ 3. [`.github/workflows/publish.yaml`](.github/workflows/publish.yaml) then
200
+ builds the gem and pushes it to RubyGems.
201
+
202
+ Configuration lives in `release-please-config.json` and
203
+ `.release-please-manifest.json`.
data/Gemfile CHANGED
@@ -1,7 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gemspec
4
-
3
+ gemspec development_group: :test
5
4
  group :development do
6
5
  # Integration testing gems.
7
6
  gem "kitchen-cinc-auditor", git: "https://github.com/test-kitchen/kitchen-cinc-auditor.git"
@@ -11,12 +10,15 @@ group :development do
11
10
  end
12
11
 
13
12
  group :test do
14
- gem "bundler"
15
13
  gem "rake"
16
14
  gem "rspec", "~> 3.2"
17
15
  gem "rspec-its", "~> 2.0"
18
16
  end
19
17
 
18
+ group :docs do
19
+ gem "yard"
20
+ end
21
+
20
22
  group :cookstyle do
21
23
  gem "cookstyle"
22
24
  end