Skip to content

Commit

Permalink
Fix issue where bufmodulebuild.ModuleBucketBuilder.BuildForBucket did…
Browse files Browse the repository at this point in the history
… not properly accept an empty configuration (#2411)
  • Loading branch information
bufdev committed Sep 2, 2023
1 parent 25c0c16 commit cd01222
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion private/bufpkg/bufmodule/bufmodulebuild/module_bucket_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,24 @@ func (b *moduleBucketBuilder) buildForBucket(
}
}

roots := make([]string, 0, len(config.RootToExcludes))
// The below logic relies on all roots being represented in the Config.
//
// The config Godoc says that if no roots are specified, the default of a single root
// if "." with no excludes should be assumed. We need to account for this in the case
// where an empty configuration is passed to this function.
//
// To make sure that we do not edit the input Config, we make a proper copy of the map.
rootToExcludes := make(map[string][]string, len(config.RootToExcludes))
for root, excludes := range config.RootToExcludes {
// You can't modify a slice, so this is OK
rootToExcludes[root] = excludes
}
if len(rootToExcludes) == 0 {
rootToExcludes["."] = []string{}
}

roots := make([]string, 0, len(rootToExcludes))
for root, excludes := range rootToExcludes {
roots = append(roots, root)
mappers := []storage.Mapper{
// need to do match extension here
Expand Down

0 comments on commit cd01222

Please sign in to comment.