Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions actions/overlay_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ package actions
import (
"fmt"
"log"
"os"
"path"

"github.com/go-debos/debos"
Expand All @@ -43,6 +44,15 @@ func (overlay *OverlayAction) Verify(context *debos.Context) error {
if _, err := debos.RestrictedPath(context.Rootdir, overlay.Destination); err != nil {
return err
}

/* if origin is the recipe, check the path exists on disk */
if len(overlay.Origin) == 0 || overlay.Origin == "recipe" {
sourceDir := path.Join(context.RecipeDir, overlay.Source)
if _, err := os.Stat(sourceDir); err != nil {
return err
}
}

return nil
}

Expand Down
2 changes: 2 additions & 0 deletions tests/exit_test/exit_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ expect_failure debos bad.yaml
expect_failure debos pre-machine-failure.yaml
expect_failure debos post-machine-failure.yaml
expect_failure debos overlay-non-existent-destination.yaml
expect_failure debos overlay-non-existent-source.yaml
expect_failure rename_command NOT_DEBOS debos good.yaml

expect_failure $SUDO debos non-existent-file.yaml --disable-fakemachine
Expand All @@ -79,6 +80,7 @@ expect_failure $SUDO debos bad.yaml --disable-fakemachine
expect_failure $SUDO debos pre-machine-failure.yaml --disable-fakemachine
expect_failure $SUDO debos post-machine-failure.yaml --disable-fakemachine
expect_failure $SUDO debos overlay-non-existent-destination.yaml --disable-fakemachine
expect_failure $SUDO debos overlay-non-existent-source.yaml --disable-fakemachine

echo
if [[ $FAILURES -ne 0 ]]; then
Expand Down
8 changes: 8 additions & 0 deletions tests/exit_test/overlay-non-existent-source.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
architecture: amd64

actions:
# This overlay action is expected to error out here because the source
# doesn't exist in the recipe directory.
- action: overlay
description: Overlay missing file
source: missing-file