Skip to content

Commit d3a9bdd

Browse files
committed
Update deploy to have output during dry-run too
This moves the "normal" deploy output from stdout to stderr so that we can print it all the time (whether it's a dry-run or not), such that dry-run can have the same progress output. Without this, "dry-run" doesn't print any status, especially in the case of 100% "already pushed" (which is the whole reason we implemented dry-run in the first place, so it'd helpful for it to have *some* output).
1 parent 3e3f75b commit d3a9bdd

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cmd/deploy/main.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ func main() {
203203
defer lock.(*sync.RWMutex).RUnlock()
204204
}
205205

206+
logText := ref.StringWithKnownDigest(refsDigest) + logSuffix
207+
fmt.Fprintln(os.Stderr, startedPrefix+logText)
208+
206209
if dryRun {
207210
needsDeploy, err := normal.dryRun(ctx, ref)
208211
if err != nil {
@@ -217,10 +220,13 @@ func main() {
217220
panic(err) // TODO exit in a more clean way (we can't use "os.Exit" because that causes *more* errors 😭)
218221
}
219222
dryRunOut <- j
223+
224+
// 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
225+
fmt.Fprintln(os.Stderr, failurePrefix+logText)
226+
} else {
227+
fmt.Fprintln(os.Stderr, successPrefix+logText)
220228
}
221229
} else {
222-
logText := ref.StringWithKnownDigest(refsDigest) + logSuffix
223-
fmt.Println(startedPrefix + logText)
224230
desc, err := normal.do(ctx, ref)
225231
if err != nil {
226232
fmt.Fprintf(os.Stderr, "%s%s -- ERROR: %v\n", failurePrefix, logText, err)
@@ -229,7 +235,8 @@ func main() {
229235
if ref.Digest == "" && refsDigest == "" {
230236
logText += "@" + string(desc.Digest)
231237
}
232-
fmt.Println(successPrefix + logText)
238+
239+
fmt.Fprintln(os.Stderr, successPrefix+logText)
233240
}
234241
}
235242
if parallel {

0 commit comments

Comments
 (0)