當前位置: 首頁>>代碼示例>>Golang>>正文


Golang driver.DistroDriver類代碼示例

本文整理匯總了Golang中docker-extension/driver.DistroDriver的典型用法代碼示例。如果您正苦於以下問題:Golang DistroDriver類的具體用法?Golang DistroDriver怎麽用?Golang DistroDriver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DistroDriver類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: updateDockerOpts

func updateDockerOpts(dd driver.DistroDriver, args string) error {
	log.Printf("Updating daemon args to: %s", args)
	if err := dd.ChangeOpts(args); err != nil {
		return fmt.Errorf("error updating DOCKER_OPTS: %v", err)
	}
	return nil
}
開發者ID:bear454,項目名稱:azure-docker-extension,代碼行數:7,代碼來源:op_enable.go

示例2: install

func install(he vmextension.HandlerEnvironment, d driver.DistroDriver) error {
	// Install docker daemon
	log.Printf("++ install docker")
	if _, err := exec.LookPath("docker"); err == nil {
		log.Printf("docker already installed. not re-installing")
	} else {
		if err := d.InstallDocker(); err != nil {
			return err
		}
	}
	log.Printf("-- install docker")

	// Install docker-compose
	log.Printf("++ install docker-compose")
	if err := installCompose(d.DockerComposeDir()); err != nil {
		return fmt.Errorf("error installing docker-compose: %v", err)
	}
	log.Printf("-- install docker-compose")

	// Add user to 'docker' group to user docker as non-root
	u, err := util.GetAzureUser()
	if err != nil {
		return fmt.Errorf("failed to get provisioned user: %v", err)
	}
	log.Printf("++ add user to docker group")
	if out, err := executil.Exec("usermod", "-aG", "docker", u); err != nil {
		log.Printf("%s", string(out))
		return err
	}
	log.Printf("-- add user to docker group")

	return nil
}
開發者ID:bear454,項目名稱:azure-docker-extension,代碼行數:33,代碼來源:op_install.go

示例3: composeUp

func composeUp(d driver.DistroDriver, json map[string]interface{}) error {
	if len(json) == 0 {
		log.Println("docker-compose config not specified, noop")
		return nil
	}

	// Convert json to yaml
	yaml, err := yaml.Marshal(json)
	if err != nil {
		return fmt.Errorf("error converting to compose.yml: %v", err)
	}

	tmpDir, err := ioutil.TempDir(os.TempDir(), "compose")
	if err != nil {
		return fmt.Errorf("failed creating temp dir: %v", err)
	}
	log.Printf("Using compose yaml:---------\n%s\n----------", string(yaml))
	ymlPath := filepath.Join(tmpDir, composeYml)
	if err := ioutil.WriteFile(ymlPath, yaml, 0666); err != nil {
		return fmt.Errorf("error writing yaml: %v", err)
	}

	compose := filepath.Join(d.DockerComposeDir(), composeBin)
	return executil.ExecPipe(compose, "-f", ymlPath, "up", "-d")
}
開發者ID:thomas1206,項目名稱:azure-docker-extension,代碼行數:25,代碼來源:op_enable.go

示例4: uninstall

func uninstall(he vmextension.HandlerEnvironment, d driver.DistroDriver) error {
	log.Println("++ uninstall docker")
	if err := d.UninstallDocker(); err != nil {
		return err
	}
	log.Println("-- uninstall docker")
	return nil
}
開發者ID:thomas1206,項目名稱:azure-docker-extension,代碼行數:8,代碼來源:op_uninstall.go

示例5: disable

func disable(he vmextension.HandlerEnvironment, d driver.DistroDriver) error {
	log.Printf("++ stop docker daemon")
	if err := d.StopDocker(); err != nil {
		return err
	}
	log.Printf("-- stop docker daemon")
	return nil
}
開發者ID:thomas1206,項目名稱:azure-docker-extension,代碼行數:8,代碼來源:op_disable.go

