mirror of https://github.com/docker/buildx.git
Merge pull request #590 from AkihiroSuda/split-flagparser
build: split buildflags package
This commit is contained in:
commit
908a856079
13
bake/bake.go
13
bake/bake.go
|
@ -10,6 +10,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/docker/buildx/build"
|
||||
"github.com/docker/buildx/util/buildflags"
|
||||
"github.com/docker/buildx/util/platformutil"
|
||||
"github.com/docker/docker/pkg/urlutil"
|
||||
hcl "github.com/hashicorp/hcl/v2"
|
||||
|
@ -528,17 +529,17 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
|
|||
|
||||
bo.Session = append(bo.Session, authprovider.NewDockerAuthProvider(os.Stderr))
|
||||
|
||||
secrets, err := build.ParseSecretSpecs(t.Secrets)
|
||||
secrets, err := buildflags.ParseSecretSpecs(t.Secrets)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bo.Session = append(bo.Session, secrets)
|
||||
|
||||
sshSpecs := t.SSH
|
||||
if len(sshSpecs) == 0 && build.IsGitSSH(contextPath) {
|
||||
if len(sshSpecs) == 0 && buildflags.IsGitSSH(contextPath) {
|
||||
sshSpecs = []string{"default"}
|
||||
}
|
||||
ssh, err := build.ParseSSHSpecs(sshSpecs)
|
||||
ssh, err := buildflags.ParseSSHSpecs(sshSpecs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -548,19 +549,19 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
|
|||
bo.Target = *t.Target
|
||||
}
|
||||
|
||||
cacheImports, err := build.ParseCacheEntry(t.CacheFrom)
|
||||
cacheImports, err := buildflags.ParseCacheEntry(t.CacheFrom)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bo.CacheFrom = cacheImports
|
||||
|
||||
cacheExports, err := build.ParseCacheEntry(t.CacheTo)
|
||||
cacheExports, err := buildflags.ParseCacheEntry(t.CacheTo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bo.CacheTo = cacheExports
|
||||
|
||||
outputs, err := build.ParseOutputs(t.Outputs)
|
||||
outputs, err := buildflags.ParseOutputs(t.Outputs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -1125,3 +1125,9 @@ func handleLowercaseDockerfile(dir, p string) string {
|
|||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func wrapWriteCloser(wc io.WriteCloser) func(map[string]string) (io.WriteCloser, error) {
|
||||
return func(map[string]string) (io.WriteCloser, error) {
|
||||
return wc, nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/docker/buildx/build"
|
||||
"github.com/docker/buildx/util/buildflags"
|
||||
"github.com/docker/buildx/util/platformutil"
|
||||
"github.com/docker/buildx/util/progress"
|
||||
"github.com/docker/cli/cli"
|
||||
|
@ -118,23 +119,23 @@ func runBuild(dockerCli command.Cli, in buildOptions) error {
|
|||
|
||||
opts.Session = append(opts.Session, authprovider.NewDockerAuthProvider(os.Stderr))
|
||||
|
||||
secrets, err := build.ParseSecretSpecs(in.secrets)
|
||||
secrets, err := buildflags.ParseSecretSpecs(in.secrets)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts.Session = append(opts.Session, secrets)
|
||||
|
||||
sshSpecs := in.ssh
|
||||
if len(sshSpecs) == 0 && build.IsGitSSH(in.contextPath) {
|
||||
if len(sshSpecs) == 0 && buildflags.IsGitSSH(in.contextPath) {
|
||||
sshSpecs = []string{"default"}
|
||||
}
|
||||
ssh, err := build.ParseSSHSpecs(sshSpecs)
|
||||
ssh, err := buildflags.ParseSSHSpecs(sshSpecs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts.Session = append(opts.Session, ssh)
|
||||
|
||||
outputs, err := build.ParseOutputs(in.outputs)
|
||||
outputs, err := buildflags.ParseOutputs(in.outputs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -175,19 +176,19 @@ func runBuild(dockerCli command.Cli, in buildOptions) error {
|
|||
|
||||
opts.Exports = outputs
|
||||
|
||||
cacheImports, err := build.ParseCacheEntry(in.cacheFrom)
|
||||
cacheImports, err := buildflags.ParseCacheEntry(in.cacheFrom)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts.CacheFrom = cacheImports
|
||||
|
||||
cacheExports, err := build.ParseCacheEntry(in.cacheTo)
|
||||
cacheExports, err := buildflags.ParseCacheEntry(in.cacheTo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts.CacheTo = cacheExports
|
||||
|
||||
allow, err := build.ParseEntitlements(in.allow)
|
||||
allow, err := buildflags.ParseEntitlements(in.allow)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package build
|
||||
package buildflags
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
|
@ -1,4 +1,4 @@
|
|||
package build
|
||||
package buildflags
|
||||
|
||||
import (
|
||||
"github.com/moby/buildkit/util/entitlements"
|
|
@ -1,4 +1,4 @@
|
|||
package build
|
||||
package buildflags
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
|
@ -1,4 +1,4 @@
|
|||
package build
|
||||
package buildflags
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
|
@ -1,4 +1,4 @@
|
|||
package build
|
||||
package buildflags
|
||||
|
||||
import (
|
||||
"strings"
|
Loading…
Reference in New Issue