Skip to content

Commit

Permalink
Respect subpackage no-provides
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Myers <elizabeth.myers@chainguard.dev>
  • Loading branch information
Elizafox committed Sep 20, 2023
1 parent 1ec9a55 commit 3379d8a
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion pkg/build/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ type LinterContext struct {
chk *config.Checks
}

func (lctx LinterContext) getPackageOptions() (*config.PackageOption, error) {
if lctx.pkgname == lctx.cfg.Package.Name {
return &lctx.cfg.Package.Options, nil
}

for _, spkg := range lctx.cfg.Subpackages {
if lctx.pkgname == spkg.Name {
return &spkg.Options, nil
}
}

// Shouldn't get here
return nil, fmt.Errorf("Could not locate package or subpackage!")
}

type linterFunc func(lctx LinterContext, path string, d fs.DirEntry) error

type linter struct {
Expand Down Expand Up @@ -173,7 +188,17 @@ func emptyPostLinter(lctx LinterContext, fsys fs.FS) error {
return err
}

if foundfile || lctx.cfg.Package.Options.NoProvides {
// Nothing to do
if foundfile {
return nil
}

options, err := lctx.getPackageOptions()
if err != nil {
return err
}

if options.NoProvides {
// Nothing to do
return nil
}
Expand Down

0 comments on commit 3379d8a

Please sign in to comment.