Skip to content

Update deploy to have output during dry-run too #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions cmd/deploy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ func main() {
defer lock.(*sync.RWMutex).RUnlock()
}

logText := ref.StringWithKnownDigest(refsDigest) + logSuffix
fmt.Fprintln(os.Stderr, startedPrefix+logText)

if dryRun {
needsDeploy, err := normal.dryRun(ctx, ref)
if err != nil {
Expand All @@ -217,10 +220,13 @@ func main() {
panic(err) // TODO exit in a more clean way (we can't use "os.Exit" because that causes *more* errors 😭)
}
dryRunOut <- j

// https://github.com/docker-library/meta-scripts/pull/119#discussion_r1978375608 -- "failure" here because we would've pushed, but the configuration (--dry-run) blocks us from doing so
fmt.Fprintln(os.Stderr, failurePrefix+logText)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good argument in favor of dropping the TODO here and just accepting that this is failure is that this case is basically "we do need to push, but were blocked by configuration"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that an unpushed image should be considered a failure on dry-run. Should this also exit at the end with an error if there were things needing to be pushed when doing dry-run?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a harder question -- I think it's more useful/easier to use if "non-empty stdout" means something needed to be pushed, since the whole point is querying what did need to be pushed, and a non-zero exit code then makes it harder to differentiate breaking errors vs just "things need to be pushed".

} else {
fmt.Fprintln(os.Stderr, successPrefix+logText)
}
} else {
logText := ref.StringWithKnownDigest(refsDigest) + logSuffix
fmt.Println(startedPrefix + logText)
desc, err := normal.do(ctx, ref)
if err != nil {
fmt.Fprintf(os.Stderr, "%s%s -- ERROR: %v\n", failurePrefix, logText, err)
Expand All @@ -229,7 +235,8 @@ func main() {
if ref.Digest == "" && refsDigest == "" {
logText += "@" + string(desc.Digest)
}
fmt.Println(successPrefix + logText)

fmt.Fprintln(os.Stderr, successPrefix+logText)
}
}
if parallel {
Expand Down