• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang mcnutils.GetHomeDir函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetCreateFlags

// GetCreateFlags registers the flags this driver adds to
// "docker hosts create"
func (d *Driver) GetCreateFlags() []mcnflag.Flag {
	// TODO
	return []mcnflag.Flag{
		mcnflag.StringFlag{
			EnvVar: "HYPRIOT_IP_ADDRESS",
			Name:   "hypriot-ip-address",
			Usage:  "IP Address of machine",
			Value:  "",
		},
		mcnflag.StringFlag{
			EnvVar: "HYPRIOT_SSH_USER",
			Name:   "hypriot-ssh-user",
			Usage:  "SSH user",
			Value:  "root",
		},
		mcnflag.StringFlag{
			EnvVar: "HYPRIOT_SSH_KEY",
			Name:   "hypriot-ssh-key",
			Usage:  "SSH private key path",
			Value:  filepath.Join(mcnutils.GetHomeDir(), ".ssh", "id_rsa"),
		},
		mcnflag.IntFlag{
			EnvVar: "HYPRIOT_SSH_PORT",
			Name:   "hypriot-ssh-port",
			Usage:  "SSH port",
			Value:  22,
		},
	}
}
开发者ID:openit-lib,项目名称:docker-machine-hypriot,代码行数:31,代码来源:hypriot.go


示例2: GetBaseDir

func GetBaseDir() string {
	baseDir := os.Getenv("MACHINE_STORAGE_PATH")
	if baseDir == "" {
		baseDir = filepath.Join(mcnutils.GetHomeDir(), ".docker", "machine")
	}
	return baseDir
}
开发者ID:rominirani,项目名称:machine,代码行数:7,代码来源:utils.go


示例3: TestGetDockerDir

func TestGetDockerDir(t *testing.T) {
	homeDir := mcnutils.GetHomeDir()
	baseDir := GetBaseDir()

	if strings.Index(baseDir, homeDir) != 0 {
		t.Fatalf("expected base dir with prefix %s; received %s", homeDir, baseDir)
	}
}
开发者ID:rominirani,项目名称:machine,代码行数:8,代码来源:utils_test.go


示例4: TestGetBaseDir

func TestGetBaseDir(t *testing.T) {
	// reset any override env var
	homeDir := mcnutils.GetHomeDir()
	baseDir := GetBaseDir()

	if strings.Index(baseDir, homeDir) != 0 {
		t.Fatalf("expected base dir with prefix %s; received %s", homeDir, baseDir)
	}
}
开发者ID:rominirani,项目名称:machine,代码行数:9,代码来源:utils_test.go


示例5: GetDefaultStore

func GetDefaultStore() *persist.Filestore {
	homeDir := mcnutils.GetHomeDir()
	certsDir := filepath.Join(homeDir, ".docker", "machine", "certs")
	return &persist.Filestore{
		Path:             homeDir,
		CaCertPath:       certsDir,
		CaPrivateKeyPath: certsDir,
	}
}
开发者ID:mschygulla,项目名称:machine,代码行数:9,代码来源:libmachine.go


示例6: SetConfigFromFlags

// SetConfigFromFlags configures the driver with the object that was returned
// by RegisterCreateFlags
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
	d.CloudApiURL = flags.String("triton-url")
	d.Account = flags.String("triton-account")
	d.DataCenter = flags.String("triton-datacenter")
	d.PrivateKey = flags.String("triton-key")
	d.SkipTlsVerify = flags.Bool("triton-skip-tls-verify")

	if d.CloudApiURL == "" {
		if d.DataCenter == "" {
			return fmt.Errorf("You must specify a cloudapi url or datacenter name")
		}
		// Shortend format for the cloudapi name, e.g. "us-east-1"
		d.CloudApiURL = fmt.Sprintf("https://%s.%s", d.DataCenter, TritonDefaultCloudapiDomain)
	}

	if d.Account == "" {
		return fmt.Errorf("You must specify the account name using --triton-account")
	}

	if d.PrivateKey == "" {
		homedir := mcnutils.GetHomeDir()
		if homedir == "" {
			return fmt.Errorf("You must specify the SSH key using --triton-key")
		}
		d.PrivateKey = path.Join(homedir, ".ssh", "id_rsa")
	}

	_, err := os.Stat(d.PrivateKey)
	if err != nil {
		return fmt.Errorf("Unable to access SSH key file %s", d.PrivateKey)
	}

	log.Debugf("CloudApiURL: %s", d.CloudApiURL)
	log.Debugf("Account: %s", d.Account)
	log.Debugf("DataCenter: %s", d.DataCenter)
	log.Debugf("PrivateKey: %s", d.PrivateKey)
	log.Debugf("SkipTlsVerify: %d", d.SkipTlsVerify)

	return nil
}
开发者ID:namtzigla,项目名称:docker-machine-driver-triton,代码行数:42,代码来源:driver.go


示例7: GetCreateFlags

	"github.com/docker/machine/libmachine/state"
)

type Driver struct {
	*drivers.BaseDriver
	SSHKey string
}

