Exemplo n.º 1
0
func (a *buildOverrides) applyOverrides(attributes admission.Attributes) error {
	if !a.overridesConfig.ForcePull {
		return nil
	}
	build, version, err := buildadmission.GetBuild(attributes)
	if err != nil {
		return err
	}
	glog.V(4).Infof("Handling build %s/%s", build.Namespace, build.Name)
	if build.Spec.Strategy.DockerStrategy != nil {
		glog.V(5).Infof("Setting docker strategy ForcePull to true in build %s/%s", build.Namespace, build.Name)
		build.Spec.Strategy.DockerStrategy.ForcePull = true
	}
	if build.Spec.Strategy.SourceStrategy != nil {
		glog.V(5).Infof("Setting source strategy ForcePull to true in build %s/%s", build.Namespace, build.Name)
		build.Spec.Strategy.SourceStrategy.ForcePull = true
	}
	if build.Spec.Strategy.CustomStrategy != nil {
		err := applyForcePullToPod(attributes)
		if err != nil {
			return err
		}
		glog.V(5).Infof("Setting custom strategy ForcePull to true in build %s/%s", build.Namespace, build.Name)
		build.Spec.Strategy.CustomStrategy.ForcePull = true
	}
	return buildadmission.SetBuild(attributes, build, version)
}
Exemplo n.º 2
0
// Admit applies configured build defaults to a pod that is identified
// as a build pod.
func (a *buildDefaults) Admit(attributes admission.Attributes) error {
	if a.defaultsConfig == nil {
		return nil
	}
	if !buildadmission.IsBuildPod(attributes) {
		return nil
	}
	build, version, err := buildadmission.GetBuild(attributes)
	if err != nil {
		return nil
	}

	glog.V(4).Infof("Handling build %s/%s", build.Namespace, build.Name)

	a.applyBuildDefaults(build)

	return buildadmission.SetBuild(attributes, build, version)
}
Exemplo n.º 3
0
func (a *buildOverrides) applyOverrides(attributes admission.Attributes) error {
	build, version, err := buildadmission.GetBuild(attributes)
	if err != nil {
		return err
	}
	glog.V(4).Infof("Handling build %s/%s", build.Namespace, build.Name)

	if a.overridesConfig.ForcePull {
		if err := applyForcePullToBuild(build, attributes); err != nil {
			return err
		}
	}

	// Apply label overrides
	for _, lbl := range a.overridesConfig.ImageLabels {
		glog.V(5).Infof("Overriding image label %s=%s in build %s/%s", lbl.Name, lbl.Value, build.Namespace, build.Name)
		overrideLabel(lbl, &build.Spec.Output.ImageLabels)
	}

	return buildadmission.SetBuild(attributes, build, version)
}