docker / app

Make your Docker Compose applications reusable, and share them on Docker Hub
Apache License 2.0
1.57k stars 176 forks source link

Compose validation #760

Closed rumpl closed 4 years ago

rumpl commented 4 years ago

- What I did

Created a "framework" to help write validation rules for a compose file, the Validator will do the heavy lifting of traversing all the properties in the compose file.

The validator works in two phases:

A rule has 3 parts:

The Collect method is called in the first phase, rules collect dependent data if needed here. The Accept method is used to filter out only thing that a rule needs to validate The Validate method does the actual validation and returns a list of errors for a given value.

The PR introduces two rules:

In a followup we should:

I won't do them here since the changeset is starting to get big.

- How to verify it Unit and e2e tests were added for the two rules

- A picture of a cute animal (not mandatory) image

codecov[bot] commented 4 years ago

Codecov Report

Merging #760 into master will increase coverage by 1.2%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #760     +/-   ##
=========================================
+ Coverage   70.07%   71.27%   +1.2%     
=========================================
  Files          64       67      +3     
  Lines        3519     3837    +318     
=========================================
+ Hits         2466     2735    +269     
- Misses        727      768     +41     
- Partials      326      334      +8
Impacted Files Coverage Δ
internal/commands/inspect.go 18.03% <0%> (-32.79%) :arrow_down:
internal/validator/rules/relativepath.go 100% <0%> (ø)
internal/validator/rules/externalsecrets.go 100% <0%> (ø)
internal/validator/validator.go 70.49% <0%> (ø)
internal/store/bundle.go 82.39% <0%> (+5.98%) :arrow_up:
internal/commands/build/compose.go 86.66% <0%> (+8.09%) :arrow_up:
internal/packager/extract.go 32.2% <0%> (+8.39%) :arrow_up:
internal/packager/init.go 73.24% <0%> (+8.6%) :arrow_up:
internal/commands/image/rm.go 69.76% <0%> (+11.14%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b621499...582f377. Read the comment docs.