Merge pull request #590 from AkihiroSuda/split-flagparser

build: split buildflags package
pull/605/head
Tõnis Tiigi 4 years ago committed by GitHub
commit 908a856079
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,6 +10,7 @@ import (
"strings" "strings"
"github.com/docker/buildx/build" "github.com/docker/buildx/build"
"github.com/docker/buildx/util/buildflags"
"github.com/docker/buildx/util/platformutil" "github.com/docker/buildx/util/platformutil"
"github.com/docker/docker/pkg/urlutil" "github.com/docker/docker/pkg/urlutil"
hcl "github.com/hashicorp/hcl/v2" 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)) bo.Session = append(bo.Session, authprovider.NewDockerAuthProvider(os.Stderr))
secrets, err := build.ParseSecretSpecs(t.Secrets) secrets, err := buildflags.ParseSecretSpecs(t.Secrets)
if err != nil { if err != nil {
return nil, err return nil, err
} }
bo.Session = append(bo.Session, secrets) bo.Session = append(bo.Session, secrets)
sshSpecs := t.SSH sshSpecs := t.SSH
if len(sshSpecs) == 0 && build.IsGitSSH(contextPath) { if len(sshSpecs) == 0 && buildflags.IsGitSSH(contextPath) {
sshSpecs = []string{"default"} sshSpecs = []string{"default"}
} }
ssh, err := build.ParseSSHSpecs(sshSpecs) ssh, err := buildflags.ParseSSHSpecs(sshSpecs)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -548,19 +549,19 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
bo.Target = *t.Target bo.Target = *t.Target
} }
cacheImports, err := build.ParseCacheEntry(t.CacheFrom) cacheImports, err := buildflags.ParseCacheEntry(t.CacheFrom)
if err != nil { if err != nil {
return nil, err return nil, err
} }
bo.CacheFrom = cacheImports bo.CacheFrom = cacheImports
cacheExports, err := build.ParseCacheEntry(t.CacheTo) cacheExports, err := buildflags.ParseCacheEntry(t.CacheTo)
if err != nil { if err != nil {
return nil, err return nil, err
} }
bo.CacheTo = cacheExports bo.CacheTo = cacheExports
outputs, err := build.ParseOutputs(t.Outputs) outputs, err := buildflags.ParseOutputs(t.Outputs)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1125,3 +1125,9 @@ func handleLowercaseDockerfile(dir, p string) string {
} }
return p 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" "strings"
"github.com/docker/buildx/build" "github.com/docker/buildx/build"
"github.com/docker/buildx/util/buildflags"
"github.com/docker/buildx/util/platformutil" "github.com/docker/buildx/util/platformutil"
"github.com/docker/buildx/util/progress" "github.com/docker/buildx/util/progress"
"github.com/docker/cli/cli" "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)) opts.Session = append(opts.Session, authprovider.NewDockerAuthProvider(os.Stderr))
secrets, err := build.ParseSecretSpecs(in.secrets) secrets, err := buildflags.ParseSecretSpecs(in.secrets)
if err != nil { if err != nil {
return err return err
} }
opts.Session = append(opts.Session, secrets) opts.Session = append(opts.Session, secrets)
sshSpecs := in.ssh sshSpecs := in.ssh
if len(sshSpecs) == 0 && build.IsGitSSH(in.contextPath) { if len(sshSpecs) == 0 && buildflags.IsGitSSH(in.contextPath) {
sshSpecs = []string{"default"} sshSpecs = []string{"default"}
} }
ssh, err := build.ParseSSHSpecs(sshSpecs) ssh, err := buildflags.ParseSSHSpecs(sshSpecs)
if err != nil { if err != nil {
return err return err
} }
opts.Session = append(opts.Session, ssh) opts.Session = append(opts.Session, ssh)
outputs, err := build.ParseOutputs(in.outputs) outputs, err := buildflags.ParseOutputs(in.outputs)
if err != nil { if err != nil {
return err return err
} }
@ -175,19 +176,19 @@ func runBuild(dockerCli command.Cli, in buildOptions) error {
opts.Exports = outputs opts.Exports = outputs
cacheImports, err := build.ParseCacheEntry(in.cacheFrom) cacheImports, err := buildflags.ParseCacheEntry(in.cacheFrom)
if err != nil { if err != nil {
return err return err
} }
opts.CacheFrom = cacheImports opts.CacheFrom = cacheImports
cacheExports, err := build.ParseCacheEntry(in.cacheTo) cacheExports, err := buildflags.ParseCacheEntry(in.cacheTo)
if err != nil { if err != nil {
return err return err
} }
opts.CacheTo = cacheExports opts.CacheTo = cacheExports
allow, err := build.ParseEntitlements(in.allow) allow, err := buildflags.ParseEntitlements(in.allow)
if err != nil { if err != nil {
return err return err
} }

@ -1,4 +1,4 @@
package build package buildflags
import ( import (
"encoding/csv" "encoding/csv"

@ -1,4 +1,4 @@
package build package buildflags
import ( import (
"github.com/moby/buildkit/util/entitlements" "github.com/moby/buildkit/util/entitlements"

@ -1,4 +1,4 @@
package build package buildflags
import ( import (
"encoding/csv" "encoding/csv"

@ -1,4 +1,4 @@
package build package buildflags
import ( import (
"encoding/csv" "encoding/csv"

@ -1,4 +1,4 @@
package build package buildflags
import ( import (
"strings" "strings"
Loading…
Cancel
Save