Commented out highestUserWastedPercent is not skipped, but set to 0.1
What happened:
i ran:
CI=true dive --source docker-archive --ci-config .dive-ci $TAR_FILE
my .dive-ci file:
rules:
# If the efficiency is measured below X%, mark as failed.
# Expressed as a ratio between 0-1.
lowestEfficiency: 0.99
# If the amount of wasted space is at least X or larger than X, mark as failed.
# Expressed in B, KB, MB, and GB.
# highestWastedBytes: 20MB
# If the amount of wasted space makes up for X% or more of the image, mark as failed.
# Note: the base image layer is NOT included in the total image size.
# Expressed as a ratio between 0-1; fails if the threshold is met or crossed.
# highestUserWastedPercent: 0.30
Commented out highestUserWastedPercent is not skipped, but set to 0.1 -> so it always will fail.
Results:
FAIL: highestUserWastedPercent: too many bytes wasted, relative to the user bytes added (%-user-wasted-bytes=0.2501354787801187 > threshold=0.1)
SKIP: highestWastedBytes: rule disabled
FAIL: lowestEfficiency: image efficiency is too low (efficiency=0.9780414945964051 < threshold=0.99)
Result:FAIL [Total:3] [Passed:0] [Failed:2] [Warn:0] [Skipped:1]
What you expected to happen:
If I comment out rules, they should be skipped.
How to reproduce it (as minimally and precisely as possible):
Comment out rules in CI Mode. but it seems it only affects highestUserWastedPercent.
Anything else we need to know?:
Environment:
- OS version: Gitlab-CI
- Docker version (if applicable): wagoodman/dive@sha256:f1886e6c32c094fc41a623c1989f5cb3e48aa766da5f0be233f911fc1d85ce10
This looks like a special feature of dive rather than a bug: When CI=true, dive first loads the default configuration:
func DefaultCIRules() CIRules {
return CIRules{
LowestEfficiencyThresholdString: "0.9",
HighestWastedBytesString: "disabled",
HighestUserWastedPercentString: "0.1",
}
}
Then it reads the configuration from .dive-ci to override the defaults. Since the default highestWastedBytesString is "disabled", it appears as if the comment is taking effect, but it's actually not. Similarly, commenting out highestUserWastedPercentString won't be treated as skip, but will use the default value of 0.1.
So you can change its value to "disabled" instead of commenting it out, for example: highestUserWastedPercent: disabled
Ah ok, that makes sense, thanks. I will try it out, but i think it is not that clear in the documentation?