const (
	defaultSSHUser = "root"
	defaultSSHPort = 22
	defaultTimeout = 1 * time.Second
)

var (
	defaultSSHKey = filepath.Join(mcnutils.GetHomeDir(), ".ssh", "id_rsa")
)

// GetCreateFlags registers the flags this driver adds to
// "docker hosts create"
func (d *Driver) GetCreateFlags() []mcnflag.Flag {
	return []mcnflag.Flag{
		mcnflag.StringFlag{
			Name:  "generic-ip-address",
			Usage: "IP Address of machine",
		},
		mcnflag.StringFlag{
			Name:  "generic-ssh-user",
			Usage: "SSH user",
			Value: defaultSSHUser,
		},
开发者ID:rutulpatel,项目名称:machine,代码行数:31,代码来源:generic.go


示例8: CreateVM

func (d *Driver) CreateVM() error {
	if err := d.b2dUpdater.CopyIsoToMachineDir(d.StorePath, d.MachineName, d.Boot2DockerURL); err != nil {
		return err
	}

	log.Info("Creating VirtualBox VM...")

	// import b2d VM if requested
	if d.Boot2DockerImportVM != "" {
		name := d.Boot2DockerImportVM

		// make sure vm is stopped
		_ = d.vbm("controlvm", name, "poweroff")

		diskInfo, err := getVMDiskInfo(name, d.VBoxManager)
		if err != nil {
			return err
		}

		if _, err := os.Stat(diskInfo.Path); err != nil {
			return err
		}

		if err := d.vbm("clonehd", diskInfo.Path, d.diskPath()); err != nil {
			return err
		}

		log.Debugf("Importing VM settings...")
		vmInfo, err := getVMInfo(name, d.VBoxManager)
		if err != nil {
			return err
		}

		d.CPU = vmInfo.CPUs
		d.Memory = vmInfo.Memory

		log.Debugf("Importing SSH key...")
		keyPath := filepath.Join(mcnutils.GetHomeDir(), ".ssh", "id_boot2docker")
		if err := mcnutils.CopyFile(keyPath, d.GetSSHKeyPath()); err != nil {
			return err
		}
	} else {
		log.Infof("Creating SSH key...")
		if err := d.sshKeyGenerator.Generate(d.GetSSHKeyPath()); err != nil {
			return err
		}

		log.Debugf("Creating disk image...")
		if err := d.diskCreator.Create(d.DiskSize, d.publicSSHKeyPath(), d.diskPath()); err != nil {
			return err
		}
	}

	if err := d.vbm("createvm",
		"--basefolder", d.ResolveStorePath("."),
		"--name", d.MachineName,
		"--register"); err != nil {
		return err
	}

	log.Debugf("VM CPUS: %d", d.CPU)
	log.Debugf("VM Memory: %d", d.Memory)

	cpus := d.CPU
	if cpus < 1 {
		cpus = int(runtime.NumCPU())
	}
	if cpus > 32 {
		cpus = 32
	}

	hostDNSResolver := "off"
	if d.HostDNSResolver {
		hostDNSResolver = "on"
	}

	dnsProxy := "off"
	if d.DNSProxy {
		dnsProxy = "on"
	}

	if err := d.vbm("modifyvm", d.MachineName,
		"--firmware", "bios",
		"--bioslogofadein", "off",
		"--bioslogofadeout", "off",
		"--bioslogodisplaytime", "0",
		"--biosbootmenu", "disabled",
		"--ostype", "Linux26_64",
		"--cpus", fmt.Sprintf("%d", cpus),
		"--memory", fmt.Sprintf("%d", d.Memory),
		"--acpi", "on",
		"--ioapic", "on",
		"--rtcuseutc", "on",
		"--natdnshostresolver1", hostDNSResolver,
		"--natdnsproxy1", dnsProxy,
		"--cpuhotplug", "off",
		"--pae", "on",
		"--hpet", "on",
		"--hwvirtex", "on",
		"--nestedpaging", "on",
//.........这里部分代码省略.........
开发者ID:austinhyde,项目名称:machine,代码行数:101,代码来源:virtualbox.go


示例9: tokenCachePath

// tokenCachePath returns the full path the OAuth 2.0 token should be saved at
// for given tenant ID.
func tokenCachePath(tenantID string) string {
	return filepath.Join(mcnutils.GetHomeDir(), ".docker", "machine", "credentials", "azure", fmt.Sprintf("%s.json", tenantID))
}
开发者ID:dweomer,项目名称:docker-machine,代码行数:5,代码来源:auth.go


示例10: Create

func (d *Driver) Create() error {
	b2dutils := mcnutils.NewB2dUtils(d.StorePath)
	if err := b2dutils.CopyIsoToMachineDir(d.Boot2DockerURL, d.MachineName); err != nil {
		return err
	}

	if d.IsVTXDisabled() {
		// Let's log a warning to warn the user. When the vm is started, logs
		// will be checked for an error anyway.
		// We could fail right here but the method to check didn't prove being
		// bulletproof.
		log.Warn("This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory.")
	}

	log.Infof("Creating VirtualBox VM...")

	// import b2d VM if requested
	if d.Boot2DockerImportVM != "" {
		name := d.Boot2DockerImportVM

		// make sure vm is stopped
		_ = d.vbm("controlvm", name, "poweroff")

		diskInfo, err := d.getVMDiskInfo(name)
		if err != nil {
			return err
		}

		if _, err := os.Stat(diskInfo.Path); err != nil {
			return err
		}

		if err := d.vbm("clonehd", diskInfo.Path, d.diskPath()); err != nil {
			return err
		}

		log.Debugf("Importing VM settings...")
		vmInfo, err := d.getVMInfo(name)
		if err != nil {
			return err
		}

		d.CPU = vmInfo.CPUs
		d.Memory = vmInfo.Memory

		log.Debugf("Importing SSH key...")
		keyPath := filepath.Join(mcnutils.GetHomeDir(), ".ssh", "id_boot2docker")
		if err := mcnutils.CopyFile(keyPath, d.GetSSHKeyPath()); err != nil {
			return err
		}
	} else {
		log.Infof("Creating SSH key...")
		if err := ssh.GenerateSSHKey(d.GetSSHKeyPath()); err != nil {
			return err
		}

		log.Debugf("Creating disk image...")
		if err := d.generateDiskImage(d.DiskSize); err != nil {
			return err
		}
	}

	if err := d.vbm("createvm",
		"--basefolder", d.ResolveStorePath("."),
		"--name", d.MachineName,
		"--register"); err != nil {
		return err
	}

	log.Debugf("VM CPUS: %d", d.CPU)
	log.Debugf("VM Memory: %d", d.Memory)

	cpus := d.CPU
	if cpus < 1 {
		cpus = int(runtime.NumCPU())
	}
	if cpus > 32 {
		cpus = 32
	}

	if err := d.vbm("modifyvm", d.MachineName,
		"--firmware", "bios",
		"--bioslogofadein", "off",
		"--bioslogofadeout", "off",
		"--bioslogodisplaytime", "0",
		"--biosbootmenu", "disabled",
		"--ostype", "Linux26_64",
		"--cpus", fmt.Sprintf("%d", cpus),
		"--memory", fmt.Sprintf("%d", d.Memory),
		"--acpi", "on",
		"--ioapic", "on",
		"--rtcuseutc", "on",
		"--natdnshostresolver1", "off",
		"--natdnsproxy1", "off",
		"--cpuhotplug", "off",
		"--pae", "on",
		"--hpet", "on",
		"--hwvirtex", "on",
		"--nestedpaging", "on",
		"--largepages", "on",
//.........这里部分代码省略.........
开发者ID:rogaha,项目名称:machine,代码行数:101,代码来源:virtualbox.go


示例11: azureCredsPath

// azureCredsPath returns the directory the azure credentials are stored in.
func azureCredsPath() string {
	return filepath.Join(mcnutils.GetHomeDir(), ".docker", "machine", "credentials", "azure")
}
开发者ID:flavio,项目名称:machine,代码行数:4,代码来源:auth.go


示例12: GetDockerDir

func GetDockerDir() string {
	return filepath.Join(mcnutils.GetHomeDir(), ".docker")
}
开发者ID:rominirani,项目名称:machine,代码行数:3,代码来源:utils.go


示例13: GetBaseDir

func GetBaseDir() string {
	if BaseDir == "" {
		BaseDir = filepath.Join(mcnutils.GetHomeDir(), ".docker", "machine")
	}
	return BaseDir
}
开发者ID:MerlinDMC,项目名称:machine,代码行数:6,代码来源:utils.go


示例14:

	"azure-location":                 "West US",
	"azure-size":                     "Small",
	"azure-ssh-port":                 22,
	"azure-username":                 "ubuntu",

	"digitalocean-image":  "ubuntu-14-04-x64",
	"digitalocean-region": "nyc3",
	"digitalocean-size":   "512mb",

	"exoscale-instance-profile":  "small",
	"exoscale-disk-size":         50,
	"exoscale-image":             "ubuntu-14.04",
	"exoscale-availability-zone": "ch-gva-2",

	"generic-ssh-user": "root",
	"generic-ssh-key":  filepath.Join(mcnutils.GetHomeDir(), ".ssh", "id_rsa"),
	"generic-ssh-port": 22,

	"google-zone":         "us-central1-a",
	"google-machine-type": "f1-micro",
	"google-username":     "docker-user",
	"google-scopes":       "https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write",
	"google-disk-size":    "pd-standard",
	"google-disk-type":    10,

	"hyper-v-disk-size": 20000,
	"hyper-v-memory":    1024,

	"openstack-ssh-user":       "root",
	"openstack-ssh-port":       22,
	"openstack-active-timeout": 200,
开发者ID:chanwit,项目名称:gattai,代码行数:31,代码来源:options.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang mcnutils.NewB2dUtils函数代码示例发布时间:2022-05-23
下一篇:
Golang mcnutils.GenerateRandomID函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap