Create host (#276)
* Change testHostCatalog methods to be like other resource test methods * Implement CreateHost * Make allocHost return a pointer to a Host
This commit is contained in:
1 parent
282177afc2
commit
e18cdc52b3
10 files changed
+351
-16
No files matched your search
@@ -5,6 +5,8 @@ import (
|
||||
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/host/static/store"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// A Host contains a static address.
|
||||
@@ -49,3 +51,28 @@ func (h *Host) TableName() string {
|
||||
func (h *Host) SetTableName(n string) {
|
||||
h.tableName = n
|
||||
}
|
||||
|
||||
func allocHost() *Host {
|
||||
return &Host{
|
||||
Host: &store.Host{},
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Host) clone() *Host {
|
||||
cp := proto.Clone(h.Host)
|
||||
return &Host{
|
||||
Host: cp.(*store.Host),
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Host) oplog(op oplog.OpType) oplog.Metadata {
|
||||
metadata := oplog.Metadata{
|
||||
"resource-public-id": []string{h.PublicId},
|
||||
"resource-type": []string{"static-host"},
|
||||
"op-type": []string{op.String()},
|
||||
}
|
||||
if h.CatalogId != "" {
|
||||
metadata["catalog-id"] = []string{h.CatalogId}
|
||||
}
|
||||
return metadata
|
||||
}
|
||||
Reference in new issue
Block a user