mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
383bbdeebc
This includes the addition of the new "//go:build" comment form in addition to the legacy "// +build" notation, as produced by gofmt to ensure consistent behavior between Go versions. The new directives are all equivalent to what was present before, so there's no change in behavior. Go 1.17 continues to use the Unicode 13 tables as in Go 1.16, so this upgrade does not require also upgrading our Unicode-related dependencies. This upgrade includes the following breaking changes which will also appear as breaking changes for Terraform users, but that are consistent with the Terraform v1.0 compatibility promises. - On MacOS, Terraform now requires macOS 10.13 High Sierra or later. This upgrade also includes the following breaking changes which will appear as breaking changes for Terraform users that are inconsistent with our compatibility promises, but have justified exceptions as follows: - cidrsubnet, cidrhost, and cidrnetmask will now reject IPv4 CIDR addresses whose decimal components have leading zeros, where previously they would just silently ignore those leading zeros. This is a security-motivated exception to our compatibility promises, because some external systems interpret zero-prefixed octets as octal numbers rather than decimal, and thus the previous lenient parsing could lead to a different interpretation of the address between systems, and thus potentially allow bypassing policy when configuring firewall rules etc. This upgrade also includes the following breaking changes which could _potentially_ appear as breaking changes for Terraform users, but that do not in practice for the reasons given: - The Go net/url package no longer allows query strings with pairs separated by semicolons instead of ampersands. This primarily affects HTTP servers written in Go, and Terraform includes a special temporary HTTP server as part of its implementation of OAuth for "terraform login", but that server only needs to accept URLs created by Terraform itself and Terraform does not generate any URLs that would be rejected.
55 lines
1.5 KiB
Go
55 lines
1.5 KiB
Go
//go:build !windows
|
|
// +build !windows
|
|
|
|
package terminal
|
|
|
|
import (
|
|
"os"
|
|
|
|
"golang.org/x/term"
|
|
)
|
|
|
|
// This is the implementation for all operating systems except Windows, where
|
|
// we don't expect to need to do any special initialization to get a working
|
|
// Virtual Terminal.
|
|
//
|
|
// For this implementation we just delegate everything upstream to
|
|
// golang.org/x/term, since it already has a variety of different
|
|
// implementations for quirks of more esoteric operating systems like plan9,
|
|
// and will hopefully grow to include others as Go is ported to other platforms
|
|
// in future.
|
|
//
|
|
// For operating systems that golang.org/x/term doesn't support either, it
|
|
// defaults to indicating that nothing is a terminal and returns an error when
|
|
// asked for a size, which we'll handle below.
|
|
|
|
func configureOutputHandle(f *os.File) (*OutputStream, error) {
|
|
return &OutputStream{
|
|
File: f,
|
|
isTerminal: isTerminalGolangXTerm,
|
|
getColumns: getColumnsGolangXTerm,
|
|
}, nil
|
|
}
|
|
|
|
func configureInputHandle(f *os.File) (*InputStream, error) {
|
|
return &InputStream{
|
|
File: f,
|
|
isTerminal: isTerminalGolangXTerm,
|
|
}, nil
|
|
}
|
|
|
|
func isTerminalGolangXTerm(f *os.File) bool {
|
|
return term.IsTerminal(int(f.Fd()))
|
|
}
|
|
|
|
func getColumnsGolangXTerm(f *os.File) int {
|
|
width, _, err := term.GetSize(int(f.Fd()))
|
|
if err != nil {
|
|
// Suggests that it's either not a terminal at all or that we're on
|
|
// a platform that golang.org/x/term doesn't support. In both cases
|
|
// we'll just return the placeholder default value.
|
|
return defaultColumns
|
|
}
|
|
return width
|
|
}
|