Create a repository to create, lookup, and list host plugins.
This commit is contained in:
1 parent
db9e1106a9
commit
1237d05232
10 files changed
+957
-74
No files matched your search
@@ -1,8 +1,10 @@
|
||||
package host
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/plugin/host/store"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// A Plugin enables additional logic to be used by boundary.
|
||||
@@ -14,7 +16,7 @@ type Plugin struct {
|
||||
|
||||
// NewPlugin creates a new in memory Plugin assigned to the global scope.
|
||||
// Name, Description are the only allowed option. All other options are ignored.
|
||||
func NewPlugin(pluginName, idPrefix string, opt ...Option) *Plugin {
|
||||
func NewPlugin(pluginName string, idPrefix string, opt ...Option) *Plugin {
|
||||
opts := getOpts(opt...)
|
||||
p := &Plugin{
|
||||
Plugin: &store.Plugin{
|
||||
@@ -41,3 +43,28 @@ func (c *Plugin) TableName() string {
|
||||
func (c *Plugin) SetTableName(n string) {
|
||||
c.tableName = n
|
||||
}
|
||||
|
||||
func allocPlugin() *Plugin {
|
||||
return &Plugin{
|
||||
Plugin: &store.Plugin{},
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Plugin) clone() *Plugin {
|
||||
cp := proto.Clone(c.Plugin)
|
||||
return &Plugin{
|
||||
Plugin: cp.(*store.Plugin),
|
||||
}
|
||||
}
|
||||
|
||||
func newPluginMetadata(p *Plugin, op oplog.OpType) oplog.Metadata {
|
||||
metadata := oplog.Metadata{
|
||||
"resource-public-id": []string{p.GetPublicId()},
|
||||
"resource-type": []string{"host plugin"},
|
||||
"op-type": []string{op.String()},
|
||||
}
|
||||
if p.ScopeId != "" {
|
||||
metadata["scope-id"] = []string{p.ScopeId}
|
||||
}
|
||||
return metadata
|
||||
}
|
||||
Reference in new issue
Block a user