Skip to content

Commit

Permalink
Use cache image digest if present
Browse files Browse the repository at this point in the history
  • Loading branch information
modulo11 committed Jun 7, 2021
1 parent 40af02d commit 5e7df8a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/apis/build/v1alpha1/build_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,23 @@ func (b *Build) BuildPod(images BuildPodImages, secrets []corev1.Secret, taints
}

var cacheArgs []string
var exportCacheArgs []string
var cacheVolumes []corev1.VolumeMount
if b.Spec.Cache.ImageTag == "" && b.Spec.Cache.VolumeName == "" || config.OS == "windows" {

if (b.Spec.Cache.ImageTag == "" && b.Spec.Cache.VolumeName == "") || config.OS == "windows" {
cacheArgs = nil
cacheVolumes = nil
} else if len(b.Spec.Cache.ImageTag) > 0 {
cacheArgs = []string{fmt.Sprintf("-cache-image=%s", b.Spec.Cache.ImageTag)}
if b.Spec.LastBuild != nil && b.Spec.LastBuild.CacheImage != "" {
cacheArgs = []string{fmt.Sprintf("-cache-image=%s", b.Spec.LastBuild.CacheImage)}
} else {
cacheArgs = []string{fmt.Sprintf("-cache-image=%s", b.Spec.Cache.ImageTag)}
}
exportCacheArgs = []string{fmt.Sprintf("-cache-image=%s", b.Spec.Cache.ImageTag)}
cacheVolumes = nil
} else {
cacheArgs = []string{"-cache-dir=/cache"}
exportCacheArgs = cacheArgs
cacheVolumes = []corev1.VolumeMount{cacheVolume}
}

Expand Down Expand Up @@ -391,7 +399,7 @@ func (b *Build) BuildPod(images BuildPodImages, secrets []corev1.Secret, taints
"-group=/layers/group.toml",
"-analyzed=/layers/analyzed.toml",
"-project-metadata=/layers/project-metadata.toml"},
cacheArgs,
exportCacheArgs,
func() []string {
if platformAPI == "0.3" {
return nil
Expand Down

0 comments on commit 5e7df8a

Please sign in to comment.