[cipd] Fix auth check logic.
The output of CIPD was changed in upstream to include a period, which
broke Jiri. Instead we should rely on the exit code from `cipd
auth-info` to determine the result. Also annotate the err so we don't
have a mysterious "exit status 1" failure without a clear source.
Bug: 66845
Change-Id: I42098c07e09f8be2d1ba8b9f26779b6715bc894d
Reviewed-on: https://fuchsia-review.googlesource.com/c/jiri/+/464558
Reviewed-by: Marc-Antoine Ruel <maruel@google.com>
Commit-Queue: Marc-Antoine Ruel <maruel@google.com>
Fuchsia-Auto-Submit: Nathan Mulcahey <nmulcahey@google.com>
diff --git a/cipd/cipd.go b/cipd/cipd.go
index 780cd56..3f2244d 100644
--- a/cipd/cipd.go
+++ b/cipd/cipd.go
@@ -61,7 +61,7 @@
windows-386 sha256 59c6d695a24973ef42e731e86fb055827df4f3e060481605e36c6e2d8dfd6ff0
windows-amd64 sha256 1d26180a78ac11c5a940e7f7a26cdf483cf81ccf0e98e29007932a2eb7d621e0
`
- cipdNotLoggedInStr = "Not logged in"
+ exitCodeNoValidToken = 1
cipdManifestInvalidErr = cmdline.ErrExitCode(25)
)
@@ -396,10 +396,10 @@
if err := command.Run(); err != nil {
stdErrMsg := strings.TrimSpace(stderrBuf.String())
jirix.Logger.Debugf("Error happend while executing cipd, err: %q, stderr: %q", err, stdErrMsg)
- if _, ok := err.(*exec.ExitError); ok && stdErrMsg == cipdNotLoggedInStr {
+ if err, ok := err.(*exec.ExitError); ok && err.ExitCode() == exitCodeNoValidToken {
return false, nil
}
- return false, err
+ return false, fmt.Errorf("failed to check `cipd auth-info`: %w", err)
}
return true, nil
}