Placeholder Plugin Providers for Repos and added testPlugin struct (#1532)
* Create minimalistic plugin map and test plugin. * Pass secrets and attributes to the plugin when creating catalogs or sets. Add tests for CreateSet and CreateCatalog repo methods. * make fmt and extract out getPrivateCatalog and getCatalog helper methods. * Exporting TestPluginServer so it can be used in the handlers. * Keep separate persisted data from host catalogs lookups which facilitate passing it onto the plugins. * Add TODO to merge get Catalog and get Persisted data. * Adding tests for unimplemented being returned by the plugin. * Use GetFields() instead of AsMap() to confirm attributes should be populated. Make clone consistent between catalog and sets. Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
This commit is contained in:
1 parent
ea939a4445
commit
bbfef2802f
30 files changed
+669
-227
No files matched your search
@@ -1,5 +1,7 @@
|
||||
package plugin
|
||||
|
||||
import "google.golang.org/protobuf/types/known/structpb"
|
||||
|
||||
// getOpts - iterate the inbound Options and return a struct
|
||||
func getOpts(opt ...Option) options {
|
||||
opts := getDefaultOptions()
|
||||
@@ -16,16 +18,14 @@ type Option func(*options)
|
||||
type options struct {
|
||||
withName string
|
||||
withDescription string
|
||||
withAttributes map[string]interface{}
|
||||
withSecrets map[string]interface{}
|
||||
withAttributes *structpb.Struct
|
||||
withSecrets *structpb.Struct
|
||||
withPreferredEndpoints []string
|
||||
}
|
||||
|
||||
func getDefaultOptions() options {
|
||||
return options{
|
||||
withDescription: "",
|
||||
withName: "",
|
||||
withAttributes: make(map[string]interface{}),
|
||||
withAttributes: &structpb.Struct{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,14 +44,14 @@ func WithName(name string) Option {
|
||||
}
|
||||
|
||||
// WithAttributes provides an optional attributes field.
|
||||
func WithAttributes(attrs map[string]interface{}) Option {
|
||||
func WithAttributes(attrs *structpb.Struct) Option {
|
||||
return func(o *options) {
|
||||
o.withAttributes = attrs
|
||||
}
|
||||
}
|
||||
|
||||
// WithSecrets provides an optional secrets field.
|
||||
func WithSecrets(secrets map[string]interface{}) Option {
|
||||
func WithSecrets(secrets *structpb.Struct) Option {
|
||||
return func(o *options) {
|
||||
o.withSecrets = secrets
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user