当前位置: 首页>>代码示例>>Golang>>正文


Golang log.Fatalf函数代码示例

本文整理汇总了Golang中github.com/docker/machine/libmachine/log.Fatalf函数的典型用法代码示例。如果您正苦于以下问题:Golang Fatalf函数的具体用法?Golang Fatalf怎么用?Golang Fatalf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Fatalf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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)
	}
}
开发者ID:hanazuki,项目名称:machine,代码行数:32,代码来源:ssh.go

示例2: 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))
	}
}
开发者ID:rwilliams,项目名称:machine,代码行数:31,代码来源:inspect.go

示例3: removeFileIfExists

func removeFileIfExists(name string) error {
	if _, err := os.Stat(name); err == nil {
		if err := os.Remove(name); err != nil {
			log.Fatalf("Error removing temporary download file: %s", err)
		}
	}
	return nil
}
开发者ID:rominirani,项目名称:machine,代码行数:8,代码来源:b2d.go

示例4: cmdNotFound

func cmdNotFound(c *cli.Context, command string) {
	log.Fatalf(
		"%s: '%s' is not a %s command. See '%s --help'.",
		c.App.Name,
		command,
		c.App.Name,
		os.Args[0],
	)
}
开发者ID:kristiandelay,项目名称:machine,代码行数:9,代码来源:machine.go

示例5: DownloadISO

// Download boot2docker ISO image for the given tag and save it at dest.
func (b *B2dUtils) DownloadISO(dir, file, isoUrl string) error {
	u, err := url.Parse(isoUrl)
	var src io.ReadCloser
	if u.Scheme == "file" || u.Scheme == "" {
		s, err := os.Open(u.Path)
		if err != nil {
			return err
		}
		src = s
	} else {
		client := getClient()
		s, err := client.Get(isoUrl)
		if err != nil {
			return err
		}
		src = s.Body
	}

	defer src.Close()

	// Download to a temp file first then rename it to avoid partial download.
	f, err := ioutil.TempFile(dir, file+".tmp")
	if err != nil {
		return err
	}

	defer func() {
		if err := removeFileIfExists(f.Name()); err != nil {
			log.Fatalf("Error removing file: %s", err)
		}
	}()

	if _, err := io.Copy(f, src); err != nil {
		// TODO: display download progress?
		return err
	}

	if err := f.Close(); err != nil {
		return err
	}

	// Dest is the final path of the boot2docker.iso file.
	dest := filepath.Join(dir, file)

	// Windows can't rename in place, so remove the old file before
	// renaming the temporary downloaded file.
	if err := removeFileIfExists(dest); err != nil {
		return err
	}

	if err := os.Rename(f.Name(), dest); err != nil {
		return err
	}

	return nil
}
开发者ID:rominirani,项目名称:machine,代码行数:57,代码来源:b2d.go

示例6: NewDriver

func NewDriver() *Driver {
	d := &Driver{}
	conn, err := libvirt.NewVirConnection(d.connectionString)
	if err != nil {
		log.Fatalf("Failed to connect to libvirt: %s", err)
	}
	d.conn = &conn
	d.PrivateNetwork = privateNetworkName
	return d
}
开发者ID:b0d0nne11,项目名称:docker-machine-kvm,代码行数:10,代码来源:kvm.go

示例7: generateId

func generateId() string {
	rb := make([]byte, 10)
	_, err := rand.Read(rb)
	if err != nil {
		log.Fatalf("Unable to generate id: %s", err)
	}

	h := md5.New()
	io.WriteString(h, string(rb))
	return fmt.Sprintf("%x", h.Sum(nil))
}
开发者ID:chuchengcao,项目名称:machine,代码行数:11,代码来源:ecs.go

示例8: getFirstArgHost

