chore: fmt

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker
2026-06-06 10:03:56 -03:00
parent 5c2f7caebf
commit 3f96cfd981
9 changed files with 84 additions and 74 deletions
+2 -1
View File
@@ -91,7 +91,8 @@ func TestUpgrade(t *testing.T) {
target := fmt.Sprintf("./testdata/acceptance/%s", oldpkg)
require.NoError(t, os.MkdirAll("./testdata/acceptance/tmp", 0o700))
config, err := nfpm.ParseFileWithEnvMapping(fmt.Sprintf("./testdata/acceptance/%s.v1.yaml", testName),
config, err := nfpm.ParseFileWithEnvMapping(
fmt.Sprintf("./testdata/acceptance/%s.v1.yaml", testName),
func(s string) string {
switch s {
case "BUILD_ARCH":
+14 -14
View File
@@ -61,20 +61,20 @@ func init() {
// https://github.com/golang/go/blob/master/src/internal/syslist/syslist.go
// nolint: gochecknoglobals
var archToAlpine = map[string]string{
"all": "noarch",
"386": "x86",
"amd64": "x86_64",
"arm64": "aarch64",
"arm6": "armhf",
"arm7": "armv7",
"ppc64le": "ppc64le",
"s390": "s390x",
"loong64": "loongarch64",
"aarch64": "aarch64",
"x86_64": "x86_64",
"i386": "x86",
"i686": "x86",
"riscv64": "riscv64",
"all": "noarch",
"386": "x86",
"amd64": "x86_64",
"arm64": "aarch64",
"arm6": "armhf",
"arm7": "armv7",
"ppc64le": "ppc64le",
"s390": "s390x",
"loong64": "loongarch64",
"aarch64": "aarch64",
"x86_64": "x86_64",
"i386": "x86",
"i686": "x86",
"riscv64": "riscv64",
}
func ensureValidArch(info *nfpm.Info) *nfpm.Info {
+11 -11
View File
@@ -42,17 +42,17 @@ type ArchLinux struct{}
// nolint: gochecknoglobals
var archToArchLinux = map[string]string{
"all": "any",
"amd64": "x86_64",
"386": "i686",
"arm64": "aarch64",
"arm7": "armv7h",
"arm6": "armv6h",
"arm5": "arm",
"x86_64": "x86_64",
"aarch64": "aarch64",
"i386": "i686",
"riscv64": "riscv64",
"all": "any",
"amd64": "x86_64",
"386": "i686",
"arm64": "aarch64",
"arm7": "armv7h",
"arm6": "armv6h",
"arm5": "arm",
"x86_64": "x86_64",
"aarch64": "aarch64",
"i386": "i686",
"riscv64": "riscv64",
}
func ensureValidArch(info *nfpm.Info) *nfpm.Info {
+2 -1
View File
@@ -134,7 +134,8 @@ func TestArchConventionalFileName(t *testing.T) {
info := exampleInfo()
info.Arch = arch
name := Default.ConventionalFileName(info)
require.Equal(t,
require.Equal(
t,
"foo-test-1.0.0beta_1-1-"+archToArchLinux[arch]+".pkg.tar.zst",
name,
)
+14 -13
View File
@@ -43,18 +43,18 @@ func init() {
// https://wiki.debian.org/ArchitectureSpecificsMemo
// nolint: gochecknoglobals
var archToDebian = map[string]string{
"386": "i386",
"arm64": "arm64",
"arm5": "armel",
"arm6": "armhf",
"arm7": "armhf",
"mips64le": "mips64el",
"mipsle": "mipsel",
"ppc64le": "ppc64el",
"s390": "s390x",
"x86_64": "amd64",
"aarch64": "arm64",
"riscv64": "riscv64",
"386": "i386",
"arm64": "arm64",
"arm5": "armel",
"arm6": "armhf",
"arm7": "armhf",
"mips64le": "mips64el",
"mipsle": "mipsel",
"ppc64le": "ppc64el",
"s390": "s390x",
"x86_64": "amd64",
"aarch64": "arm64",
"riscv64": "riscv64",
}
func ensureValidArch(info *nfpm.Info) *nfpm.Info {
@@ -877,7 +877,8 @@ func tarHeader(content *files.Content, preferredModTimes ...time.Time) (*tar.Hea
h := &tar.Header{
Name: content.Name(),
ModTime: modtime.Get(
append(preferredModTimes, content.ModTime())...),
append(preferredModTimes, content.ModTime())...,
),
Mode: int64(fm & 0o7777),
Uname: content.FileInfo.Owner,
Gname: content.FileInfo.Group,
+3 -2
View File
@@ -553,8 +553,9 @@ func contentCollisionError(newc *Content, present *Content) error {
presentSource = " with source " + present.Source
}
return fmt.Errorf("adding %s at destination %s: "+
"%s%s is already present at this destination: %w",
return fmt.Errorf(
"adding %s at destination %s: "+
"%s%s is already present at this destination: %w",
newc.Type, newc.Destination, present.Type, presentSource, ErrContentCollision,
)
}
+2 -1
View File
@@ -43,7 +43,8 @@ func newPackageCmd() *packageCmd {
cmd.Flags().StringVarP(&root.packager, "packager", "p", "",
fmt.Sprintf("which packager implementation to use [%s]", strings.Join(pkgs, "|")))
_ = cmd.RegisterFlagCompletionFunc("packager", cobra.FixedCompletions(pkgs,
_ = cmd.RegisterFlagCompletionFunc("packager", cobra.FixedCompletions(
pkgs,
cobra.ShellCompDirectiveNoFileComp,
))
+24 -19
View File
@@ -32,20 +32,20 @@ func init() {
// nolint: gochecknoglobals
var archToIPK = map[string]string{
// all --> all
"386": "i386",
"amd64": "x86_64",
"arm64": "arm64",
"arm5": "armel",
"arm6": "armhf",
"arm7": "armhf",
"mips64le": "mips64el",
"mipsle": "mipsel",
"ppc64le": "ppc64el",
"s390": "s390x",
"x86_64": "x86_64",
"aarch64": "arm64",
"i386": "i386",
"riscv64": "riscv64_generic",
"386": "i386",
"amd64": "x86_64",
"arm64": "arm64",
"arm5": "armel",
"arm6": "armhf",
"arm7": "armhf",
"mips64le": "mips64el",
"mipsle": "mipsel",
"ppc64le": "ppc64el",
"s390": "s390x",
"x86_64": "x86_64",
"aarch64": "arm64",
"i386": "i386",
"riscv64": "riscv64_generic",
}
func ensureValidArch(info *nfpm.Info) *nfpm.Info {
@@ -127,7 +127,8 @@ func (d *IPK) Package(info *nfpm.Info, ipk io.Writer) error {
// Strip out any custom fields that are disallowed.
stripDisallowedFields(info)
contents, err := newTGZ("ipk",
contents, err := newTGZ(
"ipk",
func(tw *tar.Writer) error {
return createIPK(info, tw)
},
@@ -145,7 +146,8 @@ func (d *IPK) Package(info *nfpm.Info, ipk io.Writer) error {
func createIPK(info *nfpm.Info, ipk *tar.Writer) error {
var installSize int64
data, err := newTGZ("data.tar.gz",
data, err := newTGZ(
"data.tar.gz",
func(tw *tar.Writer) error {
var err error
installSize, err = populateDataTar(info, tw)
@@ -156,7 +158,8 @@ func createIPK(info *nfpm.Info, ipk *tar.Writer) error {
return err
}
control, err := newTGZ("control.tar.gz",
control, err := newTGZ(
"control.tar.gz",
func(tw *tar.Writer) error {
return populateControlTar(info, tw, installSize)
},
@@ -199,7 +202,8 @@ func populateDataTar(info *nfpm.Info, tw *tar.Writer) (instSize int64, err error
Mode: int64(file.FileInfo.Mode),
Uname: file.FileInfo.Owner,
Gname: file.FileInfo.Group,
})
},
)
case files.TypeSymlink:
err = tw.WriteHeader(
&tar.Header{
@@ -208,7 +212,8 @@ func populateDataTar(info *nfpm.Info, tw *tar.Writer) (instSize int64, err error
Format: tar.FormatGNU,
ModTime: modtime.Get(info.MTime),
Linkname: file.Source,
})
},
)
case files.TypeFile, files.TypeTree, files.TypeConfig, files.TypeConfigNoReplace, files.TypeConfigMissingOK:
size, err = writeFile(tw, file)
default:
+12 -12
View File
@@ -77,18 +77,18 @@ type RPM struct {
// https://github.com/rpm-software-management/rpm/blob/4a9b7b5908d8b463a836b51322242677677bd8b7/lib/rpmrc.cc#L1167
// nolint: gochecknoglobals
var archToRPM = map[string]string{
"all": "noarch",
"amd64": "x86_64",
"386": "i386",
"arm64": "aarch64",
"arm5": "armv5tel",
"arm6": "armv6hl",
"arm7": "armv7hl",
"mips64le": "mips64el",
"mipsle": "mipsel",
"mips": "mips",
"loong64": "loongarch64",
"riscv64": "riscv64",
"all": "noarch",
"amd64": "x86_64",
"386": "i386",
"arm64": "aarch64",
"arm5": "armv5tel",
"arm6": "armv6hl",
"arm7": "armv7hl",
"mips64le": "mips64el",
"mipsle": "mipsel",
"mips": "mips",
"loong64": "loongarch64",
"riscv64": "riscv64",
}
func setDefaults(info *nfpm.Info) *nfpm.Info {