-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add New ExecOutput Function To Support Custom Writers (#1331)
* Stream output from KubeExec * Set error in pipe readers instead of a channel * Fix compile errors Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com> * Handle returned error by exec stream Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com> * Don't add error while closing pipe Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com> * Add a new kube.ExecAsync() function to handle async 'exec' outputs This new library function works like kube.Exec(), except that it writes the inbound outputs to stdout and stderr immediately. It delegates the writes to a new format.Writer instance, which formats the outputs to match the Kanister-style logs, before writing them to either stdout or stderr. This ensures that the outputs of the remote exec operation is available to log consumers immediately. Signed-off-by: Ivan Sim <ivan.sim@kasten.io> * Remove merge error Signed-off-by: Ivan Sim <ivan.sim@kasten.io> * Fix unit test Signed-off-by: Ivan Sim <ivan.sim@kasten.io> * Add stdout and stderr as function params Signed-off-by: Ivan Sim <ivan.sim@kasten.io> * Handle phase outputs found in stdout Signed-off-by: Ivan Sim <ivan.sim@kasten.io> Co-authored-by: Tom Manville <tom@kasten.io> Co-authored-by: Prasad Ghangal <prasad.ghangal@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
c3ee585
commit f3801e7
Showing
10 changed files
with
236 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package format | ||
|
||
import ( | ||
"io" | ||
) | ||
|
||
// Writer formats strings before writing them to its underlying writer. | ||
type Writer struct { | ||
W io.Writer | ||
Pod string | ||
Container string | ||
} | ||
|
||
// Write formats p and write it to w's writer. | ||
func (w *Writer) Write(p []byte) (int, error) { | ||
LogTo(w.W, w.Pod, w.Container, string(p)) | ||
return len(p), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.