Exemple #1
0
// GetBuilderImage processes the config and performs operations necessary to make
// the Docker image specified as BuilderImage available locally.
// It returns information about the base image, containing metadata necessary
// for choosing the right STI build strategy.
func GetBuilderImage(config *api.Config) (*docker.PullResult, error) {
	d, err := docker.New(config.DockerConfig, config.PullAuthentication)
	result := docker.PullResult{}
	if err != nil {
		return nil, err
	}

	var image *dockerclient.Image
	if config.ForcePull {
		image, err = d.PullImage(config.BuilderImage)
		if err != nil {
			glog.Warningf("An error occurred when pulling %s: %v. Attempting to use local image.", config.BuilderImage, err)
			image, err = d.CheckImage(config.BuilderImage)
		}
	} else {
		image, err = d.CheckAndPullImage(config.BuilderImage)
	}

	if err != nil {
		return nil, err
	}
	result.Image = image
	result.OnBuild = d.IsImageOnBuild(config.BuilderImage)

	if err = checkAllowedUser(d, config, result.OnBuild); err != nil {
		return nil, err
	}

	return &result, nil
}
Exemple #2
0
// GetBuilderImage processes the config and performs operations necessary to make
// the Docker image specified as BuilderImage available locally.
// It returns information about the base image, containing metadata necessary
// for choosing the right STI build strategy.
func GetBuilderImage(config *api.Config) (*docker.PullResult, error) {
	d, err := docker.New(config.DockerConfig, config.PullAuthentication)
	result := docker.PullResult{}
	if err != nil {
		return nil, err
	}

	var image *dockerclient.Image
	if config.ForcePull {
		image, err = d.PullImage(config.BuilderImage)
	} else {
		image, err = d.CheckAndPull(config.BuilderImage)
	}

	if err != nil {
		return nil, err
	}
	result.Image = image
	result.OnBuild = d.IsImageOnBuild(config.BuilderImage)
	return &result, nil
}