Skip to content

Commit

Permalink
Rename conpty.New to conpty.Create (microsoft#1254)
Browse files Browse the repository at this point in the history
This change renames conpty.New, the method used to create a new ConPTY
object, to Create instead. Mostly preference and to stay in line with what
we'd named the method for creating a job object. The windows API used to
create the pty is named 'CreatePseudoConsole' so to me it makes more sense.

Signed-off-by: Daniel Canter <[email protected]>
  • Loading branch information
dcantah committed Dec 27, 2021
1 parent e1ddd01 commit 0124eb3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions internal/conpty/conpty.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var (
errNotInitialized = errors.New("pseudo console hasn't been initialized")
)

// ConPTY is a wrapper around a Windows PseudoConsole handle. Create a new instance by calling `New()`.
// ConPTY is a wrapper around a Windows PseudoConsole handle. Create a new instance by calling `Create()`.
type ConPTY struct {
// handleLock guards hpc
handleLock sync.RWMutex
Expand All @@ -27,8 +27,8 @@ type ConPTY struct {
outPipe *os.File
}

// New returns a new `ConPTY` object. This object is not ready for IO until `UpdateProcThreadAttribute` is called and a process has been started.
func New(width, height int16, flags uint32) (*ConPTY, error) {
// Create returns a new `ConPTY` object. This object is not ready for IO until `UpdateProcThreadAttribute` is called and a process has been started.
func Create(width, height int16, flags uint32) (*ConPTY, error) {
// First we need to make both ends of the conpty's pipes, two to get passed into a process to use as input/output, and two for us to keep to
// make use of this data.
ptyIn, inPipeOurs, err := os.Pipe()
Expand Down
2 changes: 1 addition & 1 deletion internal/exec/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func TestExecWithJob(t *testing.T) {
}

func TestPseudoConsolePowershell(t *testing.T) {
cpty, err := conpty.New(80, 20, 0)
cpty, err := conpty.Create(80, 20, 0)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/jobcontainers/jobcontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (c *JobContainer) CreateProcess(ctx context.Context, config interface{}) (_

var cpty *conpty.ConPTY
if conf.EmulateConsole {
cpty, err = conpty.New(80, 20, 0)
cpty, err = conpty.Create(80, 20, 0)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 0124eb3

Please sign in to comment.