mirror of
https://github.com/outbackdingo/debos.git
synced 2026-01-27 10:18:47 +00:00
fix: Incorrectly formatted error string (ST1005)
Reported by staticcheck Signed-off-by: Loïc Minier <loic.minier@oss.qualcomm.com>
This commit is contained in:
@@ -63,7 +63,7 @@ func (d *DownloadAction) validateUrl() (*url.URL, error) {
|
||||
case "http", "https":
|
||||
// Supported scheme
|
||||
default:
|
||||
return url, fmt.Errorf("Unsupported URL is provided: '%s'", url.String())
|
||||
return url, fmt.Errorf("unsupported URL provided: '%s'", url.String())
|
||||
}
|
||||
|
||||
return url, nil
|
||||
@@ -77,7 +77,7 @@ func (d *DownloadAction) validateFilename(context *debos.DebosContext, url *url.
|
||||
filename = path.Base(d.Filename)
|
||||
}
|
||||
if len(filename) == 0 || filename == "." || filename == "/" {
|
||||
return "", fmt.Errorf("Incorrect filename is provided for '%s'", d.Url)
|
||||
return "", fmt.Errorf("incorrect filename provided for '%s'", d.Url)
|
||||
}
|
||||
filename = path.Join(context.Scratchdir, filename)
|
||||
return filename, nil
|
||||
@@ -104,7 +104,7 @@ func (d *DownloadAction) Verify(context *debos.DebosContext) error {
|
||||
var filename string
|
||||
|
||||
if len(d.Name) == 0 {
|
||||
return fmt.Errorf("Property 'name' is mandatory for download action\n")
|
||||
return fmt.Errorf("property 'name' is mandatory for download action")
|
||||
}
|
||||
|
||||
url, err := d.validateUrl()
|
||||
@@ -144,7 +144,7 @@ func (d *DownloadAction) Run(context *debos.DebosContext) error {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("Unsupported URL is provided: '%s'", url.String())
|
||||
return fmt.Errorf("unsupported URL provided: '%s'", url.String())
|
||||
}
|
||||
|
||||
if d.Unpack == true {
|
||||
|
||||
@@ -56,14 +56,14 @@ func NewFilesystemDeployAction() *FilesystemDeployAction {
|
||||
|
||||
func (fd *FilesystemDeployAction) setupFSTab(context *debos.DebosContext) error {
|
||||
if context.ImageFSTab.Len() == 0 {
|
||||
return errors.New("Fstab not generated, missing image-partition action?")
|
||||
return errors.New("fstab not generated, missing image-partition action?")
|
||||
}
|
||||
|
||||
log.Print("Setting up /etc/fstab")
|
||||
|
||||
err := os.MkdirAll(path.Join(context.Rootdir, "etc"), 0755)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Couldn't create etc in image: %v", err)
|
||||
return fmt.Errorf("couldn't create etc in image: %v", err)
|
||||
}
|
||||
|
||||
fstab := path.Join(context.Rootdir, "etc/fstab")
|
||||
@@ -71,13 +71,13 @@ func (fd *FilesystemDeployAction) setupFSTab(context *debos.DebosContext) error
|
||||
defer f.Close()
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Couldn't open /etc/fstab: %v", err)
|
||||
return fmt.Errorf("couldn't open /etc/fstab: %v", err)
|
||||
}
|
||||
|
||||
_, err = io.Copy(f, &context.ImageFSTab)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Couldn't write /etc/fstab: %v", err)
|
||||
return fmt.Errorf("couldn't write /etc/fstab: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -90,7 +90,7 @@ func (fd *FilesystemDeployAction) setupKernelCmdline(context *debos.DebosContext
|
||||
|
||||
err := os.MkdirAll(path.Join(context.Rootdir, "etc", "kernel"), 0755)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Couldn't create etc/kernel in image: %v", err)
|
||||
return fmt.Errorf("couldn't create etc/kernel in image: %v", err)
|
||||
}
|
||||
path := path.Join(context.Rootdir, "etc/kernel/cmdline")
|
||||
current, _ := ioutil.ReadFile(path)
|
||||
@@ -98,7 +98,7 @@ func (fd *FilesystemDeployAction) setupKernelCmdline(context *debos.DebosContext
|
||||
defer f.Close()
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Couldn't open /etc/kernel/cmdline: %v", err)
|
||||
return fmt.Errorf("couldn't open /etc/kernel/cmdline: %v", err)
|
||||
}
|
||||
|
||||
cmdline = append(cmdline, strings.TrimSpace(string(current)))
|
||||
@@ -110,7 +110,7 @@ func (fd *FilesystemDeployAction) setupKernelCmdline(context *debos.DebosContext
|
||||
|
||||
_, err = f.WriteString(strings.Join(cmdline, " ") + "\n")
|
||||
if err != nil {
|
||||
return fmt.Errorf("Couldn't write /etc/kernel/cmdline: %v", err)
|
||||
return fmt.Errorf("couldn't write /etc/kernel/cmdline: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -279,7 +279,7 @@ func (i *ImagePartitionAction) generateFSTab(context *debos.DebosContext) error
|
||||
continue
|
||||
}
|
||||
if m.part.FSUUID == "" {
|
||||
return fmt.Errorf("Missing fs UUID for partition %s!?!", m.part.Name)
|
||||
return fmt.Errorf("missing fs UUID for partition %s", m.part.Name)
|
||||
}
|
||||
|
||||
fs_passno := 0
|
||||
@@ -312,7 +312,7 @@ func (i *ImagePartitionAction) generateKernelRoot(context *debos.DebosContext) e
|
||||
for _, m := range i.Mountpoints {
|
||||
if m.Mountpoint == "/" {
|
||||
if m.part.FSUUID == "" {
|
||||
return errors.New("No fs UUID for root partition !?!")
|
||||
return errors.New("no fs UUID for root partition")
|
||||
}
|
||||
context.ImageKernelRoot = fmt.Sprintf("root=UUID=%s", m.part.FSUUID)
|
||||
break
|
||||
@@ -458,7 +458,7 @@ func (i ImagePartitionAction) formatPartition(p *Partition, context debos.DebosC
|
||||
if p.FS != "none" && p.FSUUID == "" {
|
||||
uuid, err := exec.Command("blkid", "-o", "value", "-s", "UUID", "-p", "-c", "none", path).Output()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to get uuid: %s", err)
|
||||
return fmt.Errorf("failed to get uuid: %s", err)
|
||||
}
|
||||
p.FSUUID = strings.TrimSpace(string(uuid[:]))
|
||||
}
|
||||
@@ -470,12 +470,12 @@ func (i *ImagePartitionAction) PreNoMachine(context *debos.DebosContext) error {
|
||||
imagePath := path.Join(context.Artifactdir, i.ImageName)
|
||||
img, err := os.OpenFile(imagePath, os.O_WRONLY|os.O_CREATE, 0666)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Couldn't open image file: %v", err)
|
||||
return fmt.Errorf("couldn't open image file: %v", err)
|
||||
}
|
||||
|
||||
err = img.Truncate(i.size)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Couldn't resize image file: %v", err)
|
||||
return fmt.Errorf("couldn't resize image file: %v", err)
|
||||
}
|
||||
|
||||
img.Close()
|
||||
@@ -492,7 +492,7 @@ func (i *ImagePartitionAction) PreNoMachine(context *debos.DebosContext) error {
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to setup loop device: %v", err)
|
||||
return fmt.Errorf("failed to setup loop device: %v", err)
|
||||
}
|
||||
|
||||
// go-losetup doesn't provide a way to change the loop device sector size
|
||||
@@ -804,7 +804,7 @@ func (i *ImagePartitionAction) Verify(context *debos.DebosContext) error {
|
||||
// Just check if it contains correct value
|
||||
_, err := units.FromHumanSize(i.GptGap)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to parse GPT offset: %s", i.GptGap)
|
||||
return fmt.Errorf("failed to parse image size: %s", i.GptGap)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -813,12 +813,12 @@ func (i *ImagePartitionAction) Verify(context *debos.DebosContext) error {
|
||||
case "gpt":
|
||||
_, err := uuid.Parse(i.DiskID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Incorrect disk GUID %s", i.DiskID)
|
||||
return fmt.Errorf("incorrect disk GUID %s", i.DiskID)
|
||||
}
|
||||
case "msdos":
|
||||
_, err := hex.DecodeString(i.DiskID)
|
||||
if err != nil || len(i.DiskID) != 8 {
|
||||
return fmt.Errorf("Incorrect disk ID %s, should be 32-bit hexadecimal number", i.DiskID)
|
||||
return fmt.Errorf("incorrect disk ID %s, should be 32-bit hexadecimal number", i.DiskID)
|
||||
}
|
||||
// Add 0x prefix
|
||||
i.DiskID = "0x" + i.DiskID
|
||||
@@ -832,13 +832,13 @@ func (i *ImagePartitionAction) Verify(context *debos.DebosContext) error {
|
||||
p.number = num
|
||||
num++
|
||||
if p.Name == "" {
|
||||
return fmt.Errorf("Partition without a name")
|
||||
return fmt.Errorf("partition without a name")
|
||||
}
|
||||
|
||||
// check for duplicate partition names
|
||||
for j := idx + 1; j < len(i.Partitions); j++ {
|
||||
if i.Partitions[j].Name == p.Name {
|
||||
return fmt.Errorf("Partition %s already exists", p.Name)
|
||||
return fmt.Errorf("partition %s already exists", p.Name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -847,20 +847,20 @@ func (i *ImagePartitionAction) Verify(context *debos.DebosContext) error {
|
||||
case "btrfs", "ext2", "ext3", "ext4", "xfs":
|
||||
_, err := uuid.Parse(p.FSUUID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Incorrect UUID %s", p.FSUUID)
|
||||
return fmt.Errorf("incorrect UUID %s", p.FSUUID)
|
||||
}
|
||||
case "fat", "fat12", "fat16", "fat32", "msdos", "vfat":
|
||||
_, err := hex.DecodeString(p.FSUUID)
|
||||
if err != nil || len(p.FSUUID) != 8 {
|
||||
return fmt.Errorf("Incorrect UUID %s, should be 32-bit hexadecimal number", p.FSUUID)
|
||||
return fmt.Errorf("incorrect UUID %s, should be 32-bit hexadecimal number", p.FSUUID)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("Setting the UUID is not supported for filesystem %s", p.FS)
|
||||
return fmt.Errorf("setting the UUID is not supported for filesystem %s", p.FS)
|
||||
}
|
||||
}
|
||||
|
||||
if i.PartitionType != "gpt" && p.PartLabel != "" {
|
||||
return fmt.Errorf("Can only set partition partlabel on GPT filesystem")
|
||||
return fmt.Errorf("can only set partition partlabel on GPT filesystem")
|
||||
}
|
||||
|
||||
if len(p.PartUUID) > 0 {
|
||||
@@ -868,10 +868,10 @@ func (i *ImagePartitionAction) Verify(context *debos.DebosContext) error {
|
||||
case "gpt":
|
||||
_, err := uuid.Parse(p.PartUUID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Incorrect partition UUID %s", p.PartUUID)
|
||||
return fmt.Errorf("incorrect partition UUID %s", p.PartUUID)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("Setting the partition UUID is not supported for %s", i.PartitionType)
|
||||
return fmt.Errorf("setting the partition UUID is not supported for %s", i.PartitionType)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -891,19 +891,19 @@ func (i *ImagePartitionAction) Verify(context *debos.DebosContext) error {
|
||||
for _, bitStr := range p.PartAttrs {
|
||||
bit, err := strconv.ParseInt(bitStr, 0, 0)
|
||||
if err != nil || bit < 0 || bit > 2 && bit < 48 || bit > 63 {
|
||||
return fmt.Errorf("Partition attribute bit '%s' outside of valid range (0-2, 48-63)", bitStr)
|
||||
return fmt.Errorf("partition attribute bit '%s' outside of valid range (0-2, 48-63)", bitStr)
|
||||
}
|
||||
}
|
||||
|
||||
if p.Start == "" {
|
||||
return fmt.Errorf("Partition %s missing start", p.Name)
|
||||
return fmt.Errorf("partition %s missing start", p.Name)
|
||||
}
|
||||
if p.End == "" {
|
||||
return fmt.Errorf("Partition %s missing end", p.Name)
|
||||
return fmt.Errorf("partition %s missing end", p.Name)
|
||||
}
|
||||
|
||||
if p.FS == "" {
|
||||
return fmt.Errorf("Partition %s missing fs type", p.Name)
|
||||
return fmt.Errorf("partition %s missing fs type", p.Name)
|
||||
}
|
||||
|
||||
if p.FSLabel == "" {
|
||||
@@ -939,7 +939,7 @@ func (i *ImagePartitionAction) Verify(context *debos.DebosContext) error {
|
||||
// check for duplicate mountpoints
|
||||
for j := idx + 1; j < len(i.Mountpoints); j++ {
|
||||
if i.Mountpoints[j].Mountpoint == m.Mountpoint {
|
||||
return fmt.Errorf("Mountpoint %s already exists", m.Mountpoint)
|
||||
return fmt.Errorf("mountpoint %s already exists", m.Mountpoint)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -951,11 +951,11 @@ func (i *ImagePartitionAction) Verify(context *debos.DebosContext) error {
|
||||
}
|
||||
}
|
||||
if m.part == nil {
|
||||
return fmt.Errorf("Couldn't find partition for %s", m.Mountpoint)
|
||||
return fmt.Errorf("couldn't find partition for %s", m.Mountpoint)
|
||||
}
|
||||
|
||||
if strings.ToLower(m.part.FS) == "none" {
|
||||
return fmt.Errorf("Cannot mount %s: filesystem not present", m.Mountpoint)
|
||||
return fmt.Errorf("cannot mount %s: filesystem not present", m.Mountpoint)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -971,7 +971,7 @@ func (i *ImagePartitionAction) Verify(context *debos.DebosContext) error {
|
||||
|
||||
size, err := getSizeValueFunc(i.ImageSize)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to parse image size: %s", i.ImageSize)
|
||||
return fmt.Errorf("failed to parse image size: %s", i.ImageSize)
|
||||
}
|
||||
|
||||
i.size = size
|
||||
|
||||
@@ -53,7 +53,7 @@ func (overlay *OverlayAction) Run(context *debos.DebosContext) error {
|
||||
if len(overlay.Origin) > 0 {
|
||||
var found bool
|
||||
if origin, found = context.Origin(overlay.Origin); !found {
|
||||
return fmt.Errorf("Origin not found '%s'", overlay.Origin)
|
||||
return fmt.Errorf("origin not found '%s'", overlay.Origin)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ func (pf *PackAction) Verify(context *debos.DebosContext) error {
|
||||
possibleTypes = append(possibleTypes, key)
|
||||
}
|
||||
|
||||
return fmt.Errorf("Option 'compression' has an unsupported type: `%s`. Possible types are %s.",
|
||||
return fmt.Errorf("option 'compression' has an unsupported type: `%s`; possible types are %s",
|
||||
pf.Compression, strings.Join(possibleTypes, ", "))
|
||||
}
|
||||
|
||||
|
||||
@@ -35,13 +35,13 @@ func (d *PacstrapAction) listOptionFiles(context *debos.DebosContext) ([]string,
|
||||
files := []string{}
|
||||
|
||||
if d.Config == "" {
|
||||
return nil, fmt.Errorf("No config file set")
|
||||
return nil, fmt.Errorf("no config file set")
|
||||
}
|
||||
d.Config = debos.CleanPathAt(d.Config, context.RecipeDir)
|
||||
files = append(files, d.Config)
|
||||
|
||||
if d.Mirror == "" {
|
||||
return nil, fmt.Errorf("No mirror file set")
|
||||
return nil, fmt.Errorf("no mirror file set")
|
||||
}
|
||||
d.Mirror = debos.CleanPathAt(d.Mirror, context.RecipeDir)
|
||||
files = append(files, d.Mirror)
|
||||
@@ -110,13 +110,13 @@ func (d *PacstrapAction) Run(context *debos.DebosContext) error {
|
||||
// Even if we did, blindly copying it might not be a good idea.
|
||||
cmdline := []string{"pacman-key", "--init"}
|
||||
if err := (debos.Command{}.Run("pacman-key", cmdline...)); err != nil {
|
||||
return fmt.Errorf("Couldn't init pacman keyring: %v", err)
|
||||
return fmt.Errorf("couldn't init pacman keyring: %v", err)
|
||||
}
|
||||
|
||||
// When there's no explicit keyring suite we populate all available
|
||||
cmdline = []string{"pacman-key", "--populate"}
|
||||
if err := (debos.Command{}.Run("pacman-key", cmdline...)); err != nil {
|
||||
return fmt.Errorf("Couldn't populate pacman keyring: %v", err)
|
||||
return fmt.Errorf("couldn't populate pacman keyring: %v", err)
|
||||
}
|
||||
|
||||
// Run pacstrap
|
||||
|
||||
@@ -61,7 +61,7 @@ func (raw *RawAction) checkDeprecatedSyntax() error {
|
||||
log.Printf("Usage of 'source' and 'path' properties is deprecated.")
|
||||
log.Printf("Please use 'origin' and 'source' properties.")
|
||||
if len(raw.Origin) > 0 {
|
||||
return errors.New("Can't mix 'origin' and 'path'(deprecated option) properties")
|
||||
return errors.New("can't mix 'origin' and 'path'(deprecated option) properties")
|
||||
}
|
||||
if len(raw.Source) == 0 {
|
||||
return errors.New("'source' and 'path' properties can't be empty")
|
||||
@@ -89,13 +89,13 @@ func (raw *RawAction) Verify(context *debos.DebosContext) error {
|
||||
func (raw *RawAction) Run(context *debos.DebosContext) error {
|
||||
origin, found := context.Origin(raw.Origin)
|
||||
if !found {
|
||||
return fmt.Errorf("Origin `%s` doesn't exist\n", raw.Origin)
|
||||
return fmt.Errorf("origin `%s` doesn't exist", raw.Origin)
|
||||
}
|
||||
s := path.Join(origin, raw.Source)
|
||||
content, err := ioutil.ReadFile(s)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to read %s", s)
|
||||
return fmt.Errorf("failed to read %s", s)
|
||||
}
|
||||
|
||||
var devicePath string
|
||||
@@ -108,7 +108,7 @@ func (raw *RawAction) Run(context *debos.DebosContext) error {
|
||||
}
|
||||
|
||||
if devicePath == "" {
|
||||
return fmt.Errorf("Failed to find partition named %s", raw.Partition)
|
||||
return fmt.Errorf("failed to find partition named %s", raw.Partition)
|
||||
}
|
||||
} else {
|
||||
devicePath = context.Image
|
||||
@@ -116,7 +116,7 @@ func (raw *RawAction) Run(context *debos.DebosContext) error {
|
||||
|
||||
target, err := os.OpenFile(devicePath, os.O_WRONLY, 0)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to open %s: %v", devicePath, err)
|
||||
return fmt.Errorf("failed to open %s: %v", devicePath, err)
|
||||
}
|
||||
defer target.Close()
|
||||
|
||||
@@ -130,7 +130,7 @@ func (raw *RawAction) Run(context *debos.DebosContext) error {
|
||||
}
|
||||
offset, err = strconv.ParseInt(offs, 0, 64)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Couldn't parse offset %v", err)
|
||||
return fmt.Errorf("couldn't parse offset %v", err)
|
||||
}
|
||||
|
||||
if sector {
|
||||
@@ -140,12 +140,12 @@ func (raw *RawAction) Run(context *debos.DebosContext) error {
|
||||
|
||||
bytes, err := target.WriteAt(content, offset)
|
||||
if bytes != len(content) {
|
||||
return fmt.Errorf("Couldn't write complete data %v", err)
|
||||
return fmt.Errorf("couldn't write complete data %v", err)
|
||||
}
|
||||
|
||||
err = target.Sync()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Couldn't sync content %v", err)
|
||||
return fmt.Errorf("couldn't sync content %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -155,7 +155,7 @@ func (y *YamlAction) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
case "recipe":
|
||||
y.Action = &RecipeAction{}
|
||||
default:
|
||||
return fmt.Errorf("Unknown action: %v", aux.Action)
|
||||
return fmt.Errorf("unknown action: %v", aux.Action)
|
||||
}
|
||||
|
||||
err = unmarshal(y.Action)
|
||||
|
||||
@@ -77,7 +77,7 @@ func (recipe *RecipeAction) Verify(context *debos.DebosContext) error {
|
||||
}
|
||||
|
||||
if recipe.context.Architecture != recipe.Actions.Architecture {
|
||||
return fmt.Errorf("Expect architecture '%s' but got '%s'", context.Architecture, recipe.Actions.Architecture)
|
||||
return fmt.Errorf("expected architecture '%s' but got '%s'", context.Architecture, recipe.Actions.Architecture)
|
||||
}
|
||||
|
||||
for _, a := range recipe.Actions.Actions {
|
||||
|
||||
@@ -72,7 +72,7 @@ architecture: arm64
|
||||
actions:
|
||||
- action: test_unknown_action
|
||||
`,
|
||||
"Unknown action: test_unknown_action",
|
||||
"unknown action: test_unknown_action",
|
||||
},
|
||||
// Test if 'architecture' property absence
|
||||
{`
|
||||
@@ -147,7 +147,7 @@ architecture: arm64
|
||||
actions:
|
||||
- action: {{ sector 42 }}
|
||||
`,
|
||||
"Unknown action: 42s",
|
||||
"unknown action: 42s",
|
||||
}
|
||||
runTest(t, testSector)
|
||||
}
|
||||
@@ -281,7 +281,7 @@ actions:
|
||||
recipe: armhf.yaml
|
||||
`,
|
||||
recipeArmhf,
|
||||
"Expect architecture 'amd64' but got 'armhf'",
|
||||
"expected architecture 'amd64' but got 'armhf'",
|
||||
"", // Do not expect parse failure
|
||||
},
|
||||
{
|
||||
|
||||
@@ -65,11 +65,11 @@ type RunAction struct {
|
||||
|
||||
func (run *RunAction) Verify(context *debos.DebosContext) error {
|
||||
if run.PostProcess && run.Chroot {
|
||||
return errors.New("Cannot run postprocessing in the chroot")
|
||||
return errors.New("cannot run postprocessing in the chroot")
|
||||
}
|
||||
|
||||
if run.Script == "" && run.Command == "" {
|
||||
return errors.New("Script and Command both cannot be empty")
|
||||
return errors.New("need to set 'script' or 'command'")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ type UnpackAction struct {
|
||||
func (pf *UnpackAction) Verify(context *debos.DebosContext) error {
|
||||
|
||||
if len(pf.Origin) == 0 && len(pf.File) == 0 {
|
||||
return fmt.Errorf("Filename can't be empty. Please add 'file' and/or 'origin' property.")
|
||||
return fmt.Errorf("filename can't be empty. Please add 'file' and/or 'origin' property")
|
||||
}
|
||||
|
||||
archive, err := debos.NewArchive(pf.File)
|
||||
@@ -56,7 +56,7 @@ func (pf *UnpackAction) Verify(context *debos.DebosContext) error {
|
||||
}
|
||||
if len(pf.Compression) > 0 {
|
||||
if archive.Type() != debos.Tar {
|
||||
return fmt.Errorf("Option 'compression' is supported for Tar archives only.")
|
||||
return fmt.Errorf("option 'compression' is supported for Tar archives only")
|
||||
}
|
||||
if err := archive.AddOption("tarcompression", pf.Compression); err != nil {
|
||||
return fmt.Errorf("'%s': %s", pf.File, err)
|
||||
@@ -74,7 +74,7 @@ func (pf *UnpackAction) Run(context *debos.DebosContext) error {
|
||||
//Trying to get a filename from origins first
|
||||
origin, found = context.Origin(pf.Origin)
|
||||
if !found {
|
||||
return fmt.Errorf("Origin not found '%s'", pf.Origin)
|
||||
return fmt.Errorf("origin not found '%s'", pf.Origin)
|
||||
}
|
||||
} else {
|
||||
origin = context.Artifactdir
|
||||
|
||||
10
archiver.go
10
archiver.go
@@ -150,23 +150,23 @@ func (tar *ArchiveTar) AddOption(key, value interface{}) error {
|
||||
// expect a slice
|
||||
options, ok := value.([]string)
|
||||
if !ok {
|
||||
return fmt.Errorf("Wrong type for value")
|
||||
return fmt.Errorf("wrong type for value")
|
||||
}
|
||||
tar.options["taroptions"] = options
|
||||
|
||||
case "tarcompression":
|
||||
compression, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("Wrong type for value")
|
||||
return fmt.Errorf("wrong type for value")
|
||||
}
|
||||
option := tarOptions(compression)
|
||||
if len(option) == 0 {
|
||||
return fmt.Errorf("Compression '%s' is not supported", compression)
|
||||
return fmt.Errorf("compression '%s' is not supported", compression)
|
||||
}
|
||||
tar.options["tarcompression"] = compression
|
||||
|
||||
default:
|
||||
return fmt.Errorf("Option '%v' is not supported for tar archive type", key)
|
||||
return fmt.Errorf("option '%v' is not supported for tar archive type", key)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -228,7 +228,7 @@ func NewArchive(file string, arcType ...ArchiveType) (Archive, error) {
|
||||
case Deb:
|
||||
archive = Archive{&ArchiveDeb{ArchiveBase: common}}
|
||||
default:
|
||||
return archive, fmt.Errorf("Unsupported archive '%s'", file)
|
||||
return archive, fmt.Errorf("unsupported archive '%s'", file)
|
||||
}
|
||||
return archive, nil
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ func TestBase(t *testing.T) {
|
||||
// New archive
|
||||
// Expect Tar by default
|
||||
_, err := debos.NewArchive("test.base", 0)
|
||||
assert.EqualError(t, err, "Unsupported archive 'test.base'")
|
||||
assert.EqualError(t, err, "unsupported archive 'test.base'")
|
||||
|
||||
// Test base
|
||||
archive := debos.ArchiveBase{}
|
||||
@@ -64,7 +64,7 @@ func TestTar_default(t *testing.T) {
|
||||
|
||||
// Add wrong option
|
||||
err = archive.AddOption("someoption", "somevalue")
|
||||
assert.EqualError(t, err, "Option 'someoption' is not supported for tar archive type")
|
||||
assert.EqualError(t, err, "option 'someoption' is not supported for tar archive type")
|
||||
}
|
||||
|
||||
// Check supported compression types
|
||||
@@ -91,13 +91,13 @@ func TestTar_compression(t *testing.T) {
|
||||
}
|
||||
// Check of unsupported compression type
|
||||
err = archive.AddOption("tarcompression", "fake")
|
||||
assert.EqualError(t, err, "Compression 'fake' is not supported")
|
||||
assert.EqualError(t, err, "compression 'fake' is not supported")
|
||||
|
||||
// Pass incorrect type
|
||||
err = archive.AddOption("taroptions", nil)
|
||||
assert.EqualError(t, err, "Wrong type for value")
|
||||
assert.EqualError(t, err, "wrong type for value")
|
||||
err = archive.AddOption("tarcompression", nil)
|
||||
assert.EqualError(t, err, "Wrong type for value")
|
||||
assert.EqualError(t, err, "wrong type for value")
|
||||
}
|
||||
|
||||
func TestDeb(t *testing.T) {
|
||||
|
||||
@@ -332,7 +332,7 @@ func newQemuHelper(c Command) (*qemuHelper, error) {
|
||||
q.qemusrc = "/usr/bin/qemu-sh4-static"
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("Don't know qemu for architecture %s", c.Architecture)
|
||||
return nil, fmt.Errorf("unsupported qemu architecture %s", c.Architecture)
|
||||
}
|
||||
|
||||
if q.qemusrc != "" {
|
||||
|
||||
@@ -69,18 +69,18 @@ func CopyTree(sourcetree, desttree string) error {
|
||||
case 0:
|
||||
err := CopyFile(p, target, info.Mode())
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to copy file %s: %w", p, err)
|
||||
return fmt.Errorf("failed to copy file %s: %w", p, err)
|
||||
}
|
||||
case os.ModeDir:
|
||||
os.Mkdir(target, info.Mode())
|
||||
case os.ModeSymlink:
|
||||
link, err := os.Readlink(p)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to read symlink %s: %w", suffix, err)
|
||||
return fmt.Errorf("failed to read symlink %s: %w", suffix, err)
|
||||
}
|
||||
os.Symlink(link, target)
|
||||
default:
|
||||
return fmt.Errorf("File %s with mode %v not handled", p, info.Mode())
|
||||
return fmt.Errorf("file %s with mode %v not handled", p, info.Mode())
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -106,7 +106,7 @@ func RestrictedPath(prefix, dest string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
if !strings.HasPrefix(destination, prefix) {
|
||||
return "", fmt.Errorf("The resulting path points outside of prefix '%s': '%s'\n", prefix, destination)
|
||||
return "", fmt.Errorf("resulting path points outside of prefix '%s': '%s'", prefix, destination)
|
||||
}
|
||||
return destination, nil
|
||||
}
|
||||
|
||||
4
net.go
4
net.go
@@ -17,7 +17,7 @@ func DownloadHttpUrl(url, filename string) error {
|
||||
// Check if file object already exists.
|
||||
fi, err := os.Stat(filename)
|
||||
if !os.IsNotExist(err) && !fi.Mode().IsRegular() {
|
||||
return fmt.Errorf("Failed to download '%s': '%s' exists and it is not a regular file\n", url, filename)
|
||||
return fmt.Errorf("failed to download '%s': '%s' exists and it is not a regular file", url, filename)
|
||||
}
|
||||
|
||||
resp, err := http.Get(url)
|
||||
@@ -27,7 +27,7 @@ func DownloadHttpUrl(url, filename string) error {
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("Url '%s' returned status code %d (%s)\n", url, resp.StatusCode, http.StatusText(resp.StatusCode))
|
||||
return fmt.Errorf("url '%s' returned status code %d (%s)", url, resp.StatusCode, http.StatusText(resp.StatusCode))
|
||||
}
|
||||
|
||||
// Output file
|
||||
|
||||
2
os.go
2
os.go
@@ -50,7 +50,7 @@ exit 101
|
||||
`)
|
||||
|
||||
if _, err := os.Stat(helperFile); os.IsExist(err) {
|
||||
return fmt.Errorf("Policy helper file '%s' exists already", debianPolicyHelper)
|
||||
return fmt.Errorf("policy helper file '%s' exists already", debianPolicyHelper)
|
||||
}
|
||||
if _, err := os.Stat(path.Dir(helperFile)); os.IsNotExist(err) {
|
||||
// do not try to do something if ".../usr/sbin" is not exists
|
||||
|
||||
Reference in New Issue
Block a user