mirror of
https://github.com/docker/compose.git
synced 2026-02-09 01:59:22 +08:00
configure Compose service with io.Reader and io.Writer
remove usage of internal IO interfaces Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
committed by
Nicolas De loof
parent
86e91e010d
commit
8274be8d08
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
Copyright 2020 Docker Compose CLI authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// OutputStream is a writable stream with terminal detection capabilities
|
||||
type OutputStream interface {
|
||||
io.Writer
|
||||
|
||||
// IsTerminal returns true if the stream is connected to a terminal
|
||||
IsTerminal() bool
|
||||
|
||||
// FD returns the file descriptor for the stream
|
||||
FD() uintptr
|
||||
}
|
||||
|
||||
// InputStream is a readable stream with terminal detection capabilities
|
||||
type InputStream interface {
|
||||
io.Reader
|
||||
|
||||
// IsTerminal returns true if the stream is connected to a terminal
|
||||
IsTerminal() bool
|
||||
|
||||
// FD returns the file descriptor for the stream
|
||||
FD() uintptr
|
||||
}
|
||||
@@ -104,7 +104,7 @@ func NewComposeService(dockerCli command.Cli, options ...Option) (api.Compose, e
|
||||
}
|
||||
|
||||
// WithStreams sets custom I/O streams for output and interaction
|
||||
func WithStreams(out, err api.OutputStream, in api.InputStream) Option {
|
||||
func WithStreams(out, err io.Writer, in io.Reader) Option {
|
||||
return func(s *composeService) error {
|
||||
s.outStream = out
|
||||
s.errStream = err
|
||||
@@ -114,7 +114,7 @@ func WithStreams(out, err api.OutputStream, in api.InputStream) Option {
|
||||
}
|
||||
|
||||
// WithOutputStream sets a custom output stream
|
||||
func WithOutputStream(out api.OutputStream) Option {
|
||||
func WithOutputStream(out io.Writer) Option {
|
||||
return func(s *composeService) error {
|
||||
s.outStream = out
|
||||
return nil
|
||||
@@ -122,7 +122,7 @@ func WithOutputStream(out api.OutputStream) Option {
|
||||
}
|
||||
|
||||
// WithErrorStream sets a custom error stream
|
||||
func WithErrorStream(err api.OutputStream) Option {
|
||||
func WithErrorStream(err io.Writer) Option {
|
||||
return func(s *composeService) error {
|
||||
s.errStream = err
|
||||
return nil
|
||||
@@ -130,7 +130,7 @@ func WithErrorStream(err api.OutputStream) Option {
|
||||
}
|
||||
|
||||
// WithInputStream sets a custom input stream
|
||||
func WithInputStream(in api.InputStream) Option {
|
||||
func WithInputStream(in io.Reader) Option {
|
||||
return func(s *composeService) error {
|
||||
s.inStream = in
|
||||
return nil
|
||||
@@ -197,9 +197,9 @@ type composeService struct {
|
||||
prompt Prompt
|
||||
|
||||
// Optional overrides for specific components (for SDK users)
|
||||
outStream api.OutputStream
|
||||
errStream api.OutputStream
|
||||
inStream api.InputStream
|
||||
outStream io.Writer
|
||||
errStream io.Writer
|
||||
inStream io.Reader
|
||||
contextInfo api.ContextInfo
|
||||
proxyConfig map[string]string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user