@@ -48,6 +48,7 @@ type PluginCatalog struct {
48
48
builtinRegistry BuiltinRegistry
49
49
catalogView logical.Storage
50
50
directory string
51
+ tmpdir string
51
52
logger log.Logger
52
53
53
54
// externalPlugins holds plugin process connections by a key which is
@@ -138,37 +139,42 @@ type pluginClient struct {
138
139
plugin.ClientProtocol
139
140
}
140
141
141
- func SetupPluginCatalog (
142
- ctx context.Context ,
143
- logger log.Logger ,
144
- builtinRegistry BuiltinRegistry ,
145
- catalogView logical.Storage ,
146
- pluginDirectory string ,
147
- enableMlock bool ,
148
- pluginRuntimeCatalog * PluginRuntimeCatalog ,
149
- ) (* PluginCatalog , error ) {
150
- pluginCatalog := & PluginCatalog {
151
- builtinRegistry : builtinRegistry ,
152
- catalogView : catalogView ,
153
- directory : pluginDirectory ,
142
+ type PluginCatalogInput struct {
143
+ Logger log.Logger
144
+ BuiltinRegistry BuiltinRegistry
145
+ CatalogView logical.Storage
146
+ PluginDirectory string
147
+ Tmpdir string
148
+ EnableMlock bool
149
+ PluginRuntimeCatalog * PluginRuntimeCatalog
150
+ }
151
+
152
+ func SetupPluginCatalog (ctx context.Context , in * PluginCatalogInput ) (* PluginCatalog , error ) {
153
+ logger := in .Logger
154
+ catalog := & PluginCatalog {
155
+ builtinRegistry : in .BuiltinRegistry ,
156
+ catalogView : in .CatalogView ,
157
+ directory : in .PluginDirectory ,
158
+ tmpdir : in .Tmpdir ,
154
159
logger : logger ,
155
- mlockPlugins : enableMlock ,
160
+ mlockPlugins : in . EnableMlock ,
156
161
wrapper : logical.StaticSystemView {VersionString : version .GetVersion ().Version },
157
- runtimeCatalog : pluginRuntimeCatalog ,
162
+ runtimeCatalog : in . PluginRuntimeCatalog ,
158
163
}
159
164
160
165
// Run upgrade if untyped plugins exist
161
- err := pluginCatalog . UpgradePlugins (ctx , logger )
166
+ err := catalog . upgradePlugins (ctx , logger )
162
167
if err != nil {
163
168
logger .Error ("error while upgrading plugin storage" , "error" , err )
164
169
return nil , err
165
170
}
166
171
167
- if logger .IsInfo () {
168
- logger .Info ("successfully setup plugin catalog" , "plugin-directory" , pluginDirectory )
172
+ logger .Info ("successfully setup plugin catalog" , "plugin-directory" , catalog .directory )
173
+ if catalog .tmpdir != "" {
174
+ logger .Debug ("plugin temporary directory configured" , "tmpdir" , catalog .tmpdir )
169
175
}
170
176
171
- return pluginCatalog , nil
177
+ return catalog , nil
172
178
}
173
179
174
180
type pluginClientConn struct {
@@ -723,9 +729,9 @@ func (c *PluginCatalog) isDatabasePlugin(ctx context.Context, pluginRunner *plug
723
729
return merr .ErrorOrNil ()
724
730
}
725
731
726
- // UpgradePlugins will loop over all the plugins of unknown type and attempt to
732
+ // upgradePlugins will loop over all the plugins of unknown type and attempt to
727
733
// upgrade them to typed plugins
728
- func (c * PluginCatalog ) UpgradePlugins (ctx context.Context , logger log.Logger ) error {
734
+ func (c * PluginCatalog ) upgradePlugins (ctx context.Context , logger log.Logger ) error {
729
735
c .lock .Lock ()
730
736
defer c .lock .Unlock ()
731
737
@@ -739,6 +745,10 @@ func (c *PluginCatalog) UpgradePlugins(ctx context.Context, logger log.Logger) e
739
745
if err != nil {
740
746
return err
741
747
}
748
+ if len (pluginsRaw ) == 0 {
749
+ return nil
750
+ }
751
+
742
752
plugins := make ([]string , 0 , len (pluginsRaw ))
743
753
for _ , p := range pluginsRaw {
744
754
if ! strings .HasSuffix (p , "/" ) {
@@ -838,6 +848,7 @@ func (c *PluginCatalog) get(ctx context.Context, name string, pluginType consts.
838
848
// If none of the cases are satisfied, we'll search for a builtin plugin below.
839
849
switch {
840
850
case entry .OCIImage != "" :
851
+ entry .Tmpdir = c .tmpdir
841
852
if entry .Runtime != "" {
842
853
entry .RuntimeConfig , err = c .runtimeCatalog .Get (ctx , entry .Runtime , consts .PluginRuntimeTypeContainer )
843
854
if err != nil {
@@ -1085,6 +1096,9 @@ func (c *PluginCatalog) ListPluginsWithRuntime(ctx context.Context, runtime stri
1085
1096
if plugin .Runtime == runtime {
1086
1097
ret = append (ret , plugin .Name )
1087
1098
}
1099
+ if plugin .OCIImage != "" {
1100
+ plugin .Tmpdir = c .tmpdir
1101
+ }
1088
1102
}
1089
1103
return ret , nil
1090
1104
}
@@ -1145,6 +1159,10 @@ func (c *PluginCatalog) listInternal(ctx context.Context, pluginType consts.Plug
1145
1159
continue
1146
1160
}
1147
1161
1162
+ if plugin .OCIImage != "" {
1163
+ plugin .Tmpdir = c .tmpdir
1164
+ }
1165
+
1148
1166
result = append (result , pluginutil.VersionedPlugin {
1149
1167
Name : plugin .Name ,
1150
1168
Type : plugin .Type .String (),
0 commit comments