Skip to content

Commit 1cecc8f

Browse files
committed
Address issue #684
* `vacuum lint example.yaml` - will fetch remotes ✅ * `vacuum lint example.yaml --remote` - will also fetch remotes ✅ * `vacuum lint example.yaml --remote=false` - will not fetch remotes ✅ * `vacuum report example.yaml` - will fetch remotes ✅ * `vacuum report example.yaml --remote` - will also fetch remotes ✅ * `vacuum report example.yaml --remote=false` - will not fetch remotes ✅ * `vacuum html-report example.yaml` - will fetch remotes ✅ * `vacuum html-report example.yaml --remote` - will also fetch remotes ✅ * `vacuum html-report example.yaml --remote=false` - will not fetch remotes ✅ * `vacuum spectral-report example.yaml` - will fetch remotes ✅ * `vacuum spectral-report example.yaml --remote` - will also fetch remotes ✅ * `vacuum spectral-report example.yaml --remote=false` - will not fetch remotes ✅ * `vacuum bundle example.yaml` - will fetch remotes ✅ * `vacuum bundle example.yaml --remote` - will also fetch remotes ✅ * `vacuum bundle example.yaml --remote=false` - will not fetch remotes ✅ * `vacuum dashboard example.yaml` - will fetch remotes ✅ * `vacuum dashboard example.yaml --remote` - will also fetch remotes ✅ * `vacuum dashboard example.yaml --remote=false` - will not fetch remotes ✅ * `vacuum spectral-report example.yaml` - will fetch remotes ✅ * `vacuum spectral=report example.yaml --remote` - will also fetch remotes ✅ * `vacuum spectral-report example.yaml --remote=false` - will not fetch remotes ✅
1 parent 4d47bda commit 1cecc8f

File tree

6 files changed

+15
-7
lines changed

6 files changed

+15
-7
lines changed

cmd/build_results.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ func BuildResults(
1616
specBytes []byte,
1717
customFunctions map[string]model.RuleFunction,
1818
base string,
19+
remote bool,
1920
timeout time.Duration) (*model.RuleResultSet, *motor.RuleSetExecutionResult, error) {
20-
return BuildResultsWithDocCheckSkip(silent, hardMode, rulesetFlag, specBytes, customFunctions, base, false, timeout)
21+
return BuildResultsWithDocCheckSkip(silent, hardMode, rulesetFlag, specBytes, customFunctions, base, remote, false, timeout)
2122
}
2223

