• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender-artifact / 1839622663

15 May 2025 12:46PM UTC coverage: 76.677% (+0.04%) from 76.641%
1839622663

push

gitlab-ci

web-flow
Merge pull request #700 from danielskinstad/macos-fsck-error

chore: add verbose error message for fsck on Mac OS

3 of 5 new or added lines in 1 file covered. (60.0%)

5921 of 7722 relevant lines covered (76.68%)

132.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.47
/utils/binpath.go
1
// Copyright 2021 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14

15
package utils
16

17
import (
18
        "fmt"
19
        "os/exec"
20
        "path"
21
        "runtime"
22
        "slices"
23

24
        "github.com/pkg/errors"
25
)
26

27
var (
28
        ExternalBinaryPaths = []string{"/usr/sbin", "/sbin", "/usr/local/sbin"}
29
)
30

31
var unsupportedBinariesDarwin = []string{
32
        "parted",
33
        "fsck.ext4",
34
        "fsck.vfat",
35
}
36

37
const errorUnsupportedDarwin = "Operations that use %q are unfortunately not available on Mac OS."
38

39
func GetBinaryPath(command string) (string, error) {
1,370✔
40
        // first check if command exists in PATH
1,370✔
41
        p, err := exec.LookPath(command)
1,370✔
42
        if err == nil {
2,734✔
43
                return p, nil
1,364✔
44
        }
1,364✔
45

46
        // maybe sbin isn't included in PATH, check there explicitly.
47
        for _, p = range ExternalBinaryPaths {
12✔
48
                p, err = exec.LookPath(path.Join(p, command))
6✔
49
                if err == nil {
6✔
50
                        return p, nil
×
51
                }
×
52
        }
53

54
        // not found, but oh well...
55
        if runtime.GOOS == "darwin" {
7✔
56
                base := path.Base(command)
1✔
57
                if slices.Contains(unsupportedBinariesDarwin, base) {
1✔
NEW
58
                        return command, errors.Wrap(err, fmt.Sprintf(errorUnsupportedDarwin, base))
×
NEW
59
                }
×
60
        }
61

62
        return command, err
6✔
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc