linters: unused arguments shouldn't have names

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
Nalin Dahyabhai 2024-08-06 15:07:02 -04:00
parent 6224e9a44e
commit fdf1c75cd3
30 changed files with 107 additions and 108 deletions

2
add.go
View File

@ -567,7 +567,7 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
return false, false, nil return false, false, nil
}) })
} }
writer = newTarFilterer(writer, func(hdr *tar.Header) (bool, bool, io.Reader) { writer = newTarFilterer(writer, func(_ *tar.Header) (bool, bool, io.Reader) {
itemsCopied++ itemsCopied++
return false, false, nil return false, false, nil
}) })

View File

@ -225,7 +225,7 @@ func makeRlimit(limit specs.POSIXRlimit) unix.Rlimit {
return unix.Rlimit{Cur: limit.Soft, Max: limit.Hard} return unix.Rlimit{Cur: limit.Soft, Max: limit.Hard}
} }
func createPlatformContainer(options runUsingChrootExecSubprocOptions) error { func createPlatformContainer(_ runUsingChrootExecSubprocOptions) error {
return errors.New("unsupported createPlatformContainer") return errors.New("unsupported createPlatformContainer")
} }

View File

@ -127,9 +127,9 @@ func TestMinimalSkeleton(t *testing.T) {
t.Skip("tests need to be run as root") t.Skip("tests need to be run as root")
} }
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(_ *generate.Generator, _, _ string) {
}, },
func(t *testing.T, report *types.TestReport) { func(_ *testing.T, _ *types.TestReport) {
}, },
) )
} }
@ -140,7 +140,7 @@ func TestProcessTerminal(t *testing.T) {
} }
for _, terminal := range []bool{false, true} { for _, terminal := range []bool{false, true} {
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(g *generate.Generator, _, _ string) {
g.SetProcessTerminal(terminal) g.SetProcessTerminal(terminal)
}, },
func(t *testing.T, report *types.TestReport) { func(t *testing.T, report *types.TestReport) {
@ -158,7 +158,7 @@ func TestProcessConsoleSize(t *testing.T) {
} }
for _, size := range [][2]uint{{80, 25}, {132, 50}} { for _, size := range [][2]uint{{80, 25}, {132, 50}} {
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(g *generate.Generator, _, _ string) {
g.SetProcessTerminal(true) g.SetProcessTerminal(true)
g.SetProcessConsoleSize(size[0], size[1]) g.SetProcessConsoleSize(size[0], size[1])
}, },
@ -180,7 +180,7 @@ func TestProcessUser(t *testing.T) {
} }
for _, id := range []uint32{0, 1000} { for _, id := range []uint32{0, 1000} {
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(g *generate.Generator, _, _ string) {
g.SetProcessUID(id) g.SetProcessUID(id)
g.SetProcessGID(id + 1) g.SetProcessGID(id + 1)
g.AddProcessAdditionalGid(id + 2) g.AddProcessAdditionalGid(id + 2)
@ -203,7 +203,7 @@ func TestProcessEnv(t *testing.T) {
} }
e := fmt.Sprintf("PARENT_TEST_PID=%d", unix.Getpid()) e := fmt.Sprintf("PARENT_TEST_PID=%d", unix.Getpid())
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(g *generate.Generator, _, _ string) {
g.ClearProcessEnv() g.ClearProcessEnv()
g.AddProcessEnv("PARENT_TEST_PID", strconv.Itoa(unix.Getpid())) g.AddProcessEnv("PARENT_TEST_PID", strconv.Itoa(unix.Getpid()))
}, },
@ -223,7 +223,7 @@ func TestProcessCwd(t *testing.T) {
t.Skip("tests need to be run as root") t.Skip("tests need to be run as root")
} }
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(g *generate.Generator, rootDir, _ string) {
if err := os.Mkdir(filepath.Join(rootDir, "/no-such-directory"), 0700); err != nil { if err := os.Mkdir(filepath.Join(rootDir, "/no-such-directory"), 0700); err != nil {
t.Fatalf("mkdir(%q): %v", filepath.Join(rootDir, "/no-such-directory"), err) t.Fatalf("mkdir(%q): %v", filepath.Join(rootDir, "/no-such-directory"), err)
} }
@ -242,7 +242,7 @@ func TestProcessCapabilities(t *testing.T) {
t.Skip("tests need to be run as root") t.Skip("tests need to be run as root")
} }
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(g *generate.Generator, _, _ string) {
g.ClearProcessCapabilities() g.ClearProcessCapabilities()
}, },
func(t *testing.T, report *types.TestReport) { func(t *testing.T, report *types.TestReport) {
@ -252,7 +252,7 @@ func TestProcessCapabilities(t *testing.T) {
}, },
) )
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(g *generate.Generator, _, _ string) {
g.ClearProcessCapabilities() g.ClearProcessCapabilities()
if err := g.AddProcessCapabilityEffective("CAP_IPC_LOCK"); err != nil { if err := g.AddProcessCapabilityEffective("CAP_IPC_LOCK"); err != nil {
t.Fatalf("%v", err) t.Fatalf("%v", err)
@ -287,7 +287,7 @@ func TestProcessRlimits(t *testing.T) {
} }
for _, limit := range []uint64{100 * 1024 * 1024 * 1024, 200 * 1024 * 1024 * 1024, unix.RLIM_INFINITY} { for _, limit := range []uint64{100 * 1024 * 1024 * 1024, 200 * 1024 * 1024 * 1024, unix.RLIM_INFINITY} {
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(g *generate.Generator, _, _ string) {
g.ClearProcessRlimits() g.ClearProcessRlimits()
if limit != unix.RLIM_INFINITY { if limit != unix.RLIM_INFINITY {
g.AddProcessRlimits("rlimit_as", limit, limit) g.AddProcessRlimits("rlimit_as", limit, limit)
@ -328,7 +328,7 @@ func TestProcessNoNewPrivileges(t *testing.T) {
} }
for _, nope := range []bool{false, true} { for _, nope := range []bool{false, true} {
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(g *generate.Generator, _, _ string) {
g.SetProcessNoNewPrivileges(nope) g.SetProcessNoNewPrivileges(nope)
}, },
func(t *testing.T, report *types.TestReport) { func(t *testing.T, report *types.TestReport) {
@ -346,7 +346,7 @@ func TestProcessOOMScoreAdj(t *testing.T) {
} }
for _, adj := range []int{0, 1, 2, 3} { for _, adj := range []int{0, 1, 2, 3} {
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(g *generate.Generator, _, _ string) {
g.SetProcessOOMScoreAdj(adj) g.SetProcessOOMScoreAdj(adj)
}, },
func(t *testing.T, report *types.TestReport) { func(t *testing.T, report *types.TestReport) {
@ -368,7 +368,7 @@ func TestHostname(t *testing.T) {
} }
hostname := fmt.Sprintf("host%d", unix.Getpid()) hostname := fmt.Sprintf("host%d", unix.Getpid())
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(g *generate.Generator, _, _ string) {
g.SetHostname(hostname) g.SetHostname(hostname)
}, },
func(t *testing.T, report *types.TestReport) { func(t *testing.T, report *types.TestReport) {
@ -385,7 +385,7 @@ func TestMounts(t *testing.T) {
} }
t.Run("tmpfs", func(t *testing.T) { t.Run("tmpfs", func(t *testing.T) {
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(g *generate.Generator, _, _ string) {
g.AddMount(specs.Mount{ g.AddMount(specs.Mount{
Source: "tmpfs", Source: "tmpfs",
Destination: "/was-not-there-before", Destination: "/was-not-there-before",
@ -485,7 +485,7 @@ func TestMounts(t *testing.T) {
tmpfsFlags, tmpfsOptions := mount.ParseOptions(tmpfsOptions) tmpfsFlags, tmpfsOptions := mount.ParseOptions(tmpfsOptions)
require.NoErrorf(t, unix.Mount("none", tmpfsMount, "tmpfs", uintptr(tmpfsFlags), tmpfsOptions), "error mounting a tmpfs with flags=%#x,options=%q at %s", tmpfsFlags, tmpfsOptions, tmpfsMount) require.NoErrorf(t, unix.Mount("none", tmpfsMount, "tmpfs", uintptr(tmpfsFlags), tmpfsOptions), "error mounting a tmpfs with flags=%#x,options=%q at %s", tmpfsFlags, tmpfsOptions, tmpfsMount)
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(g *generate.Generator, _, _ string) {
fsType := bind.fsType fsType := bind.fsType
if fsType == "" { if fsType == "" {
fsType = "bind" fsType = "bind"
@ -543,7 +543,7 @@ func TestLinuxIDMapping(t *testing.T) {
t.Skip("tests need to be run as root") t.Skip("tests need to be run as root")
} }
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(g *generate.Generator, _, _ string) {
g.ClearLinuxUIDMappings() g.ClearLinuxUIDMappings()
g.ClearLinuxGIDMappings() g.ClearLinuxGIDMappings()
g.AddLinuxUIDMapping(uint32(unix.Getuid()), 0, 1) g.AddLinuxUIDMapping(uint32(unix.Getuid()), 0, 1)
@ -580,7 +580,7 @@ func TestLinuxIDMappingShift(t *testing.T) {
t.Skip("tests need to be run as root") t.Skip("tests need to be run as root")
} }
testMinimal(t, testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) { func(g *generate.Generator, _, _ string) {
g.ClearLinuxUIDMappings() g.ClearLinuxUIDMappings()
g.ClearLinuxGIDMappings() g.ClearLinuxGIDMappings()
g.AddLinuxUIDMapping(uint32(unix.Getuid())+1, 0, 1) g.AddLinuxUIDMapping(uint32(unix.Getuid())+1, 0, 1)

View File

@ -49,7 +49,7 @@ func TestGetStore(t *testing.T) {
failTestIfNotRoot(t) failTestIfNotRoot(t)
testCmd := &cobra.Command{ testCmd := &cobra.Command{
Use: "test", Use: "test",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, _ []string) error {
_, err := getStore(cmd) _, err := getStore(cmd)
return err return err
}, },

View File

@ -21,7 +21,7 @@ var (
} }
) )
func dumpBoltCmd(c *cobra.Command, args []string) error { func dumpBoltCmd(_ *cobra.Command, args []string) error {
db, err := bolt.Open(args[0], 0600, &bolt.Options{ReadOnly: true}) db, err := bolt.Open(args[0], 0600, &bolt.Options{ReadOnly: true})
if err != nil { if err != nil {
return fmt.Errorf("opening database %q: %w", args[0], err) return fmt.Errorf("opening database %q: %w", args[0], err)

View File

@ -28,7 +28,7 @@ func init() {
Use: "info", Use: "info",
Short: "Display Buildah system information", Short: "Display Buildah system information",
Long: infoDescription, Long: infoDescription,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, _ []string) error {
return infoCmd(cmd, opts) return infoCmd(cmd, opts)
}, },
Args: cobra.NoArgs, Args: cobra.NoArgs,

View File

@ -45,13 +45,13 @@ type globalFlags struct {
var rootCmd = &cobra.Command{ var rootCmd = &cobra.Command{
Use: "buildah", Use: "buildah",
Long: "A tool that facilitates building OCI images", Long: "A tool that facilitates building OCI images",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, _ []string) error {
return cmd.Help() return cmd.Help()
}, },
PersistentPreRunE: func(cmd *cobra.Command, args []string) error { PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
return before(cmd) return before(cmd)
}, },
PersistentPostRunE: func(cmd *cobra.Command, args []string) error { PersistentPostRunE: func(cmd *cobra.Command, _ []string) error {
return after(cmd) return after(cmd)
}, },
SilenceUsage: true, SilenceUsage: true,

View File

@ -623,7 +623,7 @@ func manifestAddCmd(c *cobra.Command, args []string, opts manifestAddOpts) error
return err return err
} }
func manifestRemoveCmd(c *cobra.Command, args []string, opts manifestRemoveOpts) error { func manifestRemoveCmd(c *cobra.Command, args []string, _ manifestRemoveOpts) error {
listImageSpec := "" listImageSpec := ""
var instanceDigest digest.Digest var instanceDigest digest.Digest
var instanceSpec string var instanceSpec string

View File

@ -20,7 +20,7 @@ var (
} }
) )
func passwdCmd(c *cobra.Command, args []string) error { func passwdCmd(_ *cobra.Command, args []string) error {
passwd, err := bcrypt.GenerateFromPassword([]byte(args[0]), bcrypt.DefaultCost) passwd, err := bcrypt.GenerateFromPassword([]byte(args[0]), bcrypt.DefaultCost)
if err != nil { if err != nil {
return err return err

View File

@ -17,7 +17,7 @@ var (
Use: "source", Use: "source",
Short: "Manage source containers", Short: "Manage source containers",
Long: sourceDescription, Long: sourceDescription,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(_ *cobra.Command, _ []string) error {
return nil return nil
}, },
} }
@ -34,7 +34,7 @@ var (
Short: "Create a source image", Short: "Create a source image",
Long: sourceCreateDescription, Long: sourceCreateDescription,
Example: "buildah source create /tmp/fedora:latest-source", Example: "buildah source create /tmp/fedora:latest-source",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(_ *cobra.Command, args []string) error {
return source.Create(context.Background(), args[0], sourceCreateOptions) return source.Create(context.Background(), args[0], sourceCreateOptions)
}, },
} }
@ -51,7 +51,7 @@ var (
Short: "Add a source artifact to a source image", Short: "Add a source artifact to a source image",
Long: sourceAddDescription, Long: sourceAddDescription,
Example: "buildah source add /tmp/fedora sources.tar.gz", Example: "buildah source add /tmp/fedora sources.tar.gz",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(_ *cobra.Command, args []string) error {
return source.Add(context.Background(), args[0], args[1], sourceAddOptions) return source.Add(context.Background(), args[0], args[1], sourceAddOptions)
}, },
} }
@ -68,7 +68,7 @@ var (
Short: "Pull a source image from a registry to a specified path", Short: "Pull a source image from a registry to a specified path",
Long: sourcePullDescription, Long: sourcePullDescription,
Example: "buildah source pull quay.io/sourceimage/example:latest /tmp/sourceimage:latest", Example: "buildah source pull quay.io/sourceimage/example:latest /tmp/sourceimage:latest",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(_ *cobra.Command, args []string) error {
return source.Pull(context.Background(), args[0], args[1], sourcePullOptions) return source.Pull(context.Background(), args[0], args[1], sourcePullOptions)
}, },
} }
@ -85,7 +85,7 @@ var (
Short: "Push a source image from a specified path to a registry", Short: "Push a source image from a specified path to a registry",
Long: sourcePushDescription, Long: sourcePushDescription,
Example: "buildah source push /tmp/sourceimage:latest quay.io/sourceimage/example:latest", Example: "buildah source push /tmp/sourceimage:latest quay.io/sourceimage/example:latest",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(_ *cobra.Command, args []string) error {
return source.Push(context.Background(), args[0], args[1], sourcePushOptions) return source.Push(context.Background(), args[0], args[1], sourcePushOptions)
}, },
} }

View File

@ -49,7 +49,7 @@ func init() {
Use: "version", Use: "version",
Short: "Display the Buildah version information", Short: "Display the Buildah version information",
Long: "Displays Buildah version information.", Long: "Displays Buildah version information.",
RunE: func(c *cobra.Command, args []string) error { RunE: func(_ *cobra.Command, _ []string) error {
return versionCmd(opts) return versionCmd(opts)
}, },
Args: cobra.NoArgs, Args: cobra.NoArgs,

View File

@ -222,7 +222,7 @@ type EvalOptions struct {
// If the directory is specified as an absolute path, it should either be the // If the directory is specified as an absolute path, it should either be the
// root directory or a subdirectory of the root directory. Otherwise, the // root directory or a subdirectory of the root directory. Otherwise, the
// directory is treated as a path relative to the root directory. // directory is treated as a path relative to the root directory.
func Eval(root string, directory string, options EvalOptions) (string, error) { func Eval(root string, directory string, _ EvalOptions) (string, error) {
req := request{ req := request{
Request: requestEval, Request: requestEval,
Root: root, Root: root,

View File

@ -505,7 +505,7 @@ func testPut(t *testing.T) {
require.NoErrorf(t, err, "error extracting archive %q to directory %q", testArchives[i].name, tmp) require.NoErrorf(t, err, "error extracting archive %q to directory %q", testArchives[i].name, tmp)
var found []string var found []string
err = filepath.WalkDir(tmp, func(path string, d fs.DirEntry, err error) error { err = filepath.WalkDir(tmp, func(path string, _ fs.DirEntry, err error) error {
if err != nil { if err != nil {
return err return err
} }
@ -1607,7 +1607,7 @@ func testMkdir(t *testing.T) {
root := dir root := dir
options := MkdirOptions{ChownNew: &idtools.IDPair{UID: os.Getuid(), GID: os.Getgid()}} options := MkdirOptions{ChownNew: &idtools.IDPair{UID: os.Getuid(), GID: os.Getgid()}}
var beforeNames, afterNames []string var beforeNames, afterNames []string
err = filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error { err = filepath.WalkDir(dir, func(path string, _ fs.DirEntry, err error) error {
if err != nil { if err != nil {
return err return err
} }
@ -1621,7 +1621,7 @@ func testMkdir(t *testing.T) {
require.NoErrorf(t, err, "error walking directory to catalog pre-Mkdir contents: %v", err) require.NoErrorf(t, err, "error walking directory to catalog pre-Mkdir contents: %v", err)
err = Mkdir(root, testCase.create, options) err = Mkdir(root, testCase.create, options)
require.NoErrorf(t, err, "error creating directory %q under %q with Mkdir: %v", testCase.create, root, err) require.NoErrorf(t, err, "error creating directory %q under %q with Mkdir: %v", testCase.create, root, err)
err = filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error { err = filepath.WalkDir(dir, func(path string, _ fs.DirEntry, err error) error {
if err != nil { if err != nil {
return err return err
} }
@ -1822,7 +1822,7 @@ func testRemove(t *testing.T) {
root := dir root := dir
options := RemoveOptions{All: testCase.all} options := RemoveOptions{All: testCase.all}
beforeNames := make(map[string]struct{}) beforeNames := make(map[string]struct{})
err = filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error { err = filepath.WalkDir(dir, func(path string, _ fs.DirEntry, err error) error {
if err != nil { if err != nil {
return err return err
} }
@ -1841,7 +1841,7 @@ func testRemove(t *testing.T) {
} }
require.NoErrorf(t, err, "error removing item %q under %q with Remove: %v", testCase.remove, root, err) require.NoErrorf(t, err, "error removing item %q under %q with Remove: %v", testCase.remove, root, err)
afterNames := make(map[string]struct{}) afterNames := make(map[string]struct{})
err = filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error { err = filepath.WalkDir(dir, func(path string, _ fs.DirEntry, err error) error {
if err != nil { if err != nil {
return err return err
} }

View File

@ -58,7 +58,7 @@ func lchown(path string, uid, gid int) error {
return os.Lchown(path, uid, gid) return os.Lchown(path, uid, gid)
} }
func lutimes(isSymlink bool, path string, atime, mtime time.Time) error { func lutimes(_ bool, path string, atime, mtime time.Time) error {
if atime.IsZero() || mtime.IsZero() { if atime.IsZero() || mtime.IsZero() {
now := time.Now() now := time.Now()
if atime.IsZero() { if atime.IsZero() {

View File

@ -409,7 +409,7 @@ func (i *containerImageRef) createConfigsAndManifests() (v1.Image, v1.Manifest,
return oimage, omanifest, dimage, dmanifest, nil return oimage, omanifest, dimage, dmanifest, nil
} }
func (i *containerImageRef) NewImageSource(ctx context.Context, sc *types.SystemContext) (src types.ImageSource, err error) { func (i *containerImageRef) NewImageSource(_ context.Context, _ *types.SystemContext) (src types.ImageSource, err error) {
// Decide which type of manifest and configuration output we're going to provide. // Decide which type of manifest and configuration output we're going to provide.
manifestType := i.preferredManifestType manifestType := i.preferredManifestType
// If it's not a format we support, return an error. // If it's not a format we support, return an error.
@ -922,7 +922,7 @@ func (i *containerImageRef) NewImageSource(ctx context.Context, sc *types.System
return src, nil return src, nil
} }
func (i *containerImageRef) NewImageDestination(ctx context.Context, sc *types.SystemContext) (types.ImageDestination, error) { func (i *containerImageRef) NewImageDestination(_ context.Context, _ *types.SystemContext) (types.ImageDestination, error) {
return nil, errors.New("can't write to a container") return nil, errors.New("can't write to a container")
} }
@ -966,15 +966,15 @@ func (i *containerImageSource) Reference() types.ImageReference {
return i.ref return i.ref
} }
func (i *containerImageSource) GetSignatures(ctx context.Context, instanceDigest *digest.Digest) ([][]byte, error) { func (i *containerImageSource) GetSignatures(_ context.Context, _ *digest.Digest) ([][]byte, error) {
return nil, nil return nil, nil
} }
func (i *containerImageSource) GetManifest(ctx context.Context, instanceDigest *digest.Digest) ([]byte, string, error) { func (i *containerImageSource) GetManifest(_ context.Context, _ *digest.Digest) ([]byte, string, error) {
return i.manifest, i.manifestType, nil return i.manifest, i.manifestType, nil
} }
func (i *containerImageSource) LayerInfosForCopy(ctx context.Context, instanceDigest *digest.Digest) ([]types.BlobInfo, error) { func (i *containerImageSource) LayerInfosForCopy(_ context.Context, _ *digest.Digest) ([]types.BlobInfo, error) {
return nil, nil return nil, nil
} }
@ -982,7 +982,7 @@ func (i *containerImageSource) HasThreadSafeGetBlob() bool {
return false return false
} }
func (i *containerImageSource) GetBlob(ctx context.Context, blob types.BlobInfo, cache types.BlobInfoCache) (reader io.ReadCloser, size int64, err error) { func (i *containerImageSource) GetBlob(_ context.Context, blob types.BlobInfo, _ types.BlobInfoCache) (reader io.ReadCloser, size int64, err error) {
if blob.Digest == i.configDigest { if blob.Digest == i.configDigest {
logrus.Debugf("start reading config") logrus.Debugf("start reading config")
reader := bytes.NewReader(i.config) reader := bytes.NewReader(i.config)

View File

@ -17,26 +17,26 @@ import (
// from a Dockerfile. Try anything more than that and it'll return an error. // from a Dockerfile. Try anything more than that and it'll return an error.
type configOnlyExecutor struct{} type configOnlyExecutor struct{}
func (g *configOnlyExecutor) Preserve(path string) error { func (g *configOnlyExecutor) Preserve(_ string) error {
return errors.New("ADD/COPY/RUN not supported as changes") return errors.New("ADD/COPY/RUN not supported as changes")
} }
func (g *configOnlyExecutor) EnsureContainerPath(path string) error { func (g *configOnlyExecutor) EnsureContainerPath(_ string) error {
return nil return nil
} }
func (g *configOnlyExecutor) EnsureContainerPathAs(path, user string, mode *os.FileMode) error { func (g *configOnlyExecutor) EnsureContainerPathAs(_, _ string, _ *os.FileMode) error {
return nil return nil
} }
func (g *configOnlyExecutor) Copy(excludes []string, copies ...imagebuilder.Copy) error { func (g *configOnlyExecutor) Copy(_ []string, copies ...imagebuilder.Copy) error {
if len(copies) == 0 { if len(copies) == 0 {
return nil return nil
} }
return errors.New("ADD/COPY not supported as changes") return errors.New("ADD/COPY not supported as changes")
} }
func (g *configOnlyExecutor) Run(run imagebuilder.Run, config dockerclient.Config) error { func (g *configOnlyExecutor) Run(_ imagebuilder.Run, _ dockerclient.Config) error {
return errors.New("RUN not supported as changes") return errors.New("RUN not supported as changes")
} }

View File

@ -319,7 +319,7 @@ func Archive(rootfsPath string, ociConfig *v1.Image, options ArchiveOptions) (io
imageSize := slop(options.ImageSize, options.Slop) imageSize := slop(options.ImageSize, options.Slop)
if imageSize == 0 { if imageSize == 0 {
var sourceSize int64 var sourceSize int64
if err := filepath.WalkDir(rootfsPath, func(path string, d fs.DirEntry, err error) error { if err := filepath.WalkDir(rootfsPath, func(_ string, d fs.DirEntry, err error) error {
if err != nil && !errors.Is(err, os.ErrNotExist) && !errors.Is(err, os.ErrPermission) { if err != nil && !errors.Is(err, os.ErrNotExist) && !errors.Is(err, os.ErrPermission) {
return err return err
} }

View File

@ -209,7 +209,7 @@ func TestMergeSlicesWithoutDuplicatesFixed(t *testing.T) {
map[string]any{"first": 1}, map[string]any{"first": 1},
}, },
} }
err := mergeSlicesWithoutDuplicates(base, merge, "array", func(record any) (string, error) { err := mergeSlicesWithoutDuplicates(base, merge, "array", func(_ any) (string, error) {
return "fixed", nil return "fixed", nil
}) })
assert.NoError(t, err) assert.NoError(t, err)

View File

@ -224,7 +224,7 @@ func GetBindMount(ctx *types.SystemContext, args []string, contextDir string, st
// GetCacheMount parses a single cache mount entry from the --mount flag. // GetCacheMount parses a single cache mount entry from the --mount flag.
// //
// If this function succeeds and returns a non-nil *lockfile.LockFile, the caller must unlock it (when??). // If this function succeeds and returns a non-nil *lockfile.LockFile, the caller must unlock it (when??).
func GetCacheMount(args []string, store storage.Store, imageMountLabel string, additionalMountPoints map[string]internal.StageMountDetails, workDir string) (specs.Mount, *lockfile.LockFile, error) { func GetCacheMount(args []string, _ storage.Store, _ string, additionalMountPoints map[string]internal.StageMountDetails, workDir string) (specs.Mount, *lockfile.LockFile, error) {
var err error var err error
var mode uint64 var mode uint64
var buildahLockFilesDir string var buildahLockFilesDir string

View File

@ -516,7 +516,7 @@ func VerifyFlagsArgsOrder(args []string) error {
} }
// AliasFlags is a function to handle backwards compatibility with old flags // AliasFlags is a function to handle backwards compatibility with old flags
func AliasFlags(f *pflag.FlagSet, name string) pflag.NormalizedName { func AliasFlags(_ *pflag.FlagSet, name string) pflag.NormalizedName {
switch name { switch name {
case "net": case "net":
name = "network" name = "network"

View File

@ -10,7 +10,7 @@ import (
// AutocompleteNamespaceFlag - Autocomplete the userns flag. // AutocompleteNamespaceFlag - Autocomplete the userns flag.
// -> host, private, container, ns:[path], [path] // -> host, private, container, ns:[path], [path]
func AutocompleteNamespaceFlag(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { func AutocompleteNamespaceFlag(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) {
var completions []string var completions []string
// If we don't filter on "toComplete", zsh and fish will not do file completion // If we don't filter on "toComplete", zsh and fish will not do file completion
// even if the prefix typed by the user does not match the returned completions // even if the prefix typed by the user does not match the returned completions

View File

@ -4,5 +4,5 @@ import (
"testing" "testing"
) )
func TestDummy(t *testing.T) { func TestDummy(_ *testing.T) {
} }

View File

@ -48,7 +48,7 @@ var headerFunctions = template.FuncMap{
"upper": func(v string) string { "upper": func(v string) string {
return v return v
}, },
"truncate": func(v string, l int) string { "truncate": func(v string, _ int) string {
return v return v
}, },
} }

View File

@ -801,7 +801,7 @@ func SBOMScanOptions(c *cobra.Command) (*define.SBOMScanOptions, error) {
} }
// SBOMScanOptionsFromFlagSet parses scan settings from the cli // SBOMScanOptionsFromFlagSet parses scan settings from the cli
func SBOMScanOptionsFromFlagSet(flags *pflag.FlagSet, findFlagFunc func(name string) *pflag.Flag) (*define.SBOMScanOptions, error) { func SBOMScanOptionsFromFlagSet(flags *pflag.FlagSet, _ func(name string) *pflag.Flag) (*define.SBOMScanOptions, error) {
preset, err := flags.GetString("sbom") preset, err := flags.GetString("sbom")
if err != nil { if err != nil {
return nil, fmt.Errorf("invalid value for --sbom: %w", err) return nil, fmt.Errorf("invalid value for --sbom: %w", err)
@ -866,7 +866,7 @@ func SBOMScanOptionsFromFlagSet(flags *pflag.FlagSet, findFlagFunc func(name str
} }
// IDMappingOptions parses the build options related to user namespaces and ID mapping. // IDMappingOptions parses the build options related to user namespaces and ID mapping.
func IDMappingOptions(c *cobra.Command, isolation define.Isolation) (usernsOptions define.NamespaceOptions, idmapOptions *define.IDMappingOptions, err error) { func IDMappingOptions(c *cobra.Command, _ define.Isolation) (usernsOptions define.NamespaceOptions, idmapOptions *define.IDMappingOptions, err error) {
return IDMappingOptionsFromFlagSet(c.Flags(), c.PersistentFlags(), c.Flag) return IDMappingOptionsFromFlagSet(c.Flags(), c.PersistentFlags(), c.Flag)
} }

View File

@ -62,7 +62,7 @@ type PullOptions struct {
// Pull copies the contents of the image from somewhere else to local storage. Returns the // Pull copies the contents of the image from somewhere else to local storage. Returns the
// ID of the local image or an error. // ID of the local image or an error.
func Pull(ctx context.Context, imageName string, options PullOptions) (imageID string, err error) { func Pull(_ context.Context, imageName string, options PullOptions) (imageID string, err error) {
libimageOptions := &libimage.PullOptions{} libimageOptions := &libimage.PullOptions{}
libimageOptions.SignaturePolicyPath = options.SignaturePolicyPath libimageOptions.SignaturePolicyPath = options.SignaturePolicyPath
libimageOptions.Writer = options.ReportWriter libimageOptions.Writer = options.ReportWriter

View File

@ -786,7 +786,7 @@ func runMakeStdioPipe(uid, gid int) ([][]int, error) {
return stdioPipe, nil return stdioPipe, nil
} }
func setupNamespaces(logger *logrus.Logger, g *generate.Generator, namespaceOptions define.NamespaceOptions, idmapOptions define.IDMappingOptions, policy define.NetworkConfigurationPolicy) (configureNetwork bool, networkString string, configureUTS bool, err error) { func setupNamespaces(_ *logrus.Logger, g *generate.Generator, namespaceOptions define.NamespaceOptions, idmapOptions define.IDMappingOptions, policy define.NetworkConfigurationPolicy) (configureNetwork bool, networkString string, configureUTS bool, err error) {
defaultContainerConfig, err := config.Default() defaultContainerConfig, err := config.Default()
if err != nil { if err != nil {
return false, "", false, fmt.Errorf("failed to get container config: %w", err) return false, "", false, fmt.Errorf("failed to get container config: %w", err)

View File

@ -18,14 +18,14 @@ func TestAddRlimits(t *testing.T) {
{ {
name: "empty ulimit", name: "empty ulimit",
ulimit: []string{}, ulimit: []string{},
test: func(e error, g *generate.Generator) error { test: func(e error, _ *generate.Generator) error {
return e return e
}, },
}, },
{ {
name: "invalid ulimit argument", name: "invalid ulimit argument",
ulimit: []string{"bla"}, ulimit: []string{"bla"},
test: func(e error, g *generate.Generator) error { test: func(e error, _ *generate.Generator) error {
if e == nil { if e == nil {
return errors.New("expected to receive an error but got nil") return errors.New("expected to receive an error but got nil")
} }
@ -39,7 +39,7 @@ func TestAddRlimits(t *testing.T) {
{ {
name: "invalid ulimit type", name: "invalid ulimit type",
ulimit: []string{"bla=hard"}, ulimit: []string{"bla=hard"},
test: func(e error, g *generate.Generator) error { test: func(e error, _ *generate.Generator) error {
if e == nil { if e == nil {
return errors.New("expected to receive an error but got nil") return errors.New("expected to receive an error but got nil")
} }

View File

@ -1702,7 +1702,7 @@ var internalTestCases = []testCase{
"ADD archive.tar subdir1/", "ADD archive.tar subdir1/",
"ADD archive/ subdir2/", "ADD archive/ subdir2/",
}, "\n"), }, "\n"),
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
content := []byte("test content") content := []byte("test content")
if err := os.Mkdir(filepath.Join(contextDir, "archive"), 0755); err != nil { if err := os.Mkdir(filepath.Join(contextDir, "archive"), 0755); err != nil {
@ -1788,7 +1788,7 @@ var internalTestCases = []testCase{
"COPY subdir/ subdir/", "COPY subdir/ subdir/",
"COPY --chown=99:99 subdir/ subdir/", "COPY --chown=99:99 subdir/ subdir/",
}, "\n"), }, "\n"),
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
content := []byte("test content") content := []byte("test content")
if err := os.Mkdir(filepath.Join(contextDir, "subdir"), 0755); err != nil { if err := os.Mkdir(filepath.Join(contextDir, "subdir"), 0755); err != nil {
@ -1827,7 +1827,7 @@ var internalTestCases = []testCase{
"COPY --chown=99:99 subdir/ subdir/", "COPY --chown=99:99 subdir/ subdir/",
"COPY subdir/ subdir/", "COPY subdir/ subdir/",
}, "\n"), }, "\n"),
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
content := []byte("test content") content := []byte("test content")
if err := os.Mkdir(filepath.Join(contextDir, "subdir"), 0755); err != nil { if err := os.Mkdir(filepath.Join(contextDir, "subdir"), 0755); err != nil {
@ -1889,7 +1889,7 @@ var internalTestCases = []testCase{
"COPY . subdir1", "COPY . subdir1",
"ADD . subdir2", "ADD . subdir2",
}, "\n"), }, "\n"),
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
filename := filepath.Join(contextDir, "should-be-setuid-file") filename := filepath.Join(contextDir, "should-be-setuid-file")
if err = os.WriteFile(filename, []byte("test content"), 0644); err != nil { if err = os.WriteFile(filename, []byte("test content"), 0644); err != nil {
return fmt.Errorf("creating setuid test file in temporary context directory: %w", err) return fmt.Errorf("creating setuid test file in temporary context directory: %w", err)
@ -1976,7 +1976,7 @@ var internalTestCases = []testCase{
fmt.Sprintf("# Do the setuid/setgid/sticky files in this archive end up setuid(0%o)/setgid(0%o)/sticky(0%o)?", syscall.S_ISUID, syscall.S_ISGID, syscall.S_ISVTX), fmt.Sprintf("# Do the setuid/setgid/sticky files in this archive end up setuid(0%o)/setgid(0%o)/sticky(0%o)?", syscall.S_ISUID, syscall.S_ISGID, syscall.S_ISVTX),
"ADD archive.tar .", "ADD archive.tar .",
}, "\n"), }, "\n"),
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
filename := filepath.Join(contextDir, "archive.tar") filename := filepath.Join(contextDir, "archive.tar")
f, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY, 0644) f, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY, 0644)
if err != nil { if err != nil {
@ -2312,7 +2312,7 @@ var internalTestCases = []testCase{
{ {
name: "dockerignore-irrelevant", name: "dockerignore-irrelevant",
contextDir: "dockerignore/empty", contextDir: "dockerignore/empty",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte(strings.Join([]string{"**/*-a", "!**/*-c"}, "\n")) dockerignore := []byte(strings.Join([]string{"**/*-a", "!**/*-c"}, "\n"))
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0600); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0600); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2332,7 +2332,7 @@ var internalTestCases = []testCase{
"COPY . subdir/", "COPY . subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte(strings.Join([]string{"**/*-a", "!**/*-c"}, "\n")) dockerignore := []byte(strings.Join([]string{"**/*-a", "!**/*-c"}, "\n"))
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0644); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0644); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2352,7 +2352,7 @@ var internalTestCases = []testCase{
"COPY * subdir/", "COPY * subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte(strings.Join([]string{"**/*-a", "!**/*-c"}, "\n")) dockerignore := []byte(strings.Join([]string{"**/*-a", "!**/*-c"}, "\n"))
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0600); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0600); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2372,7 +2372,7 @@ var internalTestCases = []testCase{
"COPY . subdir/", "COPY . subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte(strings.Join([]string{"!**/*-c"}, "\n")) dockerignore := []byte(strings.Join([]string{"!**/*-c"}, "\n"))
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0640); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0640); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2392,7 +2392,7 @@ var internalTestCases = []testCase{
"COPY * subdir/", "COPY * subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte("!**/*-c\n") dockerignore := []byte("!**/*-c\n")
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0100); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0100); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2412,7 +2412,7 @@ var internalTestCases = []testCase{
"COPY . subdir/", "COPY . subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte("subdir-c") dockerignore := []byte("subdir-c")
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0200); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0200); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2432,7 +2432,7 @@ var internalTestCases = []testCase{
"COPY * subdir/", "COPY * subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte("subdir-c") dockerignore := []byte("subdir-c")
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0400); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0400); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2452,7 +2452,7 @@ var internalTestCases = []testCase{
"COPY . subdir/", "COPY . subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte("**/subdir-c") dockerignore := []byte("**/subdir-c")
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0200); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0200); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2472,7 +2472,7 @@ var internalTestCases = []testCase{
"COPY * subdir/", "COPY * subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte("**/subdir-c") dockerignore := []byte("**/subdir-c")
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0400); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0400); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2492,7 +2492,7 @@ var internalTestCases = []testCase{
"COPY . subdir/", "COPY . subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte("subdir-*") dockerignore := []byte("subdir-*")
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0000); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0000); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2512,7 +2512,7 @@ var internalTestCases = []testCase{
"COPY * subdir/", "COPY * subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte("subdir-*") dockerignore := []byte("subdir-*")
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0660); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0660); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2532,7 +2532,7 @@ var internalTestCases = []testCase{
"COPY . subdir/", "COPY . subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte("**/subdir-*") dockerignore := []byte("**/subdir-*")
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0000); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0000); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2552,7 +2552,7 @@ var internalTestCases = []testCase{
"COPY * subdir/", "COPY * subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte("**/subdir-*") dockerignore := []byte("**/subdir-*")
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0660); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0660); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2572,7 +2572,7 @@ var internalTestCases = []testCase{
"COPY . subdir/", "COPY . subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte("**/subdir-f") dockerignore := []byte("**/subdir-f")
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0666); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0666); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2592,7 +2592,7 @@ var internalTestCases = []testCase{
"COPY * subdir/", "COPY * subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte("**/subdir-f") dockerignore := []byte("**/subdir-f")
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0640); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0640); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2612,7 +2612,7 @@ var internalTestCases = []testCase{
"COPY . subdir/", "COPY . subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte("**/subdir-b") dockerignore := []byte("**/subdir-b")
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0705); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0705); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2632,7 +2632,7 @@ var internalTestCases = []testCase{
"COPY * subdir/", "COPY * subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte("**/subdir-b") dockerignore := []byte("**/subdir-b")
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0750); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0750); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2652,7 +2652,7 @@ var internalTestCases = []testCase{
"COPY . subdir/", "COPY . subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte(strings.Join([]string{"**/subdir-e", "!**/subdir-f"}, "\n")) dockerignore := []byte(strings.Join([]string{"**/subdir-e", "!**/subdir-f"}, "\n"))
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0750); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0750); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2672,7 +2672,7 @@ var internalTestCases = []testCase{
"COPY * subdir/", "COPY * subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte(strings.Join([]string{"**/subdir-e", "!**/subdir-f"}, "\n")) dockerignore := []byte(strings.Join([]string{"**/subdir-e", "!**/subdir-f"}, "\n"))
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0750); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0750); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2692,7 +2692,7 @@ var internalTestCases = []testCase{
"COPY . subdir/", "COPY . subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte(strings.Join([]string{"**/subdir-f", "!**/subdir-g"}, "\n")) dockerignore := []byte(strings.Join([]string{"**/subdir-f", "!**/subdir-g"}, "\n"))
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0750); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0750); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)
@ -2712,7 +2712,7 @@ var internalTestCases = []testCase{
"COPY * subdir/", "COPY * subdir/",
}, "\n"), }, "\n"),
contextDir: "dockerignore/populated", contextDir: "dockerignore/populated",
tweakContextDir: func(t *testing.T, contextDir, storageDriver, storageRoot string) (err error) { tweakContextDir: func(_ *testing.T, contextDir, _, _ string) (err error) {
dockerignore := []byte(strings.Join([]string{"**/subdir-f", "!**/subdir-g"}, "\n")) dockerignore := []byte(strings.Join([]string{"**/subdir-f", "!**/subdir-g"}, "\n"))
if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0750); err != nil { if err := os.WriteFile(filepath.Join(contextDir, ".dockerignore"), dockerignore, 0750); err != nil {
return fmt.Errorf("writing .dockerignore file: %w", err) return fmt.Errorf("writing .dockerignore file: %w", err)

View File

@ -173,7 +173,7 @@ func getProcessNoNewPrivileges(r *types.TestReport) error {
return nil return nil
} }
func getProcessAppArmorProfile(r *types.TestReport) error { func getProcessAppArmorProfile(_ *types.TestReport) error {
// TODO // TODO
return nil return nil
} }
@ -198,7 +198,7 @@ func getProcessOOMScoreAdjust(r *types.TestReport) error {
return nil return nil
} }
func getProcessSeLinuxLabel(r *types.TestReport) error { func getProcessSeLinuxLabel(_ *types.TestReport) error {
// TODO // TODO
return nil return nil
} }
@ -336,47 +336,47 @@ func getLinuxSysctl(r *types.TestReport) error {
return filepath.Walk("/proc/sys", walk) return filepath.Walk("/proc/sys", walk)
} }
func getLinuxResources(r *types.TestReport) error { func getLinuxResources(_ *types.TestReport) error {
// TODO // TODO
return nil return nil
} }
func getLinuxCgroupsPath(r *types.TestReport) error { func getLinuxCgroupsPath(_ *types.TestReport) error {
// TODO // TODO
return nil return nil
} }
func getLinuxNamespaces(r *types.TestReport) error { func getLinuxNamespaces(_ *types.TestReport) error {
// TODO // TODO
return nil return nil
} }
func getLinuxDevices(r *types.TestReport) error { func getLinuxDevices(_ *types.TestReport) error {
// TODO // TODO
return nil return nil
} }
func getLinuxRootfsPropagation(r *types.TestReport) error { func getLinuxRootfsPropagation(_ *types.TestReport) error {
// TODO // TODO
return nil return nil
} }
func getLinuxMaskedPaths(r *types.TestReport) error { func getLinuxMaskedPaths(_ *types.TestReport) error {
// TODO // TODO
return nil return nil
} }
func getLinuxReadOnlyPaths(r *types.TestReport) error { func getLinuxReadOnlyPaths(_ *types.TestReport) error {
// TODO // TODO
return nil return nil
} }
func getLinuxMountLabel(r *types.TestReport) error { func getLinuxMountLabel(_ *types.TestReport) error {
// TODO // TODO
return nil return nil
} }
func getLinuxIntelRdt(r *types.TestReport) error { func getLinuxIntelRdt(_ *types.TestReport) error {
// TODO // TODO
return nil return nil
} }

View File

@ -138,10 +138,10 @@ func ExpandNames(names []string, systemContext *types.SystemContext, store stora
return expanded, nil return expanded, nil
} }
// FindImage locates the locally-stored image which corresponds to a given name. // FindImage locates the locally-stored image which corresponds to a given
// Please note that the `firstRegistry` argument has been deprecated and has no // name. Please note that the second argument has been deprecated and has no
// effect anymore. // effect anymore.
func FindImage(store storage.Store, firstRegistry string, systemContext *types.SystemContext, image string) (types.ImageReference, *storage.Image, error) { func FindImage(store storage.Store, _ string, systemContext *types.SystemContext, image string) (types.ImageReference, *storage.Image, error) {
runtime, err := libimage.RuntimeFromStore(store, &libimage.RuntimeOptions{SystemContext: systemContext}) runtime, err := libimage.RuntimeFromStore(store, &libimage.RuntimeOptions{SystemContext: systemContext})
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
@ -190,9 +190,8 @@ func ResolveNameToReferences(
} }
// AddImageNames adds the specified names to the specified image. Please note // AddImageNames adds the specified names to the specified image. Please note
// that the `firstRegistry` argument has been deprecated and has no effect // that the second argument has been deprecated and has no effect anymore.
// anymore. func AddImageNames(store storage.Store, _ string, systemContext *types.SystemContext, image *storage.Image, addNames []string) error {
func AddImageNames(store storage.Store, firstRegistry string, systemContext *types.SystemContext, image *storage.Image, addNames []string) error {
runtime, err := libimage.RuntimeFromStore(store, &libimage.RuntimeOptions{SystemContext: systemContext}) runtime, err := libimage.RuntimeFromStore(store, &libimage.RuntimeOptions{SystemContext: systemContext})
if err != nil { if err != nil {
return err return err