2017-10-25 11:33:19 -05:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
2019-11-29 12:59:40 +01:00
|
|
|
// See LICENSE.txt for license information.
|
2017-10-25 11:33:19 -05:00
|
|
|
|
2017-09-01 09:00:27 -04:00
|
|
|
package model
|
2017-08-16 17:23:38 -05:00
|
|
|
|
2021-01-07 22:42:43 +05:30
|
|
|
import (
|
2021-03-05 09:18:37 +01:00
|
|
|
"github.com/mattermost/mattermost-server/v5/shared/mlog"
|
2021-01-07 22:42:43 +05:30
|
|
|
)
|
2018-06-25 12:33:13 -07:00
|
|
|
|
2017-08-16 17:23:38 -05:00
|
|
|
type BundleInfo struct {
|
|
|
|
|
Path string
|
|
|
|
|
|
|
|
|
|
Manifest *Manifest
|
|
|
|
|
ManifestPath string
|
|
|
|
|
ManifestError error
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-25 12:33:13 -07:00
|
|
|
func (b *BundleInfo) WrapLogger(logger *mlog.Logger) *mlog.Logger {
|
|
|
|
|
if b.Manifest != nil {
|
|
|
|
|
return logger.With(mlog.String("plugin_id", b.Manifest.Id))
|
|
|
|
|
}
|
|
|
|
|
return logger.With(mlog.String("plugin_path", b.Path))
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-16 17:23:38 -05:00
|
|
|
// Returns bundle info for the given path. The return value is never nil.
|
|
|
|
|
func BundleInfoForPath(path string) *BundleInfo {
|
|
|
|
|
m, mpath, err := FindManifest(path)
|
|
|
|
|
return &BundleInfo{
|
|
|
|
|
Path: path,
|
|
|
|
|
Manifest: m,
|
|
|
|
|
ManifestPath: mpath,
|
|
|
|
|
ManifestError: err,
|
|
|
|
|
}
|
|
|
|
|
}
|