func getFirstArgHost(c *cli.Context) *host.Host {
	store := getStore(c)
	hostName := c.Args().First()
	h, err := store.Load(hostName)
	if err != nil {
		// I guess I feel OK with bailing here since if we can't get
		// the host reliably we're definitely not going to be able to
		// do anything else interesting, but also this premature exit
		// feels wrong to me.  Let's revisit it later.
		log.Fatalf("Error trying to get host %q: %s", hostName, err)
	}
	return h
}
开发者ID:Grynn,项目名称:machine,代码行数:13,代码来源:commands.go

示例9: cmdActive

func cmdActive(c *cli.Context) {
	if len(c.Args()) > 0 {
		log.Fatal("Error: Too many arguments given.")
	}

	store := getStore(c)
	host, err := getActiveHost(store)
	if err != nil {
		log.Fatalf("Error getting active host: %s", err)
	}

	if host != nil {
		fmt.Println(host.Name)
	}
}
开发者ID:rominirani,项目名称:machine,代码行数:15,代码来源:active.go

示例10: NewDriver

func NewDriver(hostName, storePath string) drivers.Driver {
	conn, err := libvirt.NewVirConnection(connectionString)
	if err != nil {
		log.Fatalf("Failed to connect to libvirt: %s", err)
		return nil
	}

	return &Driver{
		conn:           &conn,
		PrivateNetwork: privateNetworkName,
		BaseDriver: &drivers.BaseDriver{
			MachineName: hostName,
			StorePath:   storePath,
		},
	}
}
开发者ID:rsampaio,项目名称:docker-machine-kvm,代码行数:16,代码来源:kvm.go

示例11: cmdConfig

func cmdConfig(c *cli.Context) {
	if len(c.Args()) != 1 {
		log.Fatal(ErrExpectedOneMachine)
	}

	h := getFirstArgHost(c)

	dockerHost, authOptions, err := runConnectionBoilerplate(h, c)
	if err != nil {
		log.Fatalf("Error running connection boilerplate: %s", err)
	}

	log.Debug(dockerHost)

	fmt.Printf("--tlsverify --tlscacert=%q --tlscert=%q --tlskey=%q -H=%s",
		authOptions.CaCertPath, authOptions.ClientCertPath, authOptions.ClientKeyPath, dockerHost)
}
开发者ID:rominirani,项目名称:machine,代码行数:17,代码来源:config.go

示例12: 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)
	}

	if len(c.Args()) == 1 {
		err := host.CreateSSHShell()
		if err != nil {
			log.Fatal(err)
		}
	} else {
		output, err := host.RunSSHCommand(strings.Join(c.Args().Tail(), " "))
		if err != nil {
			log.Fatal(err)
		}

		fmt.Print(output)
	}

}
开发者ID:rominirani,项目名称:machine,代码行数:38,代码来源:ssh.go

示例13: tokenFromWeb

func tokenFromWeb(config *oauth.Config) *oauth.Token {
	randState := fmt.Sprintf("st%d", time.Now().UnixNano())

	config.RedirectURL = RedirectURI
	authURL := config.AuthCodeURL(randState)

	log.Info("Opening auth URL in browser.")
	log.Info(authURL)
	log.Info("If the URL doesn't open please open it manually and copy the code here.")
	openURL(authURL)
	code := getCodeFromStdin()

	log.Infof("Got code: %s", code)

	t := &oauth.Transport{
		Config:    config,
		Transport: http.DefaultTransport,
	}
	_, err := t.Exchange(code)
	if err != nil {
		log.Fatalf("Token exchange error: %v", err)
	}
	return t.Token
}
开发者ID:rominirani,项目名称:machine,代码行数:24,代码来源:auth_util.go

示例14: fatalf

func fatalf(fmtString string, args ...interface{}) {
	close(RpcClientDriversCh)
	<-RpcDriversClosedCh
	log.Fatalf(fmtString, args...)
}
开发者ID:KorayAgaya,项目名称:machine,代码行数:5,代码来源:commands.go

示例15: fatalf

func fatalf(fmtString string, args ...interface{}) {
	log.Fatalf(fmtString, args...)
}
开发者ID:jijojv,项目名称:machine,代码行数:3,代码来源:commands.go


注:本文中的github.com/docker/machine/libmachine/log.Fatalf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。