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

salsadigitalauorg / shipshape / 13380471727

17 Feb 2025 11:55PM UTC coverage: 67.1% (-0.2%) from 67.267%
13380471727

Pull #78

github

yusufhm
refactor: update connection plugin infrastructure and management

This commit updates the connection plugin system by:
- Introducing a BaseConnection struct to provide common functionality
- Implementing a new plugin manager for connection plugins
- Updating connection plugin types and interfaces
- Migrating existing connection plugins to use the new base implementation
- Improving plugin registration, configuration, and error handling
- Removing deprecated registry and global state management
- Updating command and fact plugin references to use the new connection plugin manager
Pull Request #78: feat: plugin refactor

425 of 944 new or added lines in 31 files covered. (45.02%)

27 existing lines in 10 files now uncovered.

3769 of 5617 relevant lines covered (67.1%)

6.5 hits per line

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

4.17
/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/plugin"
13
        "github.com/salsadigitalauorg/shipshape/pkg/utils"
14
)
15

16
type DockerCommand struct {
17
        fact.BaseFact `yaml:",inline"`
18

19
        // Plugin fields.
20
        Command []string `yaml:"command"`
21
        AsList  bool     `yaml:"as-list"`
22
}
23

24
//go:generate go run ../../../cmd/gen.go fact-plugin --package=docker
25

26
func init() {
1✔
27
        fact.Manager().RegisterFactory("docker:command", func(n string) fact.Facter {
1✔
NEW
28
                return NewDockerCommand(n)
×
NEW
29
        })
×
30
}
31

NEW
32
func NewDockerCommand(id string) *DockerCommand {
×
NEW
33
        return &DockerCommand{
×
NEW
34
                BaseFact: fact.BaseFact{
×
NEW
35
                        BasePlugin: plugin.BasePlugin{
×
NEW
36
                                Id: id,
×
NEW
37
                        },
×
NEW
38
                },
×
NEW
39
        }
×
UNCOV
40
}
×
41

NEW
42
func (p *DockerCommand) GetName() string {
×
NEW
43
        return "docker:command"
×
UNCOV
44
}
×
45

NEW
46
func (p *DockerCommand) SupportedConnections() (plugin.SupportLevel, []string) {
×
NEW
47
        return plugin.SupportRequired, []string{"docker:exec"}
×
UNCOV
48
}
×
49

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

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

74
        if !p.AsList {
×
75
                p.Format = data.FormatRaw
×
NEW
76
                p.SetData(rawData)
×
77
                return
×
78
        }
×
79

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