Skip to content
Permalink
Browse files
fix(cleanup): rare panic related to misuse of named return argument
```
panic: assignment to entry in nil map
goroutine 380 [running]:
github.com/werf/werf/pkg/cleaning/stage_manager.GetCustomTagsMetadata.func1({0xc000bee150?, 0x3cb2960?}, {0xc00177ee40?, 0xc000554d90?}, 0xc001414180, {0x0?, 0x0?})
    /git/pkg/cleaning/stage_manager/manager.go:160 +0x11e
github.com/werf/werf/pkg/storage/manager.(*StorageManager).ForEachGetStageCustomTagMetadata.func1({0x3cb2960, 0xc00177ee40}, 0x40761d?)
    /git/pkg/storage/manager/storage_manager.go:1042 +0xa5
```

Signed-off-by: Alexey Igrychev <alexey.igrychev@flant.com>
  • Loading branch information
alexey-igrychev committed Aug 31, 2022
1 parent f8a5dba commit 9fad1110d2b4854e4e0f1573dd3bb41ed1c2143b
Showing 1 changed file with 2 additions and 2 deletions.
@@ -139,14 +139,14 @@ func (m *Manager) InitCustomTagsMetadata(ctx context.Context, storageManager man
return nil
}

func GetCustomTagsMetadata(ctx context.Context, storageManager manager.StorageManagerInterface) (stageIDCustomTagList map[string][]string, err error) {
func GetCustomTagsMetadata(ctx context.Context, storageManager manager.StorageManagerInterface) (map[string][]string, error) {
stageCustomTagMetadataIDs, err := storageManager.GetStagesStorage().GetStageCustomTagMetadataIDs(ctx, storage.WithCache())
if err != nil {
return nil, fmt.Errorf("unable to get stage custom tag metadata IDs: %w", err)
}

var mutex sync.Mutex
stageIDCustomTagList = make(map[string][]string)
stageIDCustomTagList := make(map[string][]string)
err = storageManager.ForEachGetStageCustomTagMetadata(ctx, stageCustomTagMetadataIDs, func(ctx context.Context, metadataID string, metadata *storage.CustomTagMetadata, err error) error {
if err != nil {
return err

0 comments on commit 9fad111

Please sign in to comment.