Merge pull request #31313 from dperny/31306-fix-specify-stdoutstderr
Fix service logs API to be able to specify stream
This commit is contained in:
commit
dd4a6c5aff
1 changed files with 11 additions and 1 deletions
|
@ -277,12 +277,22 @@ func (c *Cluster) ServiceLogs(ctx context.Context, input string, config *backend
|
|||
return err
|
||||
}
|
||||
|
||||
// set the streams we'll use
|
||||
stdStreams := []swarmapi.LogStream{}
|
||||
if config.ContainerLogsOptions.ShowStdout {
|
||||
stdStreams = append(stdStreams, swarmapi.LogStreamStdout)
|
||||
}
|
||||
if config.ContainerLogsOptions.ShowStderr {
|
||||
stdStreams = append(stdStreams, swarmapi.LogStreamStderr)
|
||||
}
|
||||
|
||||
stream, err := state.logsClient.SubscribeLogs(ctx, &swarmapi.SubscribeLogsRequest{
|
||||
Selector: &swarmapi.LogSelector{
|
||||
ServiceIDs: []string{service.ID},
|
||||
},
|
||||
Options: &swarmapi.LogSubscriptionOptions{
|
||||
Follow: config.Follow,
|
||||
Follow: config.Follow,
|
||||
Streams: stdStreams,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue