Documentation
¶
Overview ¶
Package commands contains the workflows behind each commands of the CLI (run, attach, start, exec, commit, ...)
Index ¶
- func AddSSHKeyToTags(ctx CommandContext, tags *[]string, image string) error
- func Run(ctx CommandContext, args RunArgs) error
- func RunAttach(ctx CommandContext, args AttachArgs) error
- func RunCommit(ctx CommandContext, args CommitArgs) error
- func RunCp(ctx CommandContext, args CpArgs) error
- func RunCreate(ctx CommandContext, args CreateArgs) error
- func RunEvents(ctx CommandContext, args EventsArgs) error
- func RunExec(ctx CommandContext, args ExecArgs) error
- func RunHistory(ctx CommandContext, args HistoryArgs) error
- func RunImages(ctx CommandContext, args ImagesArgs) error
- func RunInfo(ctx CommandContext, args InfoArgs) error
- func RunInspect(ctx CommandContext, args InspectArgs) error
- func RunKill(ctx CommandContext, args KillArgs) error
- func RunLogin(ctx CommandContext, args LoginArgs) error
- func RunLogout(ctx CommandContext, args LogoutArgs) error
- func RunLogs(ctx CommandContext, args LogsArgs) error
- func RunPort(ctx CommandContext, args PortArgs) error
- func RunPs(ctx CommandContext, args PsArgs) error
- func RunRename(ctx CommandContext, args RenameArgs) error
- func RunRestart(ctx CommandContext, args RestartArgs) error
- func RunRm(ctx CommandContext, args RmArgs) error
- func RunRmi(ctx CommandContext, args RmiArgs) error
- func RunSearch(ctx CommandContext, args SearchArgs) error
- func RunStart(ctx CommandContext, args StartArgs) error
- func RunStop(ctx CommandContext, args StopArgs) error
- func RunTag(ctx CommandContext, args TagArgs) error
- func RunTop(ctx CommandContext, args TopArgs) error
- func RunWait(ctx CommandContext, args WaitArgs) error
- func TarFromSource(ctx CommandContext, source, gateway, user string, port int) (*io.ReadCloser, error)
- func UntarToDest(ctx CommandContext, sourceStream *io.ReadCloser, ...) error
- func Version(ctx CommandContext, args VersionArgs) error
- type AttachArgs
- type CommandContext
- type CommitArgs
- type CpArgs
- type CreateArgs
- type EventsArgs
- type ExecArgs
- type HistoryArgs
- type ImagesArgs
- type InfoArgs
- type InspectArgs
- type KillArgs
- type LoginArgs
- type LogoutArgs
- type LogsArgs
- type PortArgs
- type PsArgs
- type RenameArgs
- type RestartArgs
- type RmArgs
- type RmiArgs
- type RunArgs
- type SearchArgs
- type StartArgs
- type StopArgs
- type Streams
- type TagArgs
- type TopArgs
- type VersionArgs
- type WaitArgs
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSSHKeyToTags ¶
func AddSSHKeyToTags(ctx CommandContext, tags *[]string, image string) error
AddSSHKeyToTags adds the ssh key in the tags
func Run ¶
func Run(ctx CommandContext, args RunArgs) error
Run is the handler for 'scw run'
Example ¶
ctx := testCommandContext()
args := RunArgs{
Image: "ubuntu-trusty",
CommercialType: "VC1S",
}
Run(ctx, args)
Example (Complex) ¶
ctx := testCommandContext()
args := RunArgs{
Attach: false,
Bootscript: "rescue",
Command: []string{"ls", "-la"},
Detach: false,
Gateway: "my-gateway",
Image: "ubuntu-trusty",
Name: "my-test-server",
CommercialType: "VC1S",
Tags: []string{"testing", "fake"},
Volumes: []string{"50G", "1G"},
}
Run(ctx, args)
func RunAttach ¶
func RunAttach(ctx CommandContext, args AttachArgs) error
RunAttach is the handler for 'scw attach'
func RunCommit ¶
func RunCommit(ctx CommandContext, args CommitArgs) error
RunCommit is the handler for 'scw commit'
func RunCreate ¶
func RunCreate(ctx CommandContext, args CreateArgs) error
RunCreate is the handler for 'scw create'
Example ¶
ctx := testCommandContext()
args := CreateArgs{}
RunCreate(ctx, args)
Example (Complex) ¶
ctx := testCommandContext()
args := CreateArgs{
Name: "test",
Bootscript: "rescue",
Tags: []string{"tag1", "tag2"},
Volumes: []string{},
Image: "ubuntu-wily",
TmpSSHKey: false,
}
RunCreate(ctx, args)
func RunEvents ¶
func RunEvents(ctx CommandContext, args EventsArgs) error
RunEvents is the handler for 'scw events'
func RunExec ¶
func RunExec(ctx CommandContext, args ExecArgs) error
RunExec is the handler for 'scw exec'
func RunHistory ¶
func RunHistory(ctx CommandContext, args HistoryArgs) error
RunHistory is the handler for 'scw history'
Example ¶
ctx := testCommandContext()
args := HistoryArgs{}
RunHistory(ctx, args)
Example (Complex) ¶
ctx := testCommandContext()
args := HistoryArgs{
NoTrunc: false,
Quiet: false,
Image: "",
}
RunHistory(ctx, args)
func RunImages ¶
func RunImages(ctx CommandContext, args ImagesArgs) error
RunImages is the handler for 'scw images'
Example ¶
ctx := testCommandContext()
args := ImagesArgs{}
RunImages(ctx, args)
Example (All) ¶
ctx := testCommandContext()
args := ImagesArgs{
All: true,
NoTrunc: false,
Quiet: false,
}
RunImages(ctx, args)
Example (Complex) ¶
ctx := testCommandContext()
args := ImagesArgs{
All: false,
NoTrunc: false,
Quiet: false,
}
RunImages(ctx, args)
Example (Notrunc) ¶
ctx := testCommandContext()
args := ImagesArgs{
All: false,
NoTrunc: true,
Quiet: false,
}
RunImages(ctx, args)
Example (Quiet) ¶
ctx := testCommandContext()
args := ImagesArgs{
All: false,
NoTrunc: false,
Quiet: true,
}
RunImages(ctx, args)
func RunInfo ¶
func RunInfo(ctx CommandContext, args InfoArgs) error
RunInfo is the handler for 'scw info'
func RunInspect ¶
func RunInspect(ctx CommandContext, args InspectArgs) error
RunInspect is the handler for 'scw inspect'
Example ¶
ctx := testCommandContext()
args := InspectArgs{}
RunInspect(ctx, args)
Example (Complex) ¶
ctx := testCommandContext()
args := InspectArgs{
Format: "",
Browser: false,
Identifiers: []string{},
}
RunInspect(ctx, args)
func RunKill ¶
func RunKill(ctx CommandContext, args KillArgs) error
RunKill is the handler for 'scw kill'
func RunLogin ¶
func RunLogin(ctx CommandContext, args LoginArgs) error
RunLogin is the handler for 'scw login'
func RunLogout ¶
func RunLogout(ctx CommandContext, args LogoutArgs) error
RunLogout is the handler for 'scw logout'
func RunLogs ¶
func RunLogs(ctx CommandContext, args LogsArgs) error
RunLogs is the handler for 'scw logs'
func RunPort ¶
func RunPort(ctx CommandContext, args PortArgs) error
RunPort is the handler for 'scw port'
func RunRename ¶
func RunRename(ctx CommandContext, args RenameArgs) error
RunRename is the handler for 'scw rename'
func RunRestart ¶
func RunRestart(ctx CommandContext, args RestartArgs) error
RunRestart is the handler for 'scw restart'
func RunRmi ¶
func RunRmi(ctx CommandContext, args RmiArgs) error
RunRmi is the handler for 'scw rmi'
func RunSearch ¶
func RunSearch(ctx CommandContext, args SearchArgs) error
RunSearch is the handler for 'scw search'
Example ¶
ctx := testCommandContext()
args := SearchArgs{}
RunSearch(ctx, args)
Example (Complex) ¶
ctx := testCommandContext()
args := SearchArgs{
Term: "",
NoTrunc: false,
}
RunSearch(ctx, args)
func RunStart ¶
func RunStart(ctx CommandContext, args StartArgs) error
RunStart is the handler for 'scw start'
func RunStop ¶
func RunStop(ctx CommandContext, args StopArgs) error
RunStop is the handler for 'scw stop'
func RunTag ¶
func RunTag(ctx CommandContext, args TagArgs) error
RunTag is the handler for 'scw tag'
func RunTop ¶
func RunTop(ctx CommandContext, args TopArgs) error
RunTop is the handler for 'scw top'
func RunWait ¶
func RunWait(ctx CommandContext, args WaitArgs) error
RunWait is the handler for 'scw wait'
func TarFromSource ¶
func TarFromSource(ctx CommandContext, source, gateway, user string, port int) (*io.ReadCloser, error)
TarFromSource creates a stream buffer with the tarballed content of the user source
func UntarToDest ¶
func UntarToDest(ctx CommandContext, sourceStream *io.ReadCloser, destination, gateway, user string, port int) error
UntarToDest writes to user destination the streamed tarball in input
func Version ¶
func Version(ctx CommandContext, args VersionArgs) error
Version is the handler for 'scw version'
Example ¶
ctx := testCommandContext()
args := VersionArgs{}
Version(ctx, args)
Types ¶
type AttachArgs ¶
AttachArgs are flags for the `RunAttach` function
type CommandContext ¶
type CommandContext struct {
Streams
Env []string
RawArgs []string
API *api.ScalewayAPI
}
CommandContext is passed to all commands and contains streams, environment, api and arguments
Example ¶
apiClient, err := api.NewScalewayAPI("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", scwversion.UserAgent(), "")
if err != nil {
panic(err)
}
ctx := CommandContext{
Streams: Streams{
Stdin: os.Stdin,
Stdout: os.Stdout,
Stderr: os.Stderr,
},
Env: []string{
"HOME" + os.Getenv("HOME"),
},
RawArgs: []string{},
API: apiClient,
}
// Do stuff
fmt.Println(ctx)
func RealAPIContext ¶
func RealAPIContext() *CommandContext
RealAPIContext returns a CommandContext with a configured API
func (*CommandContext) Getenv ¶
func (c *CommandContext) Getenv(key string) string
Getenv returns the equivalent of os.Getenv for the CommandContext.Env
type CommitArgs ¶
CommitArgs are flags for the `RunCommit` function
type CpArgs ¶
CpArgs are arguments passed to `RunCp`
type CreateArgs ¶
type CreateArgs struct {
Volumes []string
Tags []string
Name string
Bootscript string
Image string
IP string
CommercialType string
TmpSSHKey bool
IPV6 bool
}
CreateArgs are arguments passed to `RunCreate`
type ExecArgs ¶
type ExecArgs struct {
Timeout float64
Wait bool
Gateway string
Server string
Command []string
SSHUser string
SSHPort int
}
ExecArgs are flags for the `RunExec` function
type HistoryArgs ¶
HistoryArgs are flags for the `RunHistory` function
type ImagesArgs ¶
ImagesArgs are flags for the `RunImages` function
type InspectArgs ¶
InspectArgs are flags for the `RunInspect` function
type KillArgs ¶
KillArgs are flags for the `RunKill` function
type LoginArgs ¶
LoginArgs are arguments passed to `RunLogin`
type LogsArgs ¶
LogsArgs are flags for the `RunLogs` function
type PortArgs ¶
PortArgs are flags for the `RunPort` function
type PsArgs ¶
type PsArgs struct {
NLast int
All bool
Latest bool
NoTrunc bool
Quiet bool
Filters map[string]string
}
PsArgs are flags for the `RunPs` function
type RenameArgs ¶
RenameArgs are flags for the `RunRename` function
type RestartArgs ¶
RestartArgs are flags for the `RunRestart` function
type RmArgs ¶
RmArgs are flags for the `RunRm` function
type RmiArgs ¶
type RmiArgs struct {
Identifier []string // images/volumes/snapshots
}
RmiArgs are flags for the `RunRmi` function
type RunArgs ¶
type RunArgs struct {
Bootscript string
Command []string
Gateway string
Image string
Name string
IP string
Tags []string
Volumes []string
Userdata string
CommercialType string
State string
SSHUser string
Timeout int64
SSHPort int
AutoRemove bool
TmpSSHKey bool
ShowBoot bool
Detach bool
Attach bool
IPV6 bool
}
RunArgs are flags for the `Run` function
type SearchArgs ¶
SearchArgs are flags for the `RunSearch` function
type StartArgs ¶
StartArgs are flags for the `RunStart` function
type StopArgs ¶
StopArgs are flags for the `RunStop` function
type Streams ¶
Streams is used to redirects the streams
type TagArgs ¶
TagArgs are flags for the `RunTag` function
type TopArgs ¶
TopArgs are flags for the `RunTop` function
Source Files
¶
- attach.go
- command.go
- commit.go
- cp.go
- create.go
- events.go
- exec.go
- help.go
- history.go
- images.go
- info.go
- inspect.go
- kill.go
- login.go
- logout.go
- logs.go
- port.go
- ps.go
- rename.go
- restart.go
- rm.go
- rmi.go
- run.go
- search.go
- start.go
- stop.go
- tag.go
- test.go
- top.go
- version.go
- wait.go