From 7363311e2d7f7ecc432a09ae9895bfb841138aec Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Tue, 4 Jan 2022 15:41:24 -0800 Subject: [PATCH] fix: add shim for non-supported platforms Adds console_other to support not-supported platforms. Fixes build with: env GOOS=js GOARCH=wasm go build -trimpath . Signed-off-by: Christian Stewart --- console.go | 5 ++++- console_other.go | 36 ++++++++++++++++++++++++++++++++++++ console_windows.go | 5 +---- 3 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 console_other.go diff --git a/console.go b/console.go index 810a71f..c85643c 100644 --- a/console.go +++ b/console.go @@ -22,7 +22,10 @@ import ( "os" ) -var ErrNotAConsole = errors.New("provided file is not a console") +var ( + ErrNotAConsole = errors.New("provided file is not a console") + ErrNotImplemented = errors.New("not implemented") +) type File interface { io.ReadWriteCloser diff --git a/console_other.go b/console_other.go new file mode 100644 index 0000000..933dfad --- /dev/null +++ b/console_other.go @@ -0,0 +1,36 @@ +//go:build !darwin && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows && !zos +// +build !darwin,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows,!zos + +/* + Copyright The containerd 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 console + +// NewPty creates a new pty pair +// The master is returned as the first console and a string +// with the path to the pty slave is returned as the second +func NewPty() (Console, string, error) { + return nil, "", ErrNotImplemented +} + +// checkConsole checks if the provided file is a console +func checkConsole(f File) error { + return ErrNotAConsole +} + +func newMaster(f File) (Console, error) { + return nil, ErrNotImplemented +} diff --git a/console_windows.go b/console_windows.go index f48e486..6896db1 100644 --- a/console_windows.go +++ b/console_windows.go @@ -24,10 +24,7 @@ import ( "golang.org/x/sys/windows" ) -var ( - vtInputSupported bool - ErrNotImplemented = errors.New("not implemented") -) +var vtInputSupported bool func (m *master) initStdios() { // Note: We discard console mode warnings, because in/out can be redirected.