2324
func BuildResultsWithDocCheckSkip(
@@ -27,6 +28,7 @@ func BuildResultsWithDocCheckSkip(
2728
specBytes []byte,
2829
customFunctions map[string]model.RuleFunction,
2930
base string,
31+
remote bool,
3032
skipCheck bool,
3133
timeout time.Duration) (*model.RuleResultSet, *motor.RuleSetExecutionResult, error) {
3234

@@ -76,7 +78,7 @@ func BuildResultsWithDocCheckSkip(
7678
CustomFunctions: customFunctions,
7779
Base: base,
7880
SkipDocumentCheck: skipCheck,
79-
AllowLookup: true,
81+
AllowLookup: remote,
8082
Timeout: timeout,
8183
})
8284

cmd/build_results_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import (
66
)
77

88
func TestBuildResults(t *testing.T) {
9-
_, _, err := BuildResults(false, false, "nuggets", nil, nil, "", 5)
9+
_, _, err := BuildResults(false, false, "nuggets", nil, nil, "", true, 5)
1010
assert.Error(t, err)
1111
}
1212

1313
func TestBuildResults_SkipCheck(t *testing.T) {
14-
_, _, err := BuildResultsWithDocCheckSkip(false, false, "nuggets", nil, nil, "", true, 5)
14+
_, _, err := BuildResultsWithDocCheckSkip(false, false, "nuggets", nil, nil, "", true, true, 5)
1515
assert.Error(t, err)
1616
}

cmd/dashboard.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func GetDashboardCommand() *cobra.Command {
4646
hardModeFlag, _ := cmd.Flags().GetBool("hard-mode")
4747
silent, _ := cmd.Flags().GetBool("silent")
4848
extensionRefsFlag, _ := cmd.Flags().GetBool("ext-refs")
49+
remoteFlag, _ := cmd.Flags().GetBool("remote")
4950

5051
var err error
5152
vacuumReport, specBytes, _ := vacuum_report.BuildVacuumReportFromFile(args[0])
@@ -67,7 +68,7 @@ func GetDashboardCommand() *cobra.Command {
6768

6869
rulesetFlag, _ := cmd.Flags().GetString("ruleset")
6970
resultSet, ruleset, err = BuildResultsWithDocCheckSkip(false, hardModeFlag, rulesetFlag, specBytes, customFunctions,
70-
baseFlag, skipCheckFlag, time.Duration(timeoutFlag)*time.Second)
71+
baseFlag, remoteFlag, skipCheckFlag, time.Duration(timeoutFlag)*time.Second)
7172
if err != nil {
7273
pterm.Error.Printf("Failed to render dashboard: %v\n\n", err)
7374
return err
@@ -100,7 +101,7 @@ func GetDashboardCommand() *cobra.Command {
100101
config.BasePath = baseFlag
101102
}
102103
config.AllowFileLookup = true
103-
config.AllowRemoteLookup = true
104+
config.AllowRemoteLookup = remoteFlag
104105
}
105106

106107
if extensionRefsFlag {

cmd/html_report.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func GetHTMLReportCommand() *cobra.Command {
4747
timeoutFlag, _ := cmd.Flags().GetInt("timeout")
4848
hardModeFlag, _ := cmd.Flags().GetBool("hard-mode")
4949
silent, _ := cmd.Flags().GetBool("silent")
50+
remoteFlag, _ := cmd.Flags().GetBool("remote")
5051

5152
// disable color and styling, for CI/CD use.
5253
// https://github.com/daveshanley/vacuum/issues/234
@@ -96,7 +97,7 @@ func GetHTMLReportCommand() *cobra.Command {
9697

9798
rulesetFlag, _ := cmd.Flags().GetString("ruleset")
9899
resultSet, ruleset, err = BuildResultsWithDocCheckSkip(false, hardModeFlag, rulesetFlag, specBytes, customFunctions,
99-
baseFlag, skipCheckFlag, time.Duration(timeoutFlag)*time.Second)
100+
baseFlag, remoteFlag, skipCheckFlag, time.Duration(timeoutFlag)*time.Second)
100101
if err != nil {
101102
pterm.Error.Printf("Failed to generate report: %v\n\n", err)
102103
return err

cmd/spectral_report.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func GetSpectralReportCommand() *cobra.Command {
4747
timeoutFlag, _ := cmd.Flags().GetInt("timeout")
4848
hardModeFlag, _ := cmd.Flags().GetBool("hard-mode")
4949
extensionRefsFlag, _ := cmd.Flags().GetBool("ext-refs")
50+
remoteFlag, _ := cmd.Flags().GetBool("remote")
5051

5152
// disable color and styling, for CI/CD use.
5253
// https://github.com/daveshanley/vacuum/issues/234
@@ -157,6 +158,7 @@ func GetSpectralReportCommand() *cobra.Command {
157158
CustomFunctions: customFunctions,
158159
SilenceLogs: true,
159160
Base: baseFlag,
161+
AllowLookup: remoteFlag,
160162
SkipDocumentCheck: skipCheckFlag,
161163
Timeout: time.Duration(timeoutFlag) * time.Second,
162164
ExtractReferencesFromExtensions: extensionRefsFlag,

cmd/vacuum_report.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func GetVacuumReportCommand() *cobra.Command {
5050
ignoreFile, _ := cmd.Flags().GetString("ignore-file")
5151
extensionRefsFlag, _ := cmd.Flags().GetBool("ext-refs")
5252
minScore, _ := cmd.Flags().GetInt("min-score")
53+
remoteFlag, _ := cmd.Flags().GetBool("remote")
5354

5455
// disable color and styling, for CI/CD use.
5556
// https://github.com/daveshanley/vacuum/issues/234
@@ -179,6 +180,7 @@ func GetVacuumReportCommand() *cobra.Command {
179180
CustomFunctions: customFunctions,
180181
SilenceLogs: true,
181182
Base: baseFlag,
183+
AllowLookup: remoteFlag,
182184
SkipDocumentCheck: skipCheckFlag,
183185
BuildDeepGraph: deepGraph,
184186
Timeout: time.Duration(timeoutFlag) * time.Second,

0 commit comments

Comments
 (0)