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

salsadigitalauorg / shipshape / 13157284528

05 Feb 2025 12:23PM UTC coverage: 61.165% (+0.6%) from 60.56%
13157284528

Pull #71

github

yusufhm
[DEVOPS-158] Added more doc pages.

- Started a guide on connections.
- Added a connection example.
- Added stub pages for other sections.
- Added a file for analyse common fields.
- Started adding some details for `allowed:list`.
Pull Request #71: [DEVOPS-158] Implement required value(s)

111 of 156 new or added lines in 11 files covered. (71.15%)

1 existing line in 1 file now uncovered.

3361 of 5495 relevant lines covered (61.16%)

5.01 hits per line

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

5.0
/pkg/fact/docker/dockercommand.go
1
package docker
2

3
import (
4
        "errors"
5

6
        log "github.com/sirupsen/logrus"
7

8
        "github.com/salsadigitalauorg/shipshape/pkg/command"
9
        "github.com/salsadigitalauorg/shipshape/pkg/connection"
10
        "github.com/salsadigitalauorg/shipshape/pkg/data"
11
        "github.com/salsadigitalauorg/shipshape/pkg/fact"
12
        "github.com/salsadigitalauorg/shipshape/pkg/utils"
13
)
14

15
type DockerCommand struct {
16
        // Common fields.
17
        Name                 string          `yaml:"name"`
18
        Format               data.DataFormat `yaml:"format"`
19
        ConnectionName       string          `yaml:"connection"`
20
        InputName            string          `yaml:"input"`
21
        AdditionalInputNames []string        `yaml:"additional-inputs"`
22
        connection           connection.Connectioner
23
        input                fact.Facter
24
        additionalInputs     []fact.Facter
25
        errors               []error
26
        data                 interface{}
27

28
        // Plugin fields.
29
        Command []string `yaml:"command"`
30
        AsList  bool     `yaml:"as-list"`
31
}
32

33
//go:generate go run ../../../cmd/gen.go fact-plugin --plugin=DockerCommand --package=docker
34

35
func init() {
1✔
36
        fact.Registry["docker:command"] = func(n string) fact.Facter { return &DockerCommand{Name: n} }
1✔
37
}
38

39
func (p *DockerCommand) PluginName() string {
×
40
        return "docker:command"
×
41
}
×
42

43
func (p *DockerCommand) SupportedConnections() (fact.SupportLevel, []string) {
×
44
        return fact.SupportRequired, []string{"docker:exec"}
×
45
}
×
46

47
func (p *DockerCommand) SupportedInputs() (fact.SupportLevel, []string) {
×
48
        return fact.SupportNone, []string{}
×
49
}
×
50

51
func (p *DockerCommand) Collect() {
×
NEW
52
        log.WithFields(log.Fields{
×
NEW
53
                "fact-plugin":       p.PluginName(),
×
NEW
54
                "fact":              p.Name,
×
NEW
55
                "connection":        p.GetConnectionName(),
×
NEW
56
                "connection-plugin": p.connection.PluginName(),
×
NEW
57
        }).Debug("collecting data")
×
NEW
58

×
59
        dockerConn := p.connection.(*connection.DockerExec)
×
60
        dockerConn.Command = p.Command
×
61
        rawData, err := dockerConn.Run()
×
62
        if err != nil {
×
NEW
63
                errMsg := command.GetMsgFromCommandError(err)
×
NEW
64
                if errMsg == "" {
×
NEW
65
                        errMsg = string(rawData)
×
NEW
66
                } else {
×
NEW
67
                        errMsg = errMsg + ": " + string(rawData)
×
NEW
68
                }
×
NEW
69
                err = errors.New(errMsg)
×
NEW
70
                log.WithError(err).Error("docker command failed")
×
71
                p.errors = append(p.errors, err)
×
72
                return
×
73
        }
74

75
        if !p.AsList {
×
76
                p.Format = data.FormatRaw
×
77
                p.data = rawData
×
78
                return
×
79
        }
×
80

81
        p.Format = data.FormatListString
×
82
        p.data = utils.MultilineOutputToSlice(rawData)
×
83
}
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

© 2026 Coveralls, Inc