diff --git a/hack/test-stirunimage.sh b/hack/test-stirunimage.sh index c709e8306..187841e5d 100755 --- a/hack/test-stirunimage.sh +++ b/hack/test-stirunimage.sh @@ -115,7 +115,7 @@ grep "Copying sources" "${WORK_DIR}/s2i-non-repo.log" check_result $? "${WORK_DIR}/s2i-non-repo.log" test_debug "s2i rebuild" -s2i build https://github.com/openshift/sti-php.git --context-dir=5.5/test/test-app registry.access.redhat.com/openshift3/php-55-rhel7 rack-test-app --incremental=true --loglevel=5 &> "${WORK_DIR}/s2i-pre-rebuild.log" +s2i build https://github.com/sclorg/s2i-php-container.git --context-dir=5.5/test/test-app registry.access.redhat.com/openshift3/php-55-rhel7 rack-test-app --incremental=true --loglevel=5 &> "${WORK_DIR}/s2i-pre-rebuild.log" check_result $? "${WORK_DIR}/s2i-pre-rebuild.log" s2i rebuild rack-test-app:latest rack-test-app:v1 -p never --loglevel=5 &> "${WORK_DIR}/s2i-rebuild.log" check_result $? "${WORK_DIR}/s2i-rebuild.log" @@ -127,9 +127,16 @@ check_result $? "" grep "Sample invocation" "${WORK_DIR}/s2i-usage.log" check_result $? "${WORK_DIR}/s2i-usage.log" -test_debug "s2i build with git proto" +test_debug "s2i build with overriding assemble/run scripts" +s2i build https://github.com/openshift/source-to-image openshift/php-55-centos7 test --context-dir=test_apprepo >& "${WORK_DIR}/s2i-override-build.log" +grep "Running custom assemble" "${WORK_DIR}/s2i-override-build.log" +check_result $? "${WORK_DIR}/s2i-override-build.log" +docker run test >& "${WORK_DIR}/s2i-override-run.log" +grep "Running custom run" "${WORK_DIR}/s2i-override-run.log" +check_result $? "${WORK_DIR}/s2i-override-run.log" -s2i build https://github.com/openshift/cakephp-ex openshift/php-55-centos7 test --run=true --loglevel=5 &> "${WORK_DIR}/s2i-git-proto.log" & +test_debug "s2i build with remote git repo" +s2i build https://github.com/openshift/cakephp-ex openshift/php-55-centos7 test --loglevel=5 &> "${WORK_DIR}/s2i-git-proto.log" check_result $? "${WORK_DIR}/s2i-git-proto.log" test_debug "s2i build with --run==true option" diff --git a/pkg/build/strategies/sti/sti.go b/pkg/build/strategies/sti/sti.go index ed85e352a..2d427b5b8 100644 --- a/pkg/build/strategies/sti/sti.go +++ b/pkg/build/strategies/sti/sti.go @@ -339,7 +339,7 @@ func (builder *STI) Prepare(config *api.Config) error { // Setup working directories for _, v := range workingDirs { - if err = builder.fs.MkdirAll(filepath.Join(config.WorkingDir, v)); err != nil { + if err = builder.fs.MkdirAllWithPermissions(filepath.Join(config.WorkingDir, v), 0755); err != nil { builder.result.BuildInfo.FailureReason = utilstatus.NewFailureReason( utilstatus.ReasonFSOperationFailed, utilstatus.ReasonMessageFSOperationFailed, diff --git a/pkg/test/fs.go b/pkg/test/fs.go index 86fb18ec5..67e627982 100644 --- a/pkg/test/fs.go +++ b/pkg/test/fs.go @@ -106,6 +106,12 @@ func (f *FakeFileSystem) MkdirAll(dirname string) error { return f.MkdirAllError } +// MkdirAllWithPermissions creates a new directories on the fake filesystem +func (f *FakeFileSystem) MkdirAllWithPermissions(dirname string, perm os.FileMode) error { + f.MkdirAllDir = append(f.MkdirAllDir, dirname) + return f.MkdirAllError +} + // Mkdir creates a new directory on the fake filesystem func (f *FakeFileSystem) Mkdir(dirname string) error { f.MkdirDir = dirname diff --git a/pkg/util/fs.go b/pkg/util/fs.go index e9a396807..300720d22 100644 --- a/pkg/util/fs.go +++ b/pkg/util/fs.go @@ -25,6 +25,7 @@ type FileSystem interface { Chmod(file string, mode os.FileMode) error Rename(from, to string) error MkdirAll(dirname string) error + MkdirAllWithPermissions(dirname string, perm os.FileMode) error Mkdir(dirname string) error Exists(file string) bool Copy(sourcePath, targetPath string) error @@ -149,6 +150,11 @@ func (h *fs) MkdirAll(dirname string) error { return os.MkdirAll(dirname, 0700) } +// MkdirAllWithPermissions creates the directory and all its parents with the provided permissions +func (h *fs) MkdirAllWithPermissions(dirname string, perm os.FileMode) error { + return os.MkdirAll(dirname, perm) +} + // Mkdir creates the specified directory func (h *fs) Mkdir(dirname string) error { return os.Mkdir(dirname, 0700) diff --git a/test_apprepo/.s2i/bin/assemble b/test_apprepo/.s2i/bin/assemble new file mode 100755 index 000000000..b9d80895e --- /dev/null +++ b/test_apprepo/.s2i/bin/assemble @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "Running custom assemble" + diff --git a/test_apprepo/.s2i/bin/run b/test_apprepo/.s2i/bin/run new file mode 100755 index 000000000..e44931781 --- /dev/null +++ b/test_apprepo/.s2i/bin/run @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "Running custom run" +