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 string, gateway string) (*io.ReadCloser, error)
- func UntarToDest(ctx CommandContext, sourceStream *io.ReadCloser, destination string, ...) 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-trusuty", } Run(ctx, args)
Output:
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", Tags: []string{"testing", "fake"}, Volumes: []string{"50G", "1G"}, } Run(ctx, args)
Output:
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)
Output:
Example (Complex) ¶
ctx := testCommandContext() args := CreateArgs{ Name: "test", Bootscript: "rescue", Tags: []string{"tag1", "tag2"}, Volumes: []string{}, Image: "ubuntu-vivid", TmpSSHKey: false, } RunCreate(ctx, args)
Output:
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)
Output:
Example (Complex) ¶
ctx := testCommandContext() args := HistoryArgs{ NoTrunc: false, Quiet: false, Image: "", } RunHistory(ctx, args)
Output:
func RunImages ¶
func RunImages(ctx CommandContext, args ImagesArgs) error
RunImages is the handler for 'scw images'
Example ¶
ctx := testCommandContext() args := ImagesArgs{} RunImages(ctx, args)
Output:
Example (All) ¶
ctx := testCommandContext() args := ImagesArgs{ All: true, NoTrunc: false, Quiet: false, } RunImages(ctx, args)
Output:
Example (Complex) ¶
ctx := testCommandContext() args := ImagesArgs{ All: false, NoTrunc: false, Quiet: false, } RunImages(ctx, args)
Output:
Example (Notrunc) ¶
ctx := testCommandContext() args := ImagesArgs{ All: false, NoTrunc: true, Quiet: false, } RunImages(ctx, args)
Output:
Example (Quiet) ¶
ctx := testCommandContext() args := ImagesArgs{ All: false, NoTrunc: false, Quiet: true, } RunImages(ctx, args)
Output:
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)
Output:
Example (Complex) ¶
ctx := testCommandContext() args := InspectArgs{ Format: "", Browser: false, Identifiers: []string{}, } RunInspect(ctx, args)
Output:
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)
Output:
Example (Complex) ¶
ctx := testCommandContext() args := SearchArgs{ Term: "", NoTrunc: false, } RunSearch(ctx, args)
Output:
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 string, gateway string) (*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 string, gateway string) 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)
Output:
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("https://example.org/", "https://example.org/", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") 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)
Output:
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 CreateArgs ¶
type CreateArgs struct { Name string Bootscript string Tags []string Volumes []string Image string TmpSSHKey bool IP string }
CreateArgs are arguments passed to `RunCreate`
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 PsArgs ¶
type PsArgs struct { All bool Latest bool NLast int 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 RmiArgs ¶
type RmiArgs struct {
Identifier []string // images/volumes/snapshots
}
RmiArgs are flags for the `RunRmi` function
type RunArgs ¶
type RunArgs struct { Attach bool Bootscript string Command []string Detach bool Gateway string Image string Name string IP string Tags []string Volumes []string AutoRemove bool TmpSSHKey bool ShowBoot bool Timeout int64 Userdata string }
RunArgs are flags for the `Run` function
type SearchArgs ¶
SearchArgs are flags for the `RunSearch` function