Skip to content

Commit 87a120e

Browse files
committed
bake: use build.IsRemoteURL
Signed-off-by: Justin Chadwell <[email protected]>
1 parent 589d4e4 commit 87a120e

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

bake/bake.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ func updateContext(t *build.Inputs, inp *Input) {
789789
if strings.HasPrefix(v.Path, "cwd://") || strings.HasPrefix(v.Path, "target:") || strings.HasPrefix(v.Path, "docker-image:") {
790790
continue
791791
}
792-
if IsRemoteURL(v.Path) {
792+
if build.IsRemoteURL(v.Path) {
793793
continue
794794
}
795795
st := llb.Scratch().File(llb.Copy(*inp.State, v.Path, "/"), llb.WithCustomNamef("set context %s to %s", k, v.Path))
@@ -803,7 +803,7 @@ func updateContext(t *build.Inputs, inp *Input) {
803803
if strings.HasPrefix(t.ContextPath, "cwd://") {
804804
return
805805
}
806-
if IsRemoteURL(t.ContextPath) {
806+
if build.IsRemoteURL(t.ContextPath) {
807807
return
808808
}
809809
st := llb.Scratch().File(llb.Copy(*inp.State, t.ContextPath, "/"), llb.WithCustomNamef("set context to %s", t.ContextPath))
@@ -839,7 +839,7 @@ func validateContextsEntitlements(t build.Inputs, inp *Input) error {
839839
}
840840

841841
func checkPath(p string) error {
842-
if IsRemoteURL(p) || strings.HasPrefix(p, "target:") || strings.HasPrefix(p, "docker-image:") {
842+
if build.IsRemoteURL(p) || strings.HasPrefix(p, "target:") || strings.HasPrefix(p, "docker-image:") {
843843
return nil
844844
}
845845
p, err := filepath.EvalSymlinks(p)
@@ -875,7 +875,7 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
875875
if t.Context != nil {
876876
contextPath = *t.Context
877877
}
878-
if !strings.HasPrefix(contextPath, "cwd://") && !IsRemoteURL(contextPath) {
878+
if !strings.HasPrefix(contextPath, "cwd://") && !build.IsRemoteURL(contextPath) {
879879
contextPath = path.Clean(contextPath)
880880
}
881881
dockerfilePath := "Dockerfile"

bake/remote.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,6 @@ func ReadRemoteFiles(ctx context.Context, nodes []builder.Node, url string, name
8383
return files, inp, nil
8484
}
8585

86-
func IsRemoteURL(url string) bool {
87-
if _, _, ok := detectHTTPContext(url); ok {
88-
return true
89-
}
90-
if _, ok := detectGitContext(url); ok {
91-
return true
92-
}
93-
return false
94-
}
95-
9686
func detectHTTPContext(url string) (*llb.State, string, bool) {
9787
if httpPrefix.MatchString(url) {
9888
httpContext := llb.HTTP(url, llb.Filename("context"), llb.WithCustomName("[internal] load remote build context"))

commands/bake.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ func runBake(dockerCli command.Cli, targets []string, in bakeOptions, cFlags com
4747
cmdContext := "cwd://"
4848

4949
if len(targets) > 0 {
50-
if bake.IsRemoteURL(targets[0]) {
50+
if build.IsRemoteURL(targets[0]) {
5151
url = targets[0]
5252
targets = targets[1:]
5353
if len(targets) > 0 {
54-
if bake.IsRemoteURL(targets[0]) {
54+
if build.IsRemoteURL(targets[0]) {
5555
cmdContext = targets[0]
5656
targets = targets[1:]
5757
}

0 commit comments

Comments
 (0)