コード例 #1
0
ファイル: controller.go プロジェクト: redspread/spread
// NewController returns a localkube Docker client from a created *docker.Client
func NewController(client *docker.Client, out io.Writer) (*Controller, error) {
	_, err := client.Version()
	if err != nil {
		return nil, fmt.Errorf("Unable to establish connection with Docker daemon: %v", err)
	}

	logger := log.New(out, "", 0)

	return &Controller{
		Client: client,
		log:    logger,
		out:    out,
	}, nil
}
コード例 #2
0
ファイル: dckr.go プロジェクト: EUDAT-GEF/gef-docker
func checkForMinimalDockerVersion(c *docker.Client) (string, error) {
	env, err := c.Version()
	if err != nil {
		return "", err
	}
	m := env.Map()
	version := m["Version"]
	arr := strings.Split(version, ".")
	if len(arr) < 2 {
		return "", fmt.Errorf("unparsable version string: %s", version)
	}
	major, err := strconv.Atoi(arr[0])
	if err != nil {
		return "", fmt.Errorf("unparsable major version: %s", version)
	}
	minor, err := strconv.Atoi(arr[1])
	if err != nil {
		return "", fmt.Errorf("unparsable minor version: %s", version)
	}
	if major*1000+minor < minimalDockerVersion {
		return "", fmt.Errorf("unusably old Docker version: %s", version)
	}
	return version, nil
}