github.com/haalcala/mattermost-server-change-repo/v5@v5.33.2/model/bundle_info.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package model
     5  
     6  import (
     7  	"github.com/mattermost/mattermost-server/v5/mlog"
     8  )
     9  
    10  type BundleInfo struct {
    11  	Path string
    12  
    13  	Manifest      *Manifest
    14  	ManifestPath  string
    15  	ManifestError error
    16  }
    17  
    18  func (b *BundleInfo) WrapLogger(logger *mlog.Logger) *mlog.Logger {
    19  	if b.Manifest != nil {
    20  		return logger.With(mlog.String("plugin_id", b.Manifest.Id))
    21  	}
    22  	return logger.With(mlog.String("plugin_path", b.Path))
    23  }
    24  
    25  // Returns bundle info for the given path. The return value is never nil.
    26  func BundleInfoForPath(path string) *BundleInfo {
    27  	m, mpath, err := FindManifest(path)
    28  	return &BundleInfo{
    29  		Path:          path,
    30  		Manifest:      m,
    31  		ManifestPath:  mpath,
    32  		ManifestError: err,
    33  	}
    34  }