示例6: enable

func enable(he vmextension.HandlerEnvironment, d driver.DistroDriver) error {
	settings, err := parseSettings(he.HandlerEnvironment.ConfigFolder)
	if err != nil {
		return err
	}

	// Install docker remote access certs
	log.Printf("++ setup docker certs")
	if err := installDockerCerts(*settings, dockerCfgDir); err != nil {
		return fmt.Errorf("error installing docker certs: %v", err)
	}
	log.Printf("-- setup docker certs")

	// Update dockeropts
	log.Printf("++ update dockeropts")
	if err := updateDockerOpts(d, getArgs(*settings, d)); err != nil {
		return fmt.Errorf("failed to update dockeropts: %v", err)
	}
	log.Printf("-- update dockeropts")

	// Restart docker
	log.Printf("++ restart docker")
	if err := d.RestartDocker(); err != nil {
		return err
	}
	time.Sleep(3 * time.Second) // wait for instance to come up
	log.Printf("-- restart docker")

	// Login Docker registry server
	log.Printf("++ login docker registry")
	if err := loginRegistry(settings.Login); err != nil {
		return err
	}
	log.Printf("-- login docker registry")

	// Compose Up
	log.Printf("++ compose up")
	if err := composeUp(d, settings.ComposeJson); err != nil {
		return fmt.Errorf("'compose up' failed: %v", err)
	}
	log.Printf("-- compose up")
	return nil
}
開發者ID:bear454,項目名稱:azure-docker-extension,代碼行數:43,代碼來源:op_enable.go

示例7: getArgs

func getArgs(s DockerHandlerSettings, dd driver.DistroDriver) string {
	args := dd.BaseOpts()

	if s.Certs.HasDockerCerts() {
		tls := []string{"--tlsverify",
			fmt.Sprintf("--tlscacert=%s", filepath.Join(dockerCfgDir, dockerCaCert)),
			fmt.Sprintf("--tlscert=%s", filepath.Join(dockerCfgDir, dockerSrvCert)),
			fmt.Sprintf("--tlskey=%s", filepath.Join(dockerCfgDir, dockerSrvKey)),
		}
		args = append(args, tls...)
	}

	if s.Docker.Port != "" {
		args = append(args, fmt.Sprintf("-H=0.0.0.0:%s", s.Docker.Port))
	}

	if len(s.Docker.Options) > 0 {
		args = append(args, s.Docker.Options...)
	}

	return strings.Join(args, " ")
}
開發者ID:bear454,項目名稱:azure-docker-extension,代碼行數:22,代碼來源:op_enable.go

示例8: composeUp

func composeUp(d driver.DistroDriver, json map[string]interface{}) error {
	if len(json) == 0 {
		log.Println("docker-compose config not specified, noop")
		return nil
	}

	// Convert json to yaml
	yaml, err := yaml.Marshal(json)
	if err != nil {
		return fmt.Errorf("error converting to compose.yml: %v", err)
	}

	if err := os.MkdirAll(composeDir, 0777); err != nil {
		return fmt.Errorf("failed creating %s: %v", composeDir, err)
	}
	log.Printf("Using compose yaml:>>>>>\n%s\n<<<<<", string(yaml))
	ymlPath := filepath.Join(composeDir, composeYml)
	if err := ioutil.WriteFile(ymlPath, yaml, 0666); err != nil {
		return fmt.Errorf("error writing %s: %v", ymlPath, err)
	}

	compose := filepath.Join(d.DockerComposeDir(), composeBin)
	return executil.ExecPipeToFds(executil.Fds{Out: ioutil.Discard}, compose, "-p", composeProject, "-f", ymlPath, "up", "-d")
}
開發者ID:bear454,項目名稱:azure-docker-extension,代碼行數:24,代碼來源:op_enable.go


注:本文中的docker-extension/driver.DistroDriver類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。