internal/boundary: add GetResourceType to Resource
The resource type method is used to automatically create refresh tokens from a resource when that resource is the last item returned in a page. This also renames the iam domain ResourceType method to GetResourceType to align with the new method.
This commit is contained in:
1 parent
5cded25c8d
commit
0d39456418
36 files changed
+184
-21
No files matched your search
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/event"
|
||||
"github.com/hashicorp/boundary/internal/host/plugin/store"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"github.com/hashicorp/go-secure-stdlib/strutil"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@@ -90,6 +91,11 @@ func (s *Host) SetTableName(n string) {
|
||||
s.tableName = n
|
||||
}
|
||||
|
||||
// GetResourceType returns the resource type of the Host
|
||||
func (s *Host) GetResourceType() resource.Type {
|
||||
return resource.Host
|
||||
}
|
||||
|
||||
func allocHost() *Host {
|
||||
return &Host{
|
||||
Host: &store.Host{},
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/host/plugin/store"
|
||||
"github.com/hashicorp/boundary/internal/libs/crypto"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/structpb"
|
||||
@@ -122,14 +123,19 @@ func (c *HostCatalog) SetTableName(n string) {
|
||||
c.tableName = n
|
||||
}
|
||||
|
||||
func (s *HostCatalog) oplog(op oplog.OpType) oplog.Metadata {
|
||||
// GetResourceType returns the resource type of the HostCatalog
|
||||
func (c *HostCatalog) GetResourceType() resource.Type {
|
||||
return resource.HostCatalog
|
||||
}
|
||||
|
||||
func (c *HostCatalog) oplog(op oplog.OpType) oplog.Metadata {
|
||||
metadata := oplog.Metadata{
|
||||
"resource-public-id": []string{s.PublicId},
|
||||
"resource-public-id": []string{c.PublicId},
|
||||
"resource-type": []string{"plugin-host-catalog"},
|
||||
"op-type": []string{op.String()},
|
||||
}
|
||||
if s.ProjectId != "" {
|
||||
metadata["project-id"] = []string{s.ProjectId}
|
||||
if c.ProjectId != "" {
|
||||
metadata["project-id"] = []string{c.ProjectId}
|
||||
}
|
||||
return metadata
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/host/plugin/store"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -65,6 +66,11 @@ func (s *HostSet) SetTableName(n string) {
|
||||
s.tableName = n
|
||||
}
|
||||
|
||||
// GetResourceType returns the resource type of the HostSet
|
||||
func (s *HostSet) GetResourceType() resource.Type {
|
||||
return resource.HostSet
|
||||
}
|
||||
|
||||
func allocHostSet() *HostSet {
|
||||
return &HostSet{
|
||||
HostSet: &store.HostSet{},
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/host/static/store"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -71,6 +72,11 @@ func (h *Host) SetTableName(n string) {
|
||||
h.tableName = n
|
||||
}
|
||||
|
||||
// GetResourceType returns the resource type of the Host
|
||||
func (h *Host) GetResourceType() resource.Type {
|
||||
return resource.Host
|
||||
}
|
||||
|
||||
func allocHost() *Host {
|
||||
return &Host{
|
||||
Host: &store.Host{},
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/host/static/store"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -59,6 +60,11 @@ func (c *HostCatalog) SetTableName(n string) {
|
||||
c.tableName = n
|
||||
}
|
||||
|
||||
// GetResourceType returns the resource type of the HostCatalog
|
||||
func (c *HostCatalog) GetResourceType() resource.Type {
|
||||
return resource.HostCatalog
|
||||
}
|
||||
|
||||
func allocCatalog() *HostCatalog {
|
||||
fresh := &HostCatalog{
|
||||
HostCatalog: &store.HostCatalog{},
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/host/static/store"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -51,6 +52,11 @@ func (s *HostSet) SetTableName(n string) {
|
||||
s.tableName = n
|
||||
}
|
||||
|
||||
// GetResourceType returns the resource type of the HostSet
|
||||
func (s *HostSet) GetResourceType() resource.Type {
|
||||
return resource.HostSet
|
||||
}
|
||||
|
||||
func allocHostSet() *HostSet {
|
||||
return &HostSet{
|
||||
HostSet: &store.HostSet{},
|
||||
|
||||
Reference in new issue
Block a user