mirror of
https://github.com/mudler/luet.git
synced 2025-07-30 22:45:29 +00:00
Let the build fail when depending on virtuals
This is currently not a valid use case. Virtuals are empty packages and if the `build.yaml` is completely empty, nothing could depend on them. Let's try to not be too smart and build the package image if a source image is supplied, and fail hardly when we depend on a virtual in build time.
This commit is contained in:
parent
1fdef757b6
commit
43f5b69c18
@ -528,9 +528,9 @@ func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage
|
||||
p CompilationSpec, generateArtifact bool) (Artifact, error) {
|
||||
|
||||
// If it is a virtual, check if we have to generate an empty artifact or not.
|
||||
if generateArtifact && p.EmptyPackage() {
|
||||
if generateArtifact && p.EmptyPackage() && !p.HasImageSource() {
|
||||
return cs.genArtifact(p, CompilerBackendOptions{}, CompilerBackendOptions{}, concurrency, keepPermissions)
|
||||
} else if p.EmptyPackage() {
|
||||
} else if p.EmptyPackage() && !p.HasImageSource() {
|
||||
return &PackageArtifact{}, nil
|
||||
}
|
||||
|
||||
|
@ -23,18 +23,34 @@ testBuildB() {
|
||||
mkdir $tmpdir/testbuild2
|
||||
luet build --tree "$ROOT_DIR/tests/fixtures/virtuals" --debug --compression "gzip" --destination $tmpdir/testbuild2 test/b
|
||||
buildst=$?
|
||||
assertEquals 'builds successfully' "$buildst" "0"
|
||||
assertTrue 'create package A 1.0' "[ -e '$tmpdir/testbuild2/a-test-1.0.package.tar.gz' ]"
|
||||
assertTrue 'create package A 1.0' "[ -e '$tmpdir/testbuild2/a-test-1.0.metadata.yaml' ]"
|
||||
assertTrue 'create package B 1.0' "[ -e '$tmpdir/testbuild2/b-test-1.0.package.tar.gz' ]"
|
||||
assertTrue 'create package B 1.0' "[ -e '$tmpdir/testbuild2/b-test-1.0.metadata.yaml' ]"
|
||||
assertEquals 'builds of B expected to fail. It depends on a virtual' "$buildst" "1"
|
||||
}
|
||||
|
||||
testBuildC() {
|
||||
mkdir $tmpdir/testbuild3
|
||||
luet build --tree "$ROOT_DIR/tests/fixtures/virtuals" --debug --destination $tmpdir/testbuild3 test/c
|
||||
luet build --tree "$ROOT_DIR/tests/fixtures/virtuals" --debug --compression "gzip" --destination $tmpdir/testbuild3 test/c
|
||||
buildst=$?
|
||||
assertEquals 'builds of C expected to fail' "$buildst" "1"
|
||||
assertEquals 'builds of C expected to fail. Steps with no source image' "$buildst" "1"
|
||||
}
|
||||
|
||||
testBuildImage() {
|
||||
mkdir $tmpdir/testbuild4
|
||||
luet build --tree "$ROOT_DIR/tests/fixtures/virtuals" --debug --compression "gzip" --destination $tmpdir/testbuild4 test/image
|
||||
buildst=$?
|
||||
assertEquals 'builds of test/image expected to succeed' "$buildst" "0"
|
||||
assertTrue 'create package test/image 1.0' "[ -e '$tmpdir/testbuild4/image-test-1.0.package.tar.gz' ]"
|
||||
assertTrue 'create package test/image 1.0' "[ -e '$tmpdir/testbuild4/image-test-1.0.metadata.yaml' ]"
|
||||
}
|
||||
|
||||
testBuildVirtual() {
|
||||
mkdir $tmpdir/testbuild5
|
||||
luet build --tree "$ROOT_DIR/tests/fixtures/virtuals" --debug --compression "gzip" --destination $tmpdir/testbuild5 test/virtual
|
||||
buildst=$?
|
||||
assertEquals 'builds of test/virtual expected to succeed' "$buildst" "0"
|
||||
assertTrue 'create package test/image 1.0' "[ -e '$tmpdir/testbuild5/image-test-1.0.package.tar.gz' ]"
|
||||
assertTrue 'create package test/image 1.0' "[ -e '$tmpdir/testbuild5/image-test-1.0.metadata.yaml' ]"
|
||||
assertTrue 'create package test/virtual 1.0' "[ -e '$tmpdir/testbuild5/virtual-test-1.0.package.tar.gz' ]"
|
||||
assertTrue 'create package test/virtual 1.0' "[ -e '$tmpdir/testbuild5/virtual-test-1.0.metadata.yaml' ]"
|
||||
}
|
||||
|
||||
# Load shUnit2.
|
||||
|
Loading…
Reference in New Issue
Block a user