本文整理汇总了Golang中github.com/docker/machine/libmachine/log.Fatal函数的典型用法代码示例。如果您正苦于以下问题:Golang Fatal函数的具体用法?Golang Fatal怎么用?Golang Fatal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Fatal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: cmdScp
func cmdScp(c *cli.Context) {
args := c.Args()
if len(args) != 2 {
cli.ShowCommandHelp(c, "scp")
log.Fatal("Improper number of arguments.")
}
// TODO: Check that "-3" flag is available in user's version of scp.
// It is on every system I've checked, but the manual mentioned it's "newer"
sshArgs := append(baseSSHArgs, "-3")
if c.Bool("recursive") {
sshArgs = append(sshArgs, "-r")
}
src := args[0]
dest := args[1]
store := getStore(c)
cmd, err := getScpCmd(src, dest, sshArgs, store)
if err != nil {
log.Fatal(err)
}
if err := runCmdWithStdIo(*cmd); err != nil {
log.Fatal(err)
}
}
示例2: cmdSsh
func cmdSsh(c *cli.Context) {
args := c.Args()
name := args.First()
if name == "" {
log.Fatal("Error: Please specify a machine name.")
}
store := getStore(c)
host, err := store.Load(name)
if err != nil {
log.Fatal(err)
}
currentState, err := host.Driver.GetState()
if err != nil {
log.Fatal(err)
}
if currentState != state.Running {
log.Fatalf("Error: Cannot run SSH command: Host %q is not running", host.Name)
}
client, err := host.CreateSSHClient()
if err != nil {
log.Fatal(err)
}
if err := client.Shell(c.Args().Tail()...); err != nil {
log.Fatal(err)
}
}
示例3: cmdInspect
func cmdInspect(c *cli.Context) {
tmplString := c.String("format")
if tmplString != "" {
var tmpl *template.Template
var err error
if tmpl, err = template.New("").Funcs(funcMap).Parse(tmplString); err != nil {
log.Fatalf("Template parsing error: %v\n", err)
}
jsonHost, err := json.Marshal(getFirstArgHost(c))
if err != nil {
log.Fatal(err)
}
obj := make(map[string]interface{})
if err := json.Unmarshal(jsonHost, &obj); err != nil {
log.Fatal(err)
}
if err := tmpl.Execute(os.Stdout, obj); err != nil {
log.Fatal(err)
}
os.Stdout.Write([]byte{'\n'})
} else {
prettyJSON, err := json.MarshalIndent(getFirstArgHost(c), "", " ")
if err != nil {
log.Fatal(err)
}
fmt.Println(string(prettyJSON))
}
}
示例4: cmdUrl
func cmdUrl(c *cli.Context) {
if len(c.Args()) != 1 {
log.Fatal(ErrExpectedOneMachine)
}
url, err := getFirstArgHost(c).GetURL()
if err != nil {
log.Fatal(err)
}
fmt.Println(url)
}
示例5: fatalOnError
func fatalOnError(command func(context *cli.Context) error) func(context *cli.Context) {
return func(context *cli.Context) {
if err := command(context); err != nil {
log.Fatal(err)
}
}
}
示例6: fatalOnError
func fatalOnError(command func(commandLine CommandLine) error) func(context *cli.Context) {
return func(context *cli.Context) {
if err := command(&contextCommandLine{context}); err != nil {
log.Fatal(err)
}
}
}
示例7: fatalOnError
func fatalOnError(command func(commandLine CommandLine, api libmachine.API) error) func(context *cli.Context) {
return func(context *cli.Context) {
api := libmachine.NewClient(mcndirs.GetBaseDir())
if context.GlobalBool("native-ssh") {
api.SSHClientType = ssh.Native
}
api.GithubAPIToken = context.GlobalString("github-api-token")
api.Filestore.Path = context.GlobalString("storage-path")
crashreport.Configure(context.GlobalString("bugsnag-api-token"))
// TODO (nathanleclaire): These should ultimately be accessed
// through the libmachine client by the rest of the code and
// not through their respective modules. For now, however,
// they are also being set the way that they originally were
// set to preserve backwards compatibility.
mcndirs.BaseDir = api.Filestore.Path
mcnutils.GithubAPIToken = api.GithubAPIToken
ssh.SetDefaultClient(api.SSHClientType)
defer rpcdriver.CloseDrivers()
if err := command(&contextCommandLine{context}, api); err != nil {
log.Fatal(err)
}
}
}
示例8: NewRpcClientDriver
func NewRpcClientDriver(rawDriverData []byte, driverName string) (*RpcClientDriver, error) {
mcnName := ""
p := localbinary.NewLocalBinaryPlugin(driverName)
go func() {
if err := p.Serve(); err != nil {
// If we can't safely load the server, best to just
// bail.
log.Fatal(err)
}
}()
addr, err := p.Address()
if err != nil {
return nil, fmt.Errorf("Error attempting to get plugin server address for RPC: %s", err)
}
rpcclient, err := rpc.DialHTTP("tcp", addr)
if err != nil {
return nil, err
}
c := &RpcClientDriver{
Client: NewInternalClient(rpcclient),
heartbeatDoneCh: make(chan bool),
}
go func(heartbeatDoneCh <-chan bool) {
for {
select {
case <-heartbeatDoneCh:
return
default:
if err := c.Client.Call("RpcServerDriver.Heartbeat", struct{}{}, nil); err != nil {
log.Warnf("Error attempting heartbeat call to plugin server: %s", err)
}
time.Sleep(heartbeatInterval)
}
}
}(c.heartbeatDoneCh)
var version int
if err := c.Client.Call("RpcServerDriver.GetVersion", struct{}{}, &version); err != nil {
return nil, err
}
log.Debug("Using API Version ", version)
if err := c.SetConfigRaw(rawDriverData); err != nil {
return nil, err
}
mcnName = c.GetMachineName()
p.MachineName = mcnName
c.Client.MachineName = mcnName
c.plugin = p
return c, nil
}
示例9: cmdUrl
func cmdUrl(c *cli.Context) {
url, err := getFirstArgHost(c).GetURL()
if err != nil {
log.Fatal(err)
}
fmt.Println(url)
}
示例10: DumpVal
func DumpVal(vals ...interface{}) {
for _, val := range vals {
prettyJSON, err := json.MarshalIndent(val, "", " ")
if err != nil {
log.Fatal(err)
}
log.Debug(string(prettyJSON))
}
}
示例11: runCmdWithStdIo
func runCmdWithStdIo(cmd exec.Cmd) error {
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
log.Fatal(err)
}
return nil
}
示例12: cmdRegenerateCerts
func cmdRegenerateCerts(c *cli.Context) {
force := c.Bool("force")
if force || confirmInput("Regenerate TLS machine certs? Warning: this is irreversible.") {
log.Infof("Regenerating TLS certificates")
if err := runActionWithContext("configureAuth", c); err != nil {
log.Fatal(err)
}
}
}
示例13: main
func main() {
libmachine.SetDebug(true)
log.SetOutWriter(os.Stdout)
log.SetErrWriter(os.Stderr)
// returns the familiar store at $HOME/.docker/machine
store := libmachine.GetDefaultStore()
// over-ride this for now (don't want to muck with my default store)
store.Path = "/tmp/automatic"
hostName := "myfunhost"
// Set some options on the provider...
driver := virtualbox.NewDriver(hostName, "/tmp/automatic")
driver.CPU = 2
driver.Memory = 2048
h, err := store.NewHost(driver)
if err != nil {
log.Fatal(err)
}
h.HostOptions.EngineOptions.StorageDriver = "overlay"
if err := libmachine.Create(store, h); err != nil {
log.Fatal(err)
}
out, err := h.RunSSHCommand("df -h")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Results of your disk space query:\n%s\n", out)
fmt.Println("Powering down machine now...")
if err := h.Stop(); err != nil {
log.Fatal(err)
}
}
示例14: cmdStatus
func cmdStatus(c *cli.Context) {
if len(c.Args()) != 1 {
log.Fatal(ErrExpectedOneMachine)
}
host := getFirstArgHost(c)
currentState, err := host.Driver.GetState()
if err != nil {
log.Errorf("error getting state for host %s: %s", host.Name, err)
}
log.Info(currentState)
}
示例15: main
func main() {
log.SetDebug(true)
client := libmachine.NewClient("/tmp/automatic", "/tmp/automatic/certs")
defer client.Close()
hostName := "myfunhost"
// Set some options on the provider...
driver := virtualbox.NewDriver(hostName, "/tmp/automatic")
driver.CPU = 2
driver.Memory = 2048
data, err := json.Marshal(driver)
if err != nil {
log.Fatal(err)
}
h, err := client.NewHost("virtualbox", data)
if err != nil {
log.Fatal(err)
}
h.HostOptions.EngineOptions.StorageDriver = "overlay"
if err := client.Create(h); err != nil {
log.Fatal(err)
}
out, err := h.RunSSHCommand("df -h")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Results of your disk space query:\n%s\n", out)
fmt.Println("Powering down machine now...")
if err := h.Stop(); err != nil {
log.Fatal(err)
}
}