mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00
fix lint issues after update
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
6e5aefbb98
commit
503d483731
@ -51,6 +51,7 @@ func ParseCompose(cfgs []compose.ConfigFile, envs map[string]string) (*Config, e
|
|||||||
g := &Group{Name: "default"}
|
g := &Group{Name: "default"}
|
||||||
|
|
||||||
for _, s := range cfg.Services {
|
for _, s := range cfg.Services {
|
||||||
|
s := s
|
||||||
if s.Build == nil {
|
if s.Build == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -631,13 +631,14 @@ func Parse(b hcl.Body, opt Opt, val interface{}) (map[string]map[string][]string
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, a := range content.Attributes {
|
for _, a := range content.Attributes {
|
||||||
|
a := a
|
||||||
return nil, hcl.Diagnostics{
|
return nil, hcl.Diagnostics{
|
||||||
&hcl.Diagnostic{
|
&hcl.Diagnostic{
|
||||||
Severity: hcl.DiagError,
|
Severity: hcl.DiagError,
|
||||||
Summary: "Invalid attribute",
|
Summary: "Invalid attribute",
|
||||||
Detail: "global attributes currently not supported",
|
Detail: "global attributes currently not supported",
|
||||||
Subject: &a.Range,
|
Subject: a.Range.Ptr(),
|
||||||
Context: &a.Range,
|
Context: a.Range.Ptr(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -660,13 +661,14 @@ func Parse(b hcl.Body, opt Opt, val interface{}) (map[string]map[string][]string
|
|||||||
var subject *hcl.Range
|
var subject *hcl.Range
|
||||||
var context *hcl.Range
|
var context *hcl.Range
|
||||||
if p.funcs[k].Params != nil {
|
if p.funcs[k].Params != nil {
|
||||||
subject = &p.funcs[k].Params.Range
|
subject = p.funcs[k].Params.Range.Ptr()
|
||||||
context = subject
|
context = subject
|
||||||
} else {
|
} else {
|
||||||
for _, block := range blocks.Blocks {
|
for _, block := range blocks.Blocks {
|
||||||
|
block := block
|
||||||
if block.Type == "function" && len(block.Labels) == 1 && block.Labels[0] == k {
|
if block.Type == "function" && len(block.Labels) == 1 && block.Labels[0] == k {
|
||||||
subject = &block.LabelRanges[0]
|
subject = block.LabelRanges[0].Ptr()
|
||||||
context = &block.DefRange
|
context = block.DefRange.Ptr()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -732,6 +734,7 @@ func Parse(b hcl.Body, opt Opt, val interface{}) (map[string]map[string][]string
|
|||||||
|
|
||||||
diags = hcl.Diagnostics{}
|
diags = hcl.Diagnostics{}
|
||||||
for _, b := range content.Blocks {
|
for _, b := range content.Blocks {
|
||||||
|
b := b
|
||||||
v := reflect.ValueOf(val)
|
v := reflect.ValueOf(val)
|
||||||
|
|
||||||
err := p.resolveBlock(b, nil)
|
err := p.resolveBlock(b, nil)
|
||||||
@ -742,7 +745,7 @@ func Parse(b hcl.Body, opt Opt, val interface{}) (map[string]map[string][]string
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return nil, wrapErrorDiagnostic("Invalid block", err, &b.LabelRanges[0], &b.DefRange)
|
return nil, wrapErrorDiagnostic("Invalid block", err, b.LabelRanges[0].Ptr(), b.DefRange.Ptr())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
//nolint:gosec // G101: false-positive
|
||||||
printFallbackImage = "docker/dockerfile:1.5.2-labs@sha256:f2e91734a84c0922ff47aa4098ab775f1dfa932430d2888dd5cad5251fafdac4"
|
printFallbackImage = "docker/dockerfile:1.5.2-labs@sha256:f2e91734a84c0922ff47aa4098ab775f1dfa932430d2888dd5cad5251fafdac4"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -35,10 +35,7 @@ func runUse(dockerCli command.Cli, in useOptions) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := txn.SetCurrent(ep, "", false, false); err != nil {
|
return txn.SetCurrent(ep, "", false, false)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
list, err := dockerCli.ContextStore().List()
|
list, err := dockerCli.ContextStore().List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -58,11 +55,7 @@ func runUse(dockerCli command.Cli, in useOptions) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := txn.SetCurrent(ep, in.builder, in.isGlobal, in.isDefault); err != nil {
|
return txn.SetCurrent(ep, in.builder, in.isGlobal, in.isDefault)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func useCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
|
func useCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
|
||||||
|
@ -236,6 +236,7 @@ func TestResolvePaths(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
tt := tt
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
got, err := ResolveOptionPaths(&tt.options)
|
got, err := ResolveOptionPaths(&tt.options)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -73,10 +73,7 @@ func (d *Driver) Bootstrap(ctx context.Context, l progress.Logger) error {
|
|||||||
if err := d.start(ctx, sub); err != nil {
|
if err := d.start(ctx, sub); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := d.wait(ctx, sub); err != nil {
|
return d.wait(ctx, sub)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -119,7 +116,7 @@ func (d *Driver) create(ctx context.Context, l progress.SubLogger) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useInit := true // let it cleanup exited processes created by BuildKit's container API
|
useInit := true // let it cleanup exited processes created by BuildKit's container API
|
||||||
if err := l.Wrap("creating container "+d.Name, func() error {
|
return l.Wrap("creating container "+d.Name, func() error {
|
||||||
hc := &container.HostConfig{
|
hc := &container.HostConfig{
|
||||||
Privileged: true,
|
Privileged: true,
|
||||||
Mounts: []mount.Mount{
|
Mounts: []mount.Mount{
|
||||||
@ -189,14 +186,8 @@ func (d *Driver) create(ctx context.Context, l progress.SubLogger) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := d.wait(ctx, l); err != nil {
|
return d.wait(ctx, l)
|
||||||
return err
|
})
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) wait(ctx context.Context, l progress.SubLogger) error {
|
func (d *Driver) wait(ctx context.Context, l progress.SubLogger) error {
|
||||||
|
@ -87,10 +87,7 @@ func (d *Driver) Bootstrap(ctx context.Context, l progress.Logger) error {
|
|||||||
return sub.Wrap(
|
return sub.Wrap(
|
||||||
fmt.Sprintf("waiting for %d pods to be ready", d.minReplicas),
|
fmt.Sprintf("waiting for %d pods to be ready", d.minReplicas),
|
||||||
func() error {
|
func() error {
|
||||||
if err := d.wait(ctx); err != nil {
|
return d.wait(ctx)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -228,7 +225,7 @@ func (d *Driver) Factory() driver.Factory {
|
|||||||
return d.factory
|
return d.factory
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Features(ctx context.Context) map[driver.Feature]bool {
|
func (d *Driver) Features(_ context.Context) map[driver.Feature]bool {
|
||||||
return map[driver.Feature]bool{
|
return map[driver.Feature]bool{
|
||||||
driver.OCIExporter: true,
|
driver.OCIExporter: true,
|
||||||
driver.DockerExporter: d.DockerAPI != nil,
|
driver.DockerExporter: d.DockerAPI != nil,
|
||||||
@ -237,6 +234,6 @@ func (d *Driver) Features(ctx context.Context) map[driver.Feature]bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) HostGatewayIP(ctx context.Context) (net.IP, error) {
|
func (d *Driver) HostGatewayIP(_ context.Context) (net.IP, error) {
|
||||||
return nil, errors.New("host-gateway is not supported by the kubernetes driver")
|
return nil, errors.New("host-gateway is not supported by the kubernetes driver")
|
||||||
}
|
}
|
||||||
|
@ -102,10 +102,7 @@ func (ng *NodeGroup) Update(name, endpoint string, platforms []string, endpoints
|
|||||||
}
|
}
|
||||||
|
|
||||||
ng.Nodes[i] = n
|
ng.Nodes[i] = n
|
||||||
if err := ng.validateDuplicates(endpoint, i); err != nil {
|
return ng.validateDuplicates(endpoint, i)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if name == "" {
|
if name == "" {
|
||||||
@ -127,11 +124,7 @@ func (ng *NodeGroup) Update(name, endpoint string, platforms []string, endpoints
|
|||||||
}
|
}
|
||||||
|
|
||||||
ng.Nodes = append(ng.Nodes, n)
|
ng.Nodes = append(ng.Nodes, n)
|
||||||
|
return ng.validateDuplicates(endpoint, len(ng.Nodes)-1)
|
||||||
if err := ng.validateDuplicates(endpoint, len(ng.Nodes)-1); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ng *NodeGroup) Copy() *NodeGroup {
|
func (ng *NodeGroup) Copy() *NodeGroup {
|
||||||
|
@ -185,10 +185,7 @@ func (t *Txn) reset(key string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := ioutils.AtomicWriteFile(filepath.Join(t.s.root, "current"), dt, 0600); err != nil {
|
return ioutils.AtomicWriteFile(filepath.Join(t.s.root, "current"), dt, 0600)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Txn) Current(key string) (*NodeGroup, error) {
|
func (t *Txn) Current(key string) (*NodeGroup, error) {
|
||||||
|
@ -18,9 +18,9 @@ func TestEmptyStartup(t *testing.T) {
|
|||||||
s, err := New(tmpdir)
|
s, err := New(tmpdir)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
txn, close, err := s.Txn()
|
txn, release, err := s.Txn()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer close()
|
defer release()
|
||||||
|
|
||||||
ng, err := txn.Current("foo")
|
ng, err := txn.Current("foo")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -80,8 +80,8 @@ func (w *containerWorker) New(ctx context.Context, cfg *integration.BackendConfi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *containerWorker) Close() error {
|
func (w *containerWorker) Close() error {
|
||||||
if close := w.dockerClose; close != nil {
|
if c := w.dockerClose; c != nil {
|
||||||
return close()
|
return c()
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset the worker to be ready to go again
|
// reset the worker to be ready to go again
|
||||||
|
Loading…
x
Reference in New Issue
Block a user