// BuildImageStream Build the tar stream for the context to send to a docker build
BuildImageStream Build the tar stream for the context to send to a docker build
// BuildImageStream Build the tar stream for the context to send to a docker build
func BuildImageStream(options *BuildOptions) (io.ReadCloser, string, error) {
	var err error
	var excludes []string
	if len(options.SourceIncludes) > 0 || len(options.SourceExcludes) > 0 {
		excludes = composeDockerignore(options.SourceIncludes, options.SourceExcludes)
	} else {
		dockerignore := options.Dockerignore
		if len(dockerignore) < 1 {
			dockerignore = filepath.Join(options.ContextDirectory, ".dockerignore")
		}
		excludes, err = readDockerignore(dockerignore)
		if err != nil {
			return nil, "", err
		}
	}
	dockerfileTarEntry := ""
	_, contextDirRelativeDockerfilePath, err :=
		getContextFromLocalDir(options.ContextDirectory, options.DockerfilePath)
	if err == nil {
		dockerfileTarEntry, _ = canonicalTarNameForPath(contextDirRelativeDockerfilePath)
	}
	err = validateContextDirectory(options.ContextDirectory, excludes)
	if err != nil {
		return nil, "", err
	}
	excludes = trimBuildFilesFromExcludes(excludes, dockerfileTarEntry, true)
	tarOptions := &TarOptions{
		ExcludePatterns: excludes,
		Compression:     Uncompressed,
	}
	buildContext, err := tarWithOptions(options.ContextDirectory, tarOptions)
	if buildContext != nil && options.DockerfileContent != nil {
		buildContext, dockerfileTarEntry, err =
			addBuildFilesToBuildContext(options.ScriptName, options.DockerfileContent, options.ScriptContent, buildContext)
		if err != nil {
			return nil, "", err
		}
	}
	return buildContext, dockerfileTarEntry, err
}
func BuildImageStream ( options * BuildOptions ) ( io . ReadCloser , string , error ) { var err error var excludes [ ] string if len ( options . SourceIncludes ) > 0 || len ( options . SourceExcludes ) > 0 { excludes = composeDockerignore ( options . SourceIncludes , options . SourceExcludes ) } else { dockerignore := options . Dockerignore if len ( dockerignore ) < 1 { dockerignore = filepath . Join ( options . ContextDirectory , " " ) } excludes , err = readDockerignore ( dockerignore ) if err != nil { return nil , " " , err } } dockerfileTarEntry := " " _ , contextDirRelativeDockerfilePath , err := getContextFromLocalDir ( options . ContextDirectory , options . DockerfilePath ) if err == nil { dockerfileTarEntry , _ = canonicalTarNameForPath ( contextDirRelativeDockerfilePath ) } err = validateContextDirectory ( options . ContextDirectory , excludes ) if err != nil { return nil , " " , err } excludes = trimBuildFilesFromExcludes ( excludes , dockerfileTarEntry , true ) tarOptions := & TarOptions { ExcludePatterns : excludes , Compression : Uncompressed , } buildContext , err := tarWithOptions ( options . ContextDirectory , tarOptions ) if buildContext != nil && options . DockerfileContent != nil { buildContext , dockerfileTarEntry , err = addBuildFilesToBuildContext ( options . ScriptName , options . DockerfileContent , options . ScriptContent , buildContext ) if err != nil { return nil , " " , err } } return buildContext , dockerfileTarEntry , err }
BuildImageStream Build the tar stream for the context to send to a docker build
BuildImageStream Build the tar stream for the context to send to a docker build