Merge pull request #30411 from thaJeztah/fix-build-from-local-github-directories

do not ignore local build-contexts starting with "github.com"
This commit is contained in:
Alexander Morozov 2017-01-31 12:45:11 -08:00 committed by GitHub
commit 543c88bb33
1 changed files with 8 additions and 1 deletions

View File

@ -157,12 +157,14 @@ func runBuild(dockerCli *command.DockerCli, options buildOptions) error {
switch {
case specifiedContext == "-":
buildCtx, relDockerfile, err = build.GetContextFromReader(dockerCli.In(), options.dockerfileName)
case isLocalDir(specifiedContext):
contextDir, relDockerfile, err = build.GetContextFromLocalDir(specifiedContext, options.dockerfileName)
case urlutil.IsGitURL(specifiedContext):
tempDir, relDockerfile, err = build.GetContextFromGitURL(specifiedContext, options.dockerfileName)
case urlutil.IsURL(specifiedContext):
buildCtx, relDockerfile, err = build.GetContextFromURL(progBuff, specifiedContext, options.dockerfileName)
default:
contextDir, relDockerfile, err = build.GetContextFromLocalDir(specifiedContext, options.dockerfileName)
return fmt.Errorf("unable to prepare context: path %q not found", specifiedContext)
}
if err != nil {
@ -357,6 +359,11 @@ func runBuild(dockerCli *command.DockerCli, options buildOptions) error {
return nil
}
func isLocalDir(c string) bool {
_, err := os.Stat(c)
return err == nil
}
type translatorFunc func(context.Context, reference.NamedTagged) (reference.Canonical, error)
// validateTag checks if the given image name can be resolved.