-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested plugin binaries are output to their respective directories #1007
Conversation
} | ||
|
||
// execNameCache is a cache for the executable name, so we don't have to read the plugin.json file multiple times. | ||
var executableNameCache sync.Map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mimicking what we are already doing today with var exname string
above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you wanted to mimick what was there already but is this cache relevant? I'd say the time to read the plugin json file is negligible vs the time to compile 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess for building for all distros for example you benefit from not reading it 6+ times. I haven't performance tested it or anything though 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some light testing and it's negligible it seems. I'll keep it for now for consistency and it does not harm I guess
var ( | ||
defaultOutputBinaryPath = "dist" | ||
defaultPluginJSONPath = "src" | ||
defaultNestedDataSourcePath = "datasource" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have opted to not add a config option for this because I think if people want to do something out of the standard we are offering (docs to come in plugin-tools), then they can do so with mage. For example:
func Foo() {
configCallback := func(cfg build.Config) (build.Config, error) {
cfg.PluginJSONPath = "src/myCustomPath"
return cfg, nil
}
build.SetBeforeBuildCallback(configCallback)
build.BuildAll()
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a nit
@@ -40,6 +46,10 @@ func SetBeforeBuildCallback(cb BeforeBuildCallback) error { | |||
|
|||
var exname string | |||
|
|||
// Deprecated: Use getExecutableNameForPlugin instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. This is not exported so maybe can be deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to - but this func is being used in a couple of places (for debugging it looks like) and I'm reluctant to change in the off chance someone is relying on this behaviour in the debugging setup!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} | ||
|
||
// execNameCache is a cache for the executable name, so we don't have to read the plugin.json file multiple times. | ||
var executableNameCache sync.Map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you wanted to mimick what was there already but is this cache relevant? I'd say the time to read the plugin json file is negligible vs the time to compile 😅
What this PR does / why we need it:
Currently it is expected that any nested datasource binary is placed in the root of the plugin dist. This forces the
executable
path of the nested plugin to contain relative path information so that the binary can be found when loaded by Grafana.This is problematic as it makes it impossible to run these nested plugins on Windows as the path information is UNIX style. Considering the binary belongs to the nested plugin - it should live in the nested plugin's directory so that it is clear what the binary is associated with.
This PR makes it possible to do so while also keeping existing plugins backwards compatible. Therefore plugins with path information in the nested plugin executable
../$binaryName
will continue to work.Special notes for your reviewer: