Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/lint/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,12 +409,12 @@ var AllRules = func(l *Linter) Rules { //nolint:gocyclo
Severity: SeverityError,
LintFunc: func(config config.Configuration) error {
for _, repo := range config.Environment.Contents.BuildRepositories {
if repo[0] == '@' {
if strings.HasPrefix(repo, "@") {
return fmt.Errorf("repository %q is tagged", repo)
}
}
for _, repo := range config.Environment.Contents.Repositories {
if repo[0] == '@' {
if strings.HasPrefix(repo, "@") {
return fmt.Errorf("repository %q is tagged", repo)
}
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/lint/rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ func TestLinter_Rules(t *testing.T) {
wantErr: false,
matches: 1,
},
{
// an empty entry used to panic the rule on repo[0]
file: "empty-repository-entry.yaml",
minSeverity: SeverityWarning,
want: EvalResult{
File: "empty-repository-entry",
Errors: EvalRuleErrors{},
},
wantErr: false,
matches: 0,
},
{
file: "forbidden-repository-tagged.yaml",
minSeverity: SeverityWarning,
Expand Down
27 changes: 27 additions & 0 deletions pkg/lint/testdata/files/empty-repository-entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#nolint:fetch-templating
package:
name: empty-repository-entry
version: 1.0.0
epoch: 0
description: A package with an empty entry in the repositories block
target-architecture:
- all
copyright:
- license: Apache-2.0
paths:
- "*"
environment:
contents:
repositories:
- ""
packages:
- foo
pipeline:
- uses: fetch
with:
uri: https://test.com/foo/bar/baz.tar.gz
expected-sha512: 6d8e828fa406518b4b3f55b0e5f62bbd5cf25cb5782d1884b9d5eaf61fb0614deaacad4236ab7420fa5b3868c79df226ae1aa5193bb136c556aa52853eeca553
- runs: |
go build .
update:
enabled: true