| ... | ... |
@@ -5,12 +5,13 @@ import ( |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"io" |
| 7 | 7 |
"io/ioutil" |
| 8 |
- "os" |
|
| 9 | 8 |
"path/filepath" |
| 10 | 9 |
"strings" |
| 11 | 10 |
|
| 12 | 11 |
docker "github.com/fsouza/go-dockerclient" |
| 13 |
- stitar "github.com/openshift/source-to-image/pkg/tar" |
|
| 12 |
+ |
|
| 13 |
+ s2itar "github.com/openshift/source-to-image/pkg/tar" |
|
| 14 |
+ s2iutil "github.com/openshift/source-to-image/pkg/util" |
|
| 14 | 15 |
) |
| 15 | 16 |
|
| 16 | 17 |
// removeLeadingDirectoryAdapter wraps a tar.Reader and strips the first leading |
| ... | ... |
@@ -18,7 +19,7 @@ import ( |
| 18 | 18 |
// the case that files with differing first leading directory names are |
| 19 | 19 |
// encountered. |
| 20 | 20 |
type removeLeadingDirectoryAdapter struct {
|
| 21 |
- stitar.Reader |
|
| 21 |
+ s2itar.Reader |
|
| 22 | 22 |
leadingDir string |
| 23 | 23 |
setLeadingDir bool |
| 24 | 24 |
} |
| ... | ... |
@@ -116,7 +117,7 @@ func DownloadDirFromContainer(client *docker.Client, container, src, dst string) |
| 116 | 116 |
defer downloader.Close() |
| 117 | 117 |
tarReader := &removeLeadingDirectoryAdapter{Reader: tar.NewReader(downloader)}
|
| 118 | 118 |
|
| 119 |
- t := stitar.New() |
|
| 119 |
+ t := s2itar.New(s2iutil.NewFileSystem()) |
|
| 120 | 120 |
return t.ExtractTarStreamFromTarReader(dst, tarReader, nil) |
| 121 | 121 |
} |
| 122 | 122 |
|
| ... | ... |
@@ -124,10 +125,13 @@ func DownloadDirFromContainer(client *docker.Client, container, src, dst string) |
| 124 | 124 |
func UploadFileToContainer(client *docker.Client, container, src, dest string) error {
|
| 125 | 125 |
uploader, errch := newContainerUploader(client, container, filepath.Dir(dest)) |
| 126 | 126 |
|
| 127 |
- nullWalkFunc := func(path string, info os.FileInfo, err error) error { return err }
|
|
| 127 |
+ t := s2itar.New(s2iutil.NewFileSystem()) |
|
| 128 |
+ tarWriter := s2itar.RenameAdapter{Writer: tar.NewWriter(uploader), Old: filepath.Base(src), New: filepath.Base(dest)}
|
|
| 128 | 129 |
|
| 129 |
- t := stitar.New() |
|
| 130 |
- err := t.StreamFileAsTarWithCallback(src, filepath.Base(dest), uploader, nullWalkFunc, false) |
|
| 130 |
+ err := t.CreateTarStreamToTarWriter(src, true, tarWriter, nil) |
|
| 131 |
+ if err == nil {
|
|
| 132 |
+ err = tarWriter.Close() |
|
| 133 |
+ } |
|
| 131 | 134 |
uploader.Close() |
| 132 | 135 |
if err != nil {
|
| 133 | 136 |
return err |
| ... | ... |
@@ -19,6 +19,7 @@ import ( |
| 19 | 19 |
s2iapi "github.com/openshift/source-to-image/pkg/api" |
| 20 | 20 |
"github.com/openshift/source-to-image/pkg/tar" |
| 21 | 21 |
"github.com/openshift/source-to-image/pkg/util" |
| 22 |
+ s2iutil "github.com/openshift/source-to-image/pkg/util" |
|
| 22 | 23 |
|
| 23 | 24 |
"github.com/openshift/origin/pkg/build/api" |
| 24 | 25 |
"github.com/openshift/origin/pkg/build/builder/cmd/dockercfg" |
| ... | ... |
@@ -49,7 +50,7 @@ func NewDockerBuilder(dockerClient DockerClient, buildsClient client.BuildInterf |
| 49 | 49 |
dockerClient: dockerClient, |
| 50 | 50 |
build: build, |
| 51 | 51 |
gitClient: gitClient, |
| 52 |
- tar: tar.New(), |
|
| 52 |
+ tar: tar.New(s2iutil.NewFileSystem()), |
|
| 53 | 53 |
urlTimeout: initialURLCheckTimeout, |
| 54 | 54 |
client: buildsClient, |
| 55 | 55 |
cgLimits: cgLimits, |
| ... | ... |
@@ -12,11 +12,13 @@ import ( |
| 12 | 12 |
"github.com/fsouza/go-dockerclient" |
| 13 | 13 |
kapi "k8s.io/kubernetes/pkg/api" |
| 14 | 14 |
|
| 15 |
+ "github.com/openshift/source-to-image/pkg/tar" |
|
| 16 |
+ s2iutil "github.com/openshift/source-to-image/pkg/util" |
|
| 17 |
+ |
|
| 15 | 18 |
"github.com/openshift/origin/pkg/build/api" |
| 16 | 19 |
"github.com/openshift/origin/pkg/generate/git" |
| 17 | 20 |
"github.com/openshift/origin/pkg/util/docker/dockerfile" |
| 18 | 21 |
"github.com/openshift/origin/test/util" |
| 19 |
- "github.com/openshift/source-to-image/pkg/tar" |
|
| 20 | 22 |
) |
| 21 | 23 |
|
| 22 | 24 |
func TestInsertEnvAfterFrom(t *testing.T) {
|
| ... | ... |
@@ -226,7 +228,7 @@ func TestDockerfilePath(t *testing.T) {
|
| 226 | 226 |
dockerClient: dockerClient, |
| 227 | 227 |
build: build, |
| 228 | 228 |
gitClient: git.NewRepository(), |
| 229 |
- tar: tar.New(), |
|
| 229 |
+ tar: tar.New(s2iutil.NewFileSystem()), |
|
| 230 | 230 |
} |
| 231 | 231 |
|
| 232 | 232 |
// this will validate that the Dockerfile is readable |
| ... | ... |
@@ -13,6 +13,7 @@ import ( |
| 13 | 13 |
docker "github.com/fsouza/go-dockerclient" |
| 14 | 14 |
|
| 15 | 15 |
s2igit "github.com/openshift/source-to-image/pkg/scm/git" |
| 16 |
+ s2iutil "github.com/openshift/source-to-image/pkg/util" |
|
| 16 | 17 |
|
| 17 | 18 |
"github.com/openshift/origin/pkg/build/api" |
| 18 | 19 |
"github.com/openshift/origin/pkg/build/builder/cmd/dockercfg" |
| ... | ... |
@@ -151,7 +152,7 @@ func checkRemoteGit(gitClient GitClient, url string, initialTimeout time.Duratio |
| 151 | 151 |
// checkSourceURI performs a check on the URI associated with the build |
| 152 | 152 |
// to make sure that it is valid. |
| 153 | 153 |
func checkSourceURI(gitClient GitClient, rawurl string, timeout time.Duration) error {
|
| 154 |
- ok, err := s2igit.New().ValidCloneSpec(rawurl) |
|
| 154 |
+ ok, err := s2igit.New(s2iutil.NewFileSystem()).ValidCloneSpec(rawurl) |
|
| 155 | 155 |
if err != nil {
|
| 156 | 156 |
return fmt.Errorf("Invalid git source url %q: %v", rawurl, err)
|
| 157 | 157 |
} |
| ... | ... |
@@ -366,7 +367,7 @@ func extractSourceFromImage(dockerClient DockerClient, image, buildDir string, i |
| 366 | 366 |
} |
| 367 | 367 |
defer dockerClient.RemoveContainer(docker.RemoveContainerOptions{ID: container.ID})
|
| 368 | 368 |
|
| 369 |
- tarHelper := tar.New() |
|
| 369 |
+ tarHelper := tar.New(s2iutil.NewFileSystem()) |
|
| 370 | 370 |
tarHelper.SetExclusionPattern(nil) |
| 371 | 371 |
|
| 372 | 372 |
for _, path := range paths {
|
| ... | ... |
@@ -16,6 +16,8 @@ import ( |
| 16 | 16 |
"github.com/spf13/cobra" |
| 17 | 17 |
kerrors "k8s.io/kubernetes/pkg/util/errors" |
| 18 | 18 |
|
| 19 |
+ s2iutil "github.com/openshift/source-to-image/pkg/util" |
|
| 20 |
+ |
|
| 19 | 21 |
"github.com/openshift/origin/pkg/cmd/util/clientcmd" |
| 20 | 22 |
) |
| 21 | 23 |
|
| ... | ... |
@@ -35,7 +37,7 @@ type tarStrategy struct {
|
| 35 | 35 |
|
| 36 | 36 |
func newTarStrategy(f *clientcmd.Factory, c *cobra.Command, o *RsyncOptions) (copyStrategy, error) {
|
| 37 | 37 |
|
| 38 |
- tarHelper := tar.New() |
|
| 38 |
+ tarHelper := tar.New(s2iutil.NewFileSystem()) |
|
| 39 | 39 |
tarHelper.SetExclusionPattern(nil) |
| 40 | 40 |
|
| 41 | 41 |
ignoredFlags := rsyncSpecificFlags(o) |
| ... | ... |
@@ -18,6 +18,9 @@ import ( |
| 18 | 18 |
"github.com/golang/glog" |
| 19 | 19 |
"github.com/spf13/cobra" |
| 20 | 20 |
|
| 21 |
+ "github.com/openshift/source-to-image/pkg/tar" |
|
| 22 |
+ s2iutil "github.com/openshift/source-to-image/pkg/util" |
|
| 23 |
+ |
|
| 21 | 24 |
kapi "k8s.io/kubernetes/pkg/api" |
| 22 | 25 |
kerrors "k8s.io/kubernetes/pkg/api/errors" |
| 23 | 26 |
"k8s.io/kubernetes/pkg/api/meta" |
| ... | ... |
@@ -35,7 +38,6 @@ import ( |
| 35 | 35 |
"github.com/openshift/origin/pkg/cmd/util/clientcmd" |
| 36 | 36 |
"github.com/openshift/origin/pkg/generate/git" |
| 37 | 37 |
oerrors "github.com/openshift/origin/pkg/util/errors" |
| 38 |
- "github.com/openshift/source-to-image/pkg/tar" |
|
| 39 | 38 |
) |
| 40 | 39 |
|
| 41 | 40 |
var ( |
| ... | ... |
@@ -567,7 +569,7 @@ func streamPathToBuild(repo git.Repository, in io.Reader, out io.Writer, client |
| 567 | 567 |
pr, pw := io.Pipe() |
| 568 | 568 |
go func() {
|
| 569 | 569 |
w := gzip.NewWriter(pw) |
| 570 |
- if err := tar.New().CreateTarStream(path, false, w); err != nil {
|
|
| 570 |
+ if err := tar.New(s2iutil.NewFileSystem()).CreateTarStream(path, false, w); err != nil {
|
|
| 571 | 571 |
pw.CloseWithError(err) |
| 572 | 572 |
} else {
|
| 573 | 573 |
w.Close() |
| ... | ... |
@@ -10,11 +10,13 @@ import ( |
| 10 | 10 |
"regexp" |
| 11 | 11 |
"strconv" |
| 12 | 12 |
|
| 13 |
+ "github.com/openshift/source-to-image/pkg/tar" |
|
| 14 |
+ s2iutil "github.com/openshift/source-to-image/pkg/util" |
|
| 15 |
+ |
|
| 13 | 16 |
kapi "k8s.io/kubernetes/pkg/api" |
| 14 | 17 |
kerrs "k8s.io/kubernetes/pkg/util/errors" |
| 15 | 18 |
|
| 16 | 19 |
"github.com/openshift/origin/pkg/diagnostics/networkpod/util" |
| 17 |
- "github.com/openshift/source-to-image/pkg/tar" |
|
| 18 | 20 |
) |
| 19 | 21 |
|
| 20 | 22 |
func (d *NetworkDiagnostic) CollectNetworkPodLogs() error {
|
| ... | ... |
@@ -91,7 +93,7 @@ func (d *NetworkDiagnostic) copyNetworkPodInfo(pod *kapi.Pod) error {
|
| 91 | 91 |
} |
| 92 | 92 |
defer tmp.Close() |
| 93 | 93 |
|
| 94 |
- tarHelper := tar.New() |
|
| 94 |
+ tarHelper := tar.New(s2iutil.NewFileSystem()) |
|
| 95 | 95 |
tarHelper.SetExclusionPattern(nil) |
| 96 | 96 |
logdir := filepath.Join(d.LogDir, util.NetworkDiagNodeLogDirPrefix, pod.Spec.NodeName) |
| 97 | 97 |
err = tarHelper.ExtractTarStream(logdir, tmp) |
| ... | ... |
@@ -13,14 +13,17 @@ import ( |
| 13 | 13 |
"github.com/docker/docker/builder/dockerfile/parser" |
| 14 | 14 |
"github.com/golang/glog" |
| 15 | 15 |
|
| 16 |
- buildapi "github.com/openshift/origin/pkg/build/api" |
|
| 17 |
- "github.com/openshift/origin/pkg/generate" |
|
| 18 |
- "github.com/openshift/origin/pkg/generate/git" |
|
| 19 |
- "github.com/openshift/origin/pkg/generate/source" |
|
| 20 | 16 |
s2iapi "github.com/openshift/source-to-image/pkg/api" |
| 21 | 17 |
s2igit "github.com/openshift/source-to-image/pkg/scm/git" |
| 18 |
+ s2iutil "github.com/openshift/source-to-image/pkg/util" |
|
| 19 |
+ |
|
| 22 | 20 |
kapi "k8s.io/kubernetes/pkg/api" |
| 23 | 21 |
"k8s.io/kubernetes/pkg/api/validation" |
| 22 |
+ |
|
| 23 |
+ buildapi "github.com/openshift/origin/pkg/build/api" |
|
| 24 |
+ "github.com/openshift/origin/pkg/generate" |
|
| 25 |
+ "github.com/openshift/origin/pkg/generate/git" |
|
| 26 |
+ "github.com/openshift/origin/pkg/generate/source" |
|
| 24 | 27 |
) |
| 25 | 28 |
|
| 26 | 29 |
type Dockerfile interface {
|
| ... | ... |
@@ -70,7 +73,7 @@ func IsPossibleSourceRepository(s string) bool {
|
| 70 | 70 |
|
| 71 | 71 |
// IsRemoteRepository checks whether the provided string is a remote repository or not |
| 72 | 72 |
func IsRemoteRepository(s string) bool {
|
| 73 |
- if !s2igit.New().ValidCloneSpecRemoteOnly(s) {
|
|
| 73 |
+ if !s2igit.New(s2iutil.NewFileSystem()).ValidCloneSpecRemoteOnly(s) {
|
|
| 74 | 74 |
return false |
| 75 | 75 |
} |
| 76 | 76 |
url, err := url.Parse(s) |
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
"strings" |
| 9 | 9 |
|
| 10 | 10 |
s2igit "github.com/openshift/source-to-image/pkg/scm/git" |
| 11 |
+ s2iutil "github.com/openshift/source-to-image/pkg/util" |
|
| 11 | 12 |
) |
| 12 | 13 |
|
| 13 | 14 |
// ParseRepository parses a string that may be in the Git format (git@) or URL format |
| ... | ... |
@@ -27,7 +28,7 @@ func ParseRepository(s string) (*url.URL, error) {
|
| 27 | 27 |
// There are some shortcomings with url.Parse when it comes to GIT, namely wrt |
| 28 | 28 |
// the GIT local/file and ssh protocols - it does not handle implied schema (i.e. no <proto>:// prefix)well; |
| 29 | 29 |
// We handle those caveats here |
| 30 |
- err = s2igit.New().MungeNoProtocolURL(s, uri) |
|
| 30 |
+ err = s2igit.New(s2iutil.NewFileSystem()).MungeNoProtocolURL(s, uri) |
|
| 31 | 31 |
if err != nil {
|
| 32 | 32 |
return nil, err |
| 33 | 33 |
} |