Skip to content

Commit

Permalink
feat(stapel-to-buildah): allow buildah to build stapel images with sh…
Browse files Browse the repository at this point in the history
…ell builder

 * buildah backend is allowed by default to build dockerfiles or stapel images with shell builder

 * ansible builder cannot be used with buildah, added new error

 * removed WERF_BUILDAH_FOR_STAPEL_ENABLED=1 feature gate to use stapel with buildah, just enable buildah backend to build stapel images

Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed May 16, 2022
1 parent 56e90e2 commit 27a1d49
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions pkg/build/conveyor.go
Expand Up @@ -381,34 +381,25 @@ func (c *Conveyor) checkContainerBackendSupported(_ context.Context) error {
return nil
}

imageConfigList, err := c.werfConfig.GetSpecificImages(c.imageNamesToProcess)
if err != nil {
return err
}
var stapelImagesWithAnsible []*config.StapelImage

var nonDockerfileImages []string
for _, processImage := range imageConfigList {
for _, stapelImage := range c.werfConfig.StapelImages {
if processImage.GetName() == stapelImage.Name {
nonDockerfileImages = append(nonDockerfileImages, processImage.GetName())
break
}
for _, img := range c.werfConfig.StapelImages {
if img.Ansible != nil {
stapelImagesWithAnsible = append(stapelImagesWithAnsible, img)
}
}

for _, artifactImage := range c.werfConfig.Artifacts {
if processImage.GetName() == artifactImage.Name {
nonDockerfileImages = append(nonDockerfileImages, processImage.GetName())
break
}
if len(stapelImagesWithAnsible) > 0 {
var names []string
for _, img := range stapelImagesWithAnsible {
names = append(names, fmt.Sprintf("%q", img.GetName()))
}
}

if len(nonDockerfileImages) > 0 && os.Getenv("WERF_BUILDAH_FOR_STAPEL_ENABLED") != "1" {
return fmt.Errorf(`Unable to build stapel type images and artifacts with buildah container backend: %s
return fmt.Errorf(`Unable to build stapel images [%s], which use ansible builder when buildah container backend is enabled.
Please select only dockerfile images or delete all non-dockerfile images from your werf.yaml.
Please use shell builder instead, or select docker server backend to continue usage of ansible builder (disable buildah runtime by unsetting WERF_BUILDAH_MODE environment variable).
Or disable buildah runtime by unsetting WERF_BUILDAH_MODE environment variable.`, strings.Join(nonDockerfileImages, ", "))
It is recommended to use shell builder, because ansible builder will be deprecated soon.`, strings.Join(names, ", "))
}

return nil
Expand Down

0 comments on commit 27a1d49

Please sign in to comment.