Skip to content

Commit

Permalink
Refactored vacuum to use pb33f shared libraries
Browse files Browse the repository at this point in the history
pb33f is now the source of truth for low level, shared models and concepts. The Resolver, Index and generic utilities have all been moved out. This means a smaller codebase for vacuum, and less moving parts for the application to manage. It will now become a sister of princess beef.
  • Loading branch information
daveshanley committed Jul 18, 2022
1 parent 81c92eb commit 1b726e7
Show file tree
Hide file tree
Showing 134 changed files with 493 additions and 4,364 deletions.
8 changes: 5 additions & 3 deletions cmd/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/motor"
vacuum_report "github.com/daveshanley/vacuum/vacuum-report"
"github.com/pb33f/libopenapi/datamodel"
"github.com/pb33f/libopenapi/index"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
Expand Down Expand Up @@ -37,8 +39,8 @@ func GetDashboardCommand() *cobra.Command {

var resultSet *model.RuleResultSet
var ruleset *motor.RuleSetExecutionResult
var specIndex *model.SpecIndex
var specInfo *model.SpecInfo
var specIndex *index.SpecIndex
var specInfo *datamodel.SpecInfo

// if we have a pre-compiled report, jump straight to the end and collect $500
if vacuumReport == nil {
Expand All @@ -65,7 +67,7 @@ func GetDashboardCommand() *cobra.Command {
pterm.Println()
return err
}
specIndex = model.NewSpecIndex(&rootNode)
specIndex = index.NewSpecIndex(&rootNode)
specInfo = vacuumReport.SpecInfo
specInfo.Generated = vacuumReport.Generated
}
Expand Down
6 changes: 4 additions & 2 deletions cmd/html_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/daveshanley/vacuum/motor"
"github.com/daveshanley/vacuum/statistics"
vacuum_report "github.com/daveshanley/vacuum/vacuum-report"
"github.com/pb33f/libopenapi/datamodel"
"github.com/pb33f/libopenapi/index"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"io/ioutil"
Expand Down Expand Up @@ -55,8 +57,8 @@ func GetHTMLReportCommand() *cobra.Command {

var resultSet *model.RuleResultSet
var ruleset *motor.RuleSetExecutionResult
var specIndex *model.SpecIndex
var specInfo *model.SpecInfo
var specIndex *index.SpecIndex
var specInfo *datamodel.SpecInfo
var stats *reports.ReportStatistics

// if we have a pre-compiled report, jump straight to the end and collect $500
Expand Down
8 changes: 5 additions & 3 deletions cui/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"github.com/daveshanley/vacuum/model"
ui "github.com/gizak/termui/v3"
"github.com/gizak/termui/v3/widgets"
"github.com/pb33f/libopenapi/datamodel"
"github.com/pb33f/libopenapi/index"
)

// Dashboard represents the dashboard controlling container
Expand All @@ -17,8 +19,8 @@ type Dashboard struct {
healthGaugeItems []ui.GridItem
categoryHealthGauge []CategoryGauge
resultSet *model.RuleResultSet
index *model.SpecIndex
info *model.SpecInfo
index *index.SpecIndex
info *datamodel.SpecInfo
selectedTabIndex int
ruleCategories []*model.RuleCategory
selectedCategory *model.RuleCategory
Expand All @@ -32,7 +34,7 @@ type Dashboard struct {
uiEvents <-chan ui.Event
}

func CreateDashboard(resultSet *model.RuleResultSet, index *model.SpecIndex, info *model.SpecInfo) *Dashboard {
func CreateDashboard(resultSet *model.RuleResultSet, index *index.SpecIndex, info *datamodel.SpecInfo) *Dashboard {
db := new(Dashboard)
db.resultSet = resultSet
db.index = index
Expand Down
8 changes: 5 additions & 3 deletions cui/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/daveshanley/vacuum/motor"
"github.com/daveshanley/vacuum/rulesets"
ui "github.com/gizak/termui/v3"
"github.com/pb33f/libopenapi/datamodel"
"github.com/pb33f/libopenapi/index"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"io/ioutil"
Expand Down Expand Up @@ -111,14 +113,14 @@ func TestDashboard_Render(t *testing.T) {
//}
}

func testBootDashboard() (*model.RuleResultSet, *model.SpecIndex, *model.SpecInfo) {
func testBootDashboard() (*model.RuleResultSet, *index.SpecIndex, *datamodel.SpecInfo) {
var rootNode yaml.Node
yamlBytes, _ := ioutil.ReadFile("../model/test_files/burgershop.openapi.yaml")

info, _ := model.ExtractSpecInfo(yamlBytes)
info, _ := datamodel.ExtractSpecInfo(yamlBytes)

yaml.Unmarshal(yamlBytes, &rootNode)
index := model.NewSpecIndex(&rootNode)
index := index.NewSpecIndex(&rootNode)

// let's go ahead and lint the spec and pass the results to the dashboard.
defaultRuleSets := rulesets.BuildDefaultRuleSets()
Expand Down
5 changes: 3 additions & 2 deletions cui/stats_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package cui

import (
"fmt"
"github.com/daveshanley/vacuum/model"
ui "github.com/gizak/termui/v3"
"github.com/gizak/termui/v3/widgets"
"github.com/pb33f/libopenapi/datamodel"
"github.com/pb33f/libopenapi/index"
)

// StatsChart represents a bar chart showing statistics of the specification.
Expand All @@ -13,7 +14,7 @@ type StatsChart struct {
}

// NewStatsChart returns a new gauge widget that is ready to render
func NewStatsChart(index *model.SpecIndex, info *model.SpecInfo) StatsChart {
func NewStatsChart(index *index.SpecIndex, info *datamodel.SpecInfo) StatsChart {
bc := widgets.NewList()

//paramCount := len(index.GetAllParameters()) index. + len(index.GetAllParametersFromOperations())
Expand Down
7 changes: 4 additions & 3 deletions cui/stats_chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
package cui

import (
"github.com/daveshanley/vacuum/model"
"github.com/pb33f/libopenapi/datamodel"
"github.com/pb33f/libopenapi/index"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"io/ioutil"
Expand All @@ -15,9 +16,9 @@ func TestNewStatsChart(t *testing.T) {
var rootNode yaml.Node
yamlBytes, _ := ioutil.ReadFile("../model/test_files/burgershop.openapi.yaml")

info, _ := model.ExtractSpecInfo(yamlBytes)
info, _ := datamodel.ExtractSpecInfo(yamlBytes)
yaml.Unmarshal(yamlBytes, &rootNode)
index := model.NewSpecIndex(&rootNode)
index := index.NewSpecIndex(&rootNode)

chart := NewStatsChart(index, info)

Expand Down
2 changes: 1 addition & 1 deletion functions/core/alphabetical.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package core
import (
"fmt"
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"gopkg.in/yaml.v3"
"sort"
"strconv"
Expand Down
2 changes: 1 addition & 1 deletion functions/core/alphabetical_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package core

import (
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"testing"
)
Expand Down
2 changes: 1 addition & 1 deletion functions/core/casing.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package core
import (
"fmt"
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"gopkg.in/yaml.v3"
"regexp"
"strconv"
Expand Down
2 changes: 1 addition & 1 deletion functions/core/casing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package core

import (
"github.com/daveshanley/vacuum/model"
gen_utils "github.com/daveshanley/vacuum/utils"
gen_utils "github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"testing"
)
Expand Down
2 changes: 1 addition & 1 deletion functions/core/defined.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package core
import (
"fmt"
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"gopkg.in/yaml.v3"
)

Expand Down
2 changes: 1 addition & 1 deletion functions/core/defined_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package core

import (
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"testing"
)
Expand Down
2 changes: 1 addition & 1 deletion functions/core/enumeration.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package core
import (
"fmt"
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"gopkg.in/yaml.v3"
"strings"
)
Expand Down
2 changes: 1 addition & 1 deletion functions/core/enumeration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package core

import (
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"testing"
)
Expand Down
2 changes: 1 addition & 1 deletion functions/core/falsy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package core
import (
"fmt"
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"gopkg.in/yaml.v3"
)

Expand Down
2 changes: 1 addition & 1 deletion functions/core/falsy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package core

import (
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"testing"
)
Expand Down
2 changes: 1 addition & 1 deletion functions/core/length.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package core

import (
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"gopkg.in/yaml.v3"
"strconv"
)
Expand Down
2 changes: 1 addition & 1 deletion functions/core/length_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package core

import (
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"testing"
)
Expand Down
2 changes: 1 addition & 1 deletion functions/core/pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package core
import (
"fmt"
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"gopkg.in/yaml.v3"
"regexp"
)
Expand Down
2 changes: 1 addition & 1 deletion functions/core/pattern_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package core

import (
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"testing"
)
Expand Down
2 changes: 1 addition & 1 deletion functions/core/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/parser"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"gopkg.in/yaml.v3"
)

Expand Down
2 changes: 1 addition & 1 deletion functions/core/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package core
import (
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/parser"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"testing"
)
Expand Down
2 changes: 1 addition & 1 deletion functions/core/truthy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package core
import (
"fmt"
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"gopkg.in/yaml.v3"
)

Expand Down
2 changes: 1 addition & 1 deletion functions/core/truthy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package core

import (
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"testing"
)
Expand Down
2 changes: 1 addition & 1 deletion functions/core/undefined.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package core
import (
"fmt"
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"gopkg.in/yaml.v3"
)

Expand Down
2 changes: 1 addition & 1 deletion functions/core/undefined_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package core

import (
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"testing"
)
Expand Down
2 changes: 1 addition & 1 deletion functions/core/xor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package core
import (
"fmt"
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"gopkg.in/yaml.v3"
"strings"
)
Expand Down
2 changes: 1 addition & 1 deletion functions/core/xor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package core

import (
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"testing"
)
Expand Down
2 changes: 1 addition & 1 deletion functions/openapi/component_descriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package openapi
import (
"fmt"
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"gopkg.in/yaml.v3"
"strconv"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion functions/openapi/component_descriptions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package openapi

import (
"github.com/daveshanley/vacuum/model"
"github.com/daveshanley/vacuum/utils"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"testing"
)
Expand Down
Loading

0 comments on commit 1b726e7

Please sign in to comment.