Skip to content

Commit

Permalink
plugin: fix Plugin.Confirm again
Browse files Browse the repository at this point in the history
  • Loading branch information
FiloSottile committed Jun 21, 2024
1 parent 6fa7022 commit 8734a85
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,9 @@ func (p *Plugin) DisplayMessage(message string) error {
if s.Type == "fail" {
return fmt.Errorf("client failed to display message")
}
if err := expectStanzaWithNoBody(s, 0); err != nil {
return p.fatalInteractf("%v", err)
}
return nil
}

Expand All @@ -474,6 +477,9 @@ func (p *Plugin) RequestValue(prompt string, secret bool) (string, error) {
if s.Type == "fail" {
return "", fmt.Errorf("client failed to request value")
}
if err := expectStanzaWithBody(s, 0); err != nil {
return "", p.fatalInteractf("%v", err)
}
return string(s.Body), nil
}

Expand Down Expand Up @@ -571,9 +577,6 @@ func readOkOrFail(sr *format.StanzaReader) (*format.Stanza, error) {
}
return s, nil
case "ok":
if s.Body != nil {
return nil, fmt.Errorf("ok stanza has %d bytes of body, want 0", len(s.Body))
}
return s, nil
default:
return nil, fmt.Errorf("expected ok or fail stanza, got %q", s.Type)
Expand Down

0 comments on commit 8734a85

Please sign in to comment.