Add a Go converter in a separate tooling module and reintroduce
swagger.yaml as generated Swagger 2.0 output. Preserve schema property
order, examples, and generator extensions, and reject unsupported
constructs. Use the union of response media types for Swagger's
operation-wide produces lists.
Leave historical versioned specifications and generated Go models
unchanged.
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
The regular expression used to exclude non-shell files is too greedy,
resulting in some shell scripts being excluded from the check:
- hack/validate/vendor and hack/vendor.sh (matched "vendor");
- hack/make/.go-autogen (matched ".go").
Use git pathspec instead, excluding the vendor directory and Python
files only. Drop .go, .bats, and Jenkinsfile exclusions, as there
are no such files having a shebang line.
Note that using "shfmt -f ." to find shell scripts is not an option, as it
skips dot-files (e.g. hack/make/.binary) even with --detect=all, and
scripts with a non-standard shebang (contrib/init/openrc/docker.initd).
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Instead of asking a user to run a shfmt with a handful of options, let's
just allow to run hack/validate/shfmt with -w, making it write the
changes (in addition to showing them).
Now, the path component of $0 might differ from that of a user, but this
is still a good hint at where to look for the script.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
shellcheck complains:
> In hack/validate/shfmt line 7:
> if git grep --name-only '^#!' | egrep -v '(vendor|\.go|Jenkinsfile|\.py|\.bats)' \
> ^---^ SC2196 (info): egrep is non-standard and deprecated. Use grep -E instead.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Fix the following shellcheck warning:
> In hack/validate/shfmt line 8:
> | xargs shfmt -d $shfmtflags; then
> ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Currently, hack/validate/default and hack/validate/all source all the
scripts, thus making them part of the current one.
This is wrong for a number of reasons, the main one being any script
being sourced can make changes in the current shell thus influencing all
the scripts that are sourced after it. For example, any script sourced
can set or unset shell variables, change shell options, or just exit.
In fact, four of the scripts have exit statement:
$ git grep -w exit hack/validate/
hack/validate/module-replace: exit 1
hack/validate/pr-gh-references: exit 1
hack/validate/shfmt: exit 1
hack/validate/vendor: exit 1
and most of the others have `set -e` and/or `set -o pipefail`.
This means that if there is any error from any of the scripts,
or even just innocent "exit 0"), all the script below won't be
executed.
To fix this, while still making the "mega" script return an error, let's
run those scripts one by one, checking their exit codes, and exit with
the last non-zero exit code, if any (or 0, if all scripts exited with 0).
While at it, fix some issues reported by shellcheck.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
The DCO job runs inside an Alpine container and fetches the base
branch from VALIDATE_REPO unless VALIDATE_ORIGIN_BRANCH is set.
In forked runs that repository can point at a private upstream URL, so
the unauthenticated fetch fails with:
```
fatal: could not read Username for 'https://github.com': No such
device or address
```
Pass the pull request base SHA so the validator can resolve the
comparison point locally.
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
GitHub issue and PR references in commit messages become part of
persistent history and can create unintended cross-references.
Check commit subjects and bodies for shorthand references such as
<hash>123, moby/moby<hash>123 and GitHub issue or pull-request URLs.
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
The API Dockerfile should be ok to ignore for this check, as it's
not part of the module;
```
================================================
================================================
api diff:
-ARG GO_VERSION=1.25.7
+ARG GO_VERSION=1.25.8
================================================
Detected changes in ./api directory, checking for replace rule...
null
ERROR: Changes detected in ./api but go.mod is missing a replace rule for github.com/moby/moby/api
Please run ./hack/vendor.sh replace
================================================
```
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This flag was deprecated in favor of the `--verbose` flag, which was
already set;
Flag --print-resources-usage has been deprecated, use --verbose instead
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Minor enhancement / follow-up to c8aaeea285c63f9add09e01bd8260d1bce61a97d;
make sure we never attempt to find `go.mod` files in other locations.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Remove the `replace` rule check as it's not needed because it will also
pass the second check.
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Do not require replace rules to be added if there's no code-changes
in the module. Note that changes in api/swagger.yaml may result in
changes in generated code, but this should be checked separate from
the swagger itself.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The bash array usage was wrong - change to a simpler check that just
compares if the diff is empty.
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This change reworks the Go mod tidy/vendor checks to run for all tracked Go modules by the project and fail for any uncommitted changes.
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
This was added in 20d594fb79, but was
written before the API module was added. Now that the API is a separate
module, the check will no longer flag packages importing the API.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The stdcopy package is used to produce and read multiplexed streams for
"attach" and "logs". It is used both by the API server (to produce), and
the client (to read / de-multiplex).
Move it to the api package, so that it can be included in the api module.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
These tests don't account well for submodules and are not needed when
importers are using go modules. The tests are still relevant in the 28
branch which does not use go modules.
Signed-off-by: Derek McGowan <derek@mcg.dev>
The github.com/containerd/containerd/log package was moved to a separate
module, which will also be used by upcoming (patch) releases of containerd.
This patch moves our own uses of the package to use the new module.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- go.mod: update dependencies and go version by
- Use Go1.20
- Fix couple of typos
- Added `WithStdout` and `WithStderr` helpers
- Moved `cmdOperators` handling from `RunCmd` to `StartCmd`
- Deprecate `assert.ErrorType`
- Remove outdated Dockerfile
- add godoc links
full diff: https://github.com/gotestyourself/gotest.tools/compare/v3.4.0...v3.5.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This enforces the github.com/containerd/containerd/errdefs package to
be aliased as "cerrdefs". Any other alias (or no alias used) results
in a linting failure:
integration/container/pause_test.go:9:2: import "github.com/containerd/containerd/errdefs" imported as "c8derrdefs" but must be "cerrdefs" according to config (importas)
c8derrdefs "github.com/containerd/containerd/errdefs"
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Moby is not a Go module; to prevent anyone from mistakenly trying to
convert it to one before we are ready, introduce a check (usable in CI
and locally) for a go.mod file.
This is preferable to trying to .gitignore the file as we can ensure
that a mistakenly created go.mod is surfaced by Git-based tooling and is
less likely to surprise a contributor.
Signed-off-by: Bjorn Neergaard <bneergaard@mirantis.com>