/
attach.go
27 lines (23 loc) · 675 Bytes
/
attach.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright (C) 2015 Scaleway. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE.md file.
package commands
import "github.com/scaleway/scaleway-cli/pkg/utils"
// AttachArgs are flags for the `RunAttach` function
type AttachArgs struct {
NoStdin bool
Server string
}
// RunAttach is the handler for 'scw attach'
func RunAttach(ctx CommandContext, args AttachArgs) error {
serverID, err := ctx.API.GetServerID(args.Server)
if err != nil {
return err
}
_, done, err := utils.AttachToSerial(serverID, ctx.API.Token, ctx.API.ResolveTTYUrl())
if err != nil {
return err
}
<-done
return nil
}