فهرست منبع

Update code for use of urlutil pkg

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Michael Crosby 10 سال پیش
والد
کامیت
5794b5373e
3فایلهای تغییر یافته به همراه10 افزوده شده و 7 حذف شده
  1. 4 3
      api/client/commands.go
  2. 2 1
      builder/internals.go
  3. 4 3
      builder/job.go

+ 4 - 3
api/client/commands.go

@@ -38,6 +38,7 @@ import (
 	"github.com/docker/docker/pkg/term"
 	"github.com/docker/docker/pkg/term"
 	"github.com/docker/docker/pkg/timeutils"
 	"github.com/docker/docker/pkg/timeutils"
 	"github.com/docker/docker/pkg/units"
 	"github.com/docker/docker/pkg/units"
+	"github.com/docker/docker/pkg/urlutil"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"
@@ -115,13 +116,13 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
 		} else {
 		} else {
 			context = ioutil.NopCloser(buf)
 			context = ioutil.NopCloser(buf)
 		}
 		}
-	} else if utils.IsURL(cmd.Arg(0)) && (!utils.IsGIT(cmd.Arg(0)) || !hasGit) {
+	} else if urlutil.IsURL(cmd.Arg(0)) && (!urlutil.IsGitURL(cmd.Arg(0)) || !hasGit) {
 		isRemote = true
 		isRemote = true
 	} else {
 	} else {
 		root := cmd.Arg(0)
 		root := cmd.Arg(0)
-		if utils.IsGIT(root) {
+		if urlutil.IsGitURL(root) {
 			remoteURL := cmd.Arg(0)
 			remoteURL := cmd.Arg(0)
-			if !utils.ValidGitTransport(remoteURL) {
+			if !urlutil.IsGitTransport(remoteURL) {
 				remoteURL = "https://" + remoteURL
 				remoteURL = "https://" + remoteURL
 			}
 			}
 
 

+ 2 - 1
builder/internals.go

@@ -28,6 +28,7 @@ import (
 	"github.com/docker/docker/pkg/symlink"
 	"github.com/docker/docker/pkg/symlink"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/tarsum"
 	"github.com/docker/docker/pkg/tarsum"
+	"github.com/docker/docker/pkg/urlutil"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"
 )
 )
@@ -215,7 +216,7 @@ func calcCopyInfo(b *Builder, cmdName string, cInfos *[]*copyInfo, origPath stri
 	origPath = strings.TrimPrefix(origPath, "./")
 	origPath = strings.TrimPrefix(origPath, "./")
 
 
 	// In the remote/URL case, download it and gen its hashcode
 	// In the remote/URL case, download it and gen its hashcode
-	if utils.IsURL(origPath) {
+	if urlutil.IsURL(origPath) {
 		if !allowRemote {
 		if !allowRemote {
 			return fmt.Errorf("Source can't be a URL for %s", cmdName)
 			return fmt.Errorf("Source can't be a URL for %s", cmdName)
 		}
 		}

+ 4 - 3
builder/job.go

@@ -11,6 +11,7 @@ import (
 	"github.com/docker/docker/graph"
 	"github.com/docker/docker/graph"
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/parsers"
+	"github.com/docker/docker/pkg/urlutil"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"
 )
 )
@@ -58,8 +59,8 @@ func (b *BuilderJob) CmdBuild(job *engine.Job) engine.Status {
 
 
 	if remoteURL == "" {
 	if remoteURL == "" {
 		context = ioutil.NopCloser(job.Stdin)
 		context = ioutil.NopCloser(job.Stdin)
-	} else if utils.IsGIT(remoteURL) {
-		if !utils.ValidGitTransport(remoteURL) {
+	} else if urlutil.IsGitURL(remoteURL) {
+		if !urlutil.IsGitTransport(remoteURL) {
 			remoteURL = "https://" + remoteURL
 			remoteURL = "https://" + remoteURL
 		}
 		}
 		root, err := ioutil.TempDir("", "docker-build-git")
 		root, err := ioutil.TempDir("", "docker-build-git")
@@ -77,7 +78,7 @@ func (b *BuilderJob) CmdBuild(job *engine.Job) engine.Status {
 			return job.Error(err)
 			return job.Error(err)
 		}
 		}
 		context = c
 		context = c
-	} else if utils.IsURL(remoteURL) {
+	} else if urlutil.IsURL(remoteURL) {
 		f, err := utils.Download(remoteURL)
 		f, err := utils.Download(remoteURL)
 		if err != nil {
 		if err != nil {
 			return job.Error(err)
 			return job.Error(err)