Plugins work now oughghgghughgghg

This commit is contained in:
2024-12-10 15:51:34 -05:00
parent c2ccaff8ab
commit f112a2e564
4 changed files with 121 additions and 66 deletions

View File

@@ -129,29 +129,31 @@ func main () {
Config: config,
}
environment.Providers = providers.All()
err := environment.Init(context.Background())
if err != nil { log.Fatal(err) }
// load plugins
for _, pat := range pluginPath {
entries, err := os.ReadDir(pat)
if err != nil { continue }
for _, entry := range entries {
pluginPath := filepath.Join(pat, entry.Name())
ext := filepath.Ext(pluginPath)
if ext != ".so" { continue }
if flagUnsafePlugins.Value == "true" {
_, err = environment.LoadProviderPluginUnsafe(pluginPath)
} else {
_, err = environment.LoadProviderPlugin(pluginPath)
}
if err != nil {
var err error
var plugins []step.Provider
if flagUnsafePlugins.Value == "true" {
plugins, err = step.LoadAllProviderPluginsUnsafe(pluginPath...)
} else {
plugins, err = step.LoadAllProviderPlugins(pluginPath...)
}
if err != nil {
if errs, ok := err.(step.Errors); ok {
for _, err := range errs.Unwrap() {
log.Println("!!!", err)
}
} else {
log.Println("!!!", err)
}
}
environment.Providers = append(environment.Providers, plugins...)
logProviders(environment.Providers)
// initialize the environment
err = environment.Init(context.Background())
if err != nil { log.Fatal(err) }
// set up the HTTP handler
handler := stephttp.Handler {
Environment: &environment,