Skip to content

Commit 06eee3d

Browse files
authored
feat: renamed 'vessel' struct to 'evaluation coordinator' (#92)
Signed-off-by: Eddie Knight <knight@linux.com>
1 parent cb7efe7 commit 06eee3d

File tree

5 files changed

+27
-31
lines changed

5 files changed

+27
-31
lines changed

command/plugin.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ import (
1313

1414
type Plugin struct{}
1515

16-
var ActiveVessel *pluginkit.Vessel
16+
var ActiveEvaluationOrchestrator *pluginkit.EvaluationOrchestrator
1717

1818
// Start will be called by Privateer via gRPC
1919
func (p *Plugin) Start() error {
20-
return ActiveVessel.Mobilize()
20+
return ActiveEvaluationOrchestrator.Mobilize()
2121
}
2222

23-
func NewPluginCommands(pluginName, buildVersion, buildGitCommitHash, buildTime string, vessel *pluginkit.Vessel) *cobra.Command {
23+
func NewPluginCommands(pluginName, buildVersion, buildGitCommitHash, buildTime string, orchestrator *pluginkit.EvaluationOrchestrator) *cobra.Command {
2424

25-
ActiveVessel = vessel
25+
ActiveEvaluationOrchestrator = orchestrator
2626

2727
runCmd := runCommand(pluginName)
2828

@@ -60,7 +60,7 @@ func debugCommand() *cobra.Command {
6060
Short: "Run the Plugin in debug mode",
6161
Run: func(cmd *cobra.Command, args []string) {
6262
cmd.Print("Running in debug mode\n")
63-
err := ActiveVessel.Mobilize()
63+
err := ActiveEvaluationOrchestrator.Mobilize()
6464
if err != nil {
6565
cmd.Println(err)
6666
}

command/plugin_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ func testingLoaderFunc(*config.Config) (interface{}, error) { return &nilInterfa
2020

2121
func TestNewPluginCommands(t *testing.T) {
2222
requiredVars := []string{}
23-
vessel := pluginkit.NewVessel(pluginName, testingLoaderFunc, requiredVars)
23+
orchestrator := pluginkit.NewEvaluationOrchestrator(pluginName, testingLoaderFunc, requiredVars)
2424

25-
cmd := NewPluginCommands(pluginName, buildVersion, buildGitCommitHash, buildTime, vessel)
25+
cmd := NewPluginCommands(pluginName, buildVersion, buildGitCommitHash, buildTime, orchestrator)
2626
if cmd.Use != pluginName {
2727
t.Errorf("Expected cmd.Use to be %s, but got %s", pluginName, cmd.Use)
2828
}

pluginkit/errors.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ var (
2424
VESSEL_NAMES_NOT_SET = func(serviceName, pluginName string) error {
2525
return fmt.Errorf("expected service and plugin names to be set. ServiceName='%s' PluginName='%s'", serviceName, pluginName)
2626
}
27+
EVALUATION_ORCHESTRATOR_NAMES_NOT_SET = func(serviceName, pluginName string) error {
28+
return fmt.Errorf("expected service and plugin names to be set. ServiceName='%s' PluginName='%s'", serviceName, pluginName)
29+
}
2730
WRITE_FAILED = func(name, err string) error {
2831
return fmt.Errorf("failed to write results for evaluation suite. name: %s, error: %s", name, err)
2932
}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
"github.com/revanite-io/sci/pkg/layer4"
1313
)
1414

15-
// The vessel gets the armory in position to execute the ControlEvaluations specified in the testSuites
16-
type Vessel struct {
15+
// The evaluation orchestrator gets the plugin in position to execute the specified evaluation suites
16+
type EvaluationOrchestrator struct {
1717
Service_Name string
1818
Plugin_Name string
1919
Payload interface{}
@@ -27,16 +27,16 @@ type Vessel struct {
2727

2828
type DataLoader func(*config.Config) (interface{}, error)
2929

30-
func NewVessel(pluginName string, loader DataLoader, requiredVars []string) *Vessel {
31-
v := &Vessel{
30+
func NewEvaluationOrchestrator(pluginName string, loader DataLoader, requiredVars []string) *EvaluationOrchestrator {
31+
v := &EvaluationOrchestrator{
3232
Plugin_Name: pluginName,
3333
requiredVars: requiredVars,
3434
loader: loader,
3535
}
3636
return v
3737
}
3838

39-
func (v *Vessel) AddEvaluationSuite(catalogId string, loader DataLoader, evaluations []*layer4.ControlEvaluation) {
39+
func (v *EvaluationOrchestrator) AddEvaluationSuite(catalogId string, loader DataLoader, evaluations []*layer4.ControlEvaluation) {
4040
suite := EvaluationSuite{
4141
Catalog_Id: catalogId,
4242
Control_Evaluations: evaluations,
@@ -50,7 +50,7 @@ func (v *Vessel) AddEvaluationSuite(catalogId string, loader DataLoader, evaluat
5050
v.possibleSuites = append(v.possibleSuites, &suite)
5151
}
5252

53-
func (v *Vessel) Mobilize() error {
53+
func (v *EvaluationOrchestrator) Mobilize() error {
5454
v.setupConfig()
5555
if v.config.Error != nil {
5656
return v.config.Error
@@ -60,7 +60,7 @@ func (v *Vessel) Mobilize() error {
6060
return BAD_LOADER(v.Plugin_Name, err)
6161
}
6262

63-
v.config.Logger.Trace("Setting up vessel")
63+
v.config.Logger.Trace("Setting up evaluation orchestrator")
6464

6565
if len(v.possibleSuites) == 0 {
6666
return NO_EVALUATION_SUITES()
@@ -69,7 +69,7 @@ func (v *Vessel) Mobilize() error {
6969
v.Service_Name = v.config.ServiceName
7070

7171
if v.Plugin_Name == "" || v.Service_Name == "" {
72-
return VESSEL_NAMES_NOT_SET(v.Service_Name, v.Plugin_Name)
72+
return EVALUATION_ORCHESTRATOR_NAMES_NOT_SET(v.Service_Name, v.Plugin_Name)
7373
}
7474

7575
v.config.Logger.Trace("Mobilization beginning")
@@ -95,7 +95,7 @@ func (v *Vessel) Mobilize() error {
9595
return v.WriteResults()
9696
}
9797

98-
func (v *Vessel) WriteResults() error {
98+
func (v *EvaluationOrchestrator) WriteResults() error {
9999

100100
var err error
101101
var result []byte
@@ -119,7 +119,7 @@ func (v *Vessel) WriteResults() error {
119119
return nil
120120
}
121121

122-
func (v *Vessel) writeResultsToFile(serviceName string, result []byte, extension string) error {
122+
func (v *EvaluationOrchestrator) writeResultsToFile(serviceName string, result []byte, extension string) error {
123123
if !strings.Contains(extension, ".") {
124124
extension = fmt.Sprintf(".%s", extension)
125125
}
@@ -163,7 +163,7 @@ func (v *Vessel) writeResultsToFile(serviceName string, result []byte, extension
163163
}
164164

165165
// SetPayload allows the user to pass data to be referenced in assessments
166-
func (v *Vessel) loadPayload() (err error) {
166+
func (v *EvaluationOrchestrator) loadPayload() (err error) {
167167
payload := new(interface{})
168168
if v.loader != nil {
169169
data, err := v.loader(v.config)
@@ -187,7 +187,7 @@ func (v *Vessel) loadPayload() (err error) {
187187
return nil
188188
}
189189

190-
func (v *Vessel) setupConfig() {
190+
func (v *EvaluationOrchestrator) setupConfig() {
191191
if v.config == nil {
192192
c := config.NewConfig(v.requiredVars)
193193
v.config = &c
Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
package pluginkit
22

3-
// This file contains table tests for the following functions:
4-
// func (v *Vessel) SetInitilizer(initializer func(*config.Config) error) {
5-
// func (v *Vessel) SetPayload(payload interface{}) {
6-
// func (v *Vessel) Config() *config.Config {
7-
// func (v *Vessel) AddEvaluationSuite(name string, evaluations []layer4.ControlEvaluation) {
8-
// func (v *Vessel) Mobilize(requiredVars []string, suites map[string]EvaluationSuite) error {
9-
103
import (
114
"fmt"
125
"strings"
@@ -17,7 +10,7 @@ import (
1710
)
1811

1912
func TestSetPayload(t *testing.T) {
20-
v := NewVessel("test", nil, []string{})
13+
v := NewEvaluationOrchestrator("test", nil, []string{})
2114

2215
payloadTestData := []struct {
2316
name string
@@ -53,7 +46,7 @@ func TestSetPayload(t *testing.T) {
5346
}
5447

5548
func TestSetupConfig(t *testing.T) {
56-
v := NewVessel("test", nil, []string{})
49+
v := NewEvaluationOrchestrator("test", nil, []string{})
5750
v.setupConfig()
5851
if v.config == nil {
5952
t.Error("Expected config to always be returned")
@@ -74,7 +67,7 @@ func TestAddEvaluationSuite(t *testing.T) {
7467
t.Run(test.testName, func(t *testing.T) {
7568
for _, suite := range test.evals {
7669
t.Run("subtest_"+suite.Name, func(t *testing.T) {
77-
v := NewVessel("test", nil, []string{})
70+
v := NewEvaluationOrchestrator("test", nil, []string{})
7871
v.config = setBasicConfig()
7972
v.AddEvaluationSuite("test", nil, test.evals)
8073
if len(v.possibleSuites) == 0 {
@@ -104,7 +97,7 @@ func TestMobilize(t *testing.T) {
10497
var limitedConfigEvaluationCount int
10598

10699
tt.Run("limitedConfig", func(tt *testing.T) {
107-
v := NewVessel("test", nil, []string{})
100+
v := NewEvaluationOrchestrator("test", nil, []string{})
108101
v.config = setLimitedConfig()
109102

110103
catalogName := strings.ReplaceAll(test.testName, " ", "-")
@@ -131,7 +124,7 @@ func TestMobilize(t *testing.T) {
131124
func runMobilizeTests(t *testing.T, test testingData, invasive bool, limitedConfigEvaluationCount int) {
132125
catalogName := strings.ReplaceAll(test.testName, " ", "-")
133126

134-
v := NewVessel("test", nil, []string{})
127+
v := NewEvaluationOrchestrator("test", nil, []string{})
135128
v.config = setBasicConfig()
136129
v.config.Invasive = invasive
137130

0 commit comments

Comments
 (0)