示例#1
0
func createLabelsForResultingImage(builder *STI, docker dockerpkg.Docker, baseImage string) map[string]string {
	generatedLabels := util.GenerateOutputImageLabels(builder.sourceInfo, builder.config)

	existingLabels, err := docker.GetLabels(baseImage)
	if err != nil {
		glog.V(0).Infof("error: Unable to read existing labels from the base image %s", baseImage)
	}

	return mergeLabels(generatedLabels, existingLabels)
}
示例#2
0
func commitContainer(docker dockerpkg.Docker, containerID, cmd, user, tag string, env, entrypoint []string, labels map[string]string) (string, error) {
	opts := dockerpkg.CommitContainerOptions{
		Command:     []string{cmd},
		Env:         env,
		Entrypoint:  entrypoint,
		ContainerID: containerID,
		Repository:  tag,
		User:        user,
		Labels:      labels,
	}

	imageID, err := docker.CommitContainer(opts)
	if err != nil {
		return "", s2ierr.NewCommitError(tag, err)
	}

	return imageID, nil
}
示例#3
0
func checkAllowedUser(d docker.Docker, config *api.Config, isOnbuild bool) error {
	if config.AllowedUIDs == nil || config.AllowedUIDs.Empty() {
		return nil
	}
	user, err := d.GetImageUser(config.BuilderImage)
	if err != nil {
		return err
	}
	if !userutil.IsUserAllowed(user, &config.AllowedUIDs) {
		return errors.NewBuilderUserNotAllowedError(config.BuilderImage, false)
	}
	if isOnbuild {
		cmds, err := d.GetOnBuild(config.BuilderImage)
		if err != nil {
			return err
		}
		if !userutil.IsOnbuildAllowed(cmds, &config.AllowedUIDs) {
			return errors.NewBuilderUserNotAllowedError(config.BuilderImage, true)
		}
	}
	return nil
}