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:
Johan Brandhorst-Satzkorn committed 2024-01-05 07:43:19 -08:00
1 parent 5cded25c8d
commit 0d39456418
36 files changed
+184 -21

No files matched your search

+6
View File
@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/boundary/internal/auth/ldap/store"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/types/resource"
"google.golang.org/protobuf/proto"
)
@@ -120,6 +121,11 @@ func (a *Account) GetSubject() string {
return ""
}
// GetResourceType returns the resource type of the Account
func (a *Account) GetResourceType() resource.Type {
return resource.Account
}
// oplog will create oplog metadata for the Account.
func (a *Account) oplog(ctx context.Context, opType oplog.OpType) (oplog.Metadata, error) {
const op = "ldap.(Account).oplog"
+6
View File
@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/boundary/internal/auth/ldap/store"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/types/resource"
"google.golang.org/protobuf/proto"
)
@@ -112,6 +113,11 @@ func (am *AuthMethod) SetTableName(n string) {
am.tableName = n
}
// GetResourceType returns the resource type of the AuthMethod
func (am *AuthMethod) GetResourceType() resource.Type {
return resource.AuthMethod
}
// oplog will create oplog metadata for the AuthMethod.
func (am *AuthMethod) oplog(ctx context.Context, opType oplog.OpType) (oplog.Metadata, error) {
const op = "ldap.(AuthMethod).oplog"
+6
View File
@@ -10,6 +10,7 @@ import (
"github.com/hashicorp/boundary/internal/auth/ldap/store"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/types/resource"
"google.golang.org/protobuf/proto"
)
@@ -80,6 +81,11 @@ func (mg *ManagedGroup) SetTableName(n string) {
mg.tableName = n
}
// GetResourceType returns the resource type of the ManagedGroup
func (mg *ManagedGroup) GetResourceType() resource.Type {
return resource.ManagedGroup
}
// oplog will create oplog metadata for the ManagedGroup.
func (mg *ManagedGroup) oplog(ctx context.Context, opType oplog.OpType, authMethodScopeId string) (oplog.Metadata, error) {
const op = "ldap.(ManagedGroup).oplog"
+6
View File
@@ -10,6 +10,7 @@ import (
"github.com/hashicorp/boundary/internal/auth/oidc/store"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/types/resource"
"google.golang.org/protobuf/proto"
)
@@ -115,6 +116,11 @@ func (a *Account) SetTableName(n string) {
a.tableName = n
}
// GetResourceType returns the resource type of the Account
func (a *Account) GetResourceType() resource.Type {
return resource.Account
}
// GetLoginName returns the login name, which will always be empty as this type
// doesn't currently support login name
func (a *Account) GetLoginName() string {
+6
View File
@@ -15,6 +15,7 @@ import (
"github.com/hashicorp/boundary/internal/errors"
"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"
"github.com/hashicorp/go-kms-wrapping/v2/extras/structwrapping"
kvbuilder "github.com/hashicorp/go-secure-stdlib/kv-builder"
@@ -196,6 +197,11 @@ func (a *AuthMethod) SetTableName(n string) {
a.tableName = n
}
// GetResourceType returns the resource type of the AuthMethod
func (a *AuthMethod) GetResourceType() resource.Type {
return resource.AuthMethod
}
// oplog will create oplog metadata for the AuthMethod.
func (a *AuthMethod) oplog(op oplog.OpType) oplog.Metadata {
metadata := oplog.Metadata{
+6
View File
@@ -9,6 +9,7 @@ import (
"github.com/hashicorp/boundary/internal/auth/oidc/store"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/types/resource"
"github.com/hashicorp/go-bexpr"
"google.golang.org/protobuf/proto"
)
@@ -86,6 +87,11 @@ func (mg *ManagedGroup) SetTableName(n string) {
mg.tableName = n
}
// GetResourceType returns the resource type of the ManagedGroup
func (mg *ManagedGroup) GetResourceType() resource.Type {
return resource.ManagedGroup
}
// oplog will create oplog metadata for the ManagedGroup.
func (mg *ManagedGroup) oplog(op oplog.OpType, authMethodScopeId string) oplog.Metadata {
metadata := oplog.Metadata{
+6
View File
@@ -9,6 +9,7 @@ import (
"github.com/hashicorp/boundary/internal/auth/password/store"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/types/resource"
"google.golang.org/protobuf/proto"
)
@@ -70,6 +71,11 @@ func (a *Account) SetTableName(n string) {
a.tableName = n
}
// GetResourceType returns the resource type of the Account
func (a *Account) GetResourceType() resource.Type {
return resource.Account
}
// GetEmail returns the email, which will always be empty as this type doesn't
// currently support email
func (a *Account) GetEmail() string {
+6
View File
@@ -9,6 +9,7 @@ import (
"github.com/hashicorp/boundary/internal/auth/password/store"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/types/resource"
"google.golang.org/protobuf/proto"
)
@@ -69,6 +70,11 @@ func (a *AuthMethod) SetTableName(n string) {
a.tableName = n
}
// GetResourceType returns the resource type of the AuthMethod
func (a *AuthMethod) GetResourceType() resource.Type {
return resource.AuthMethod
}
func (a *AuthMethod) oplog(op oplog.OpType) oplog.Metadata {
metadata := oplog.Metadata{
"resource-public-id": []string{a.GetPublicId()},
+3 -1
View File
@@ -7,6 +7,7 @@ package boundary
import (
"github.com/hashicorp/boundary/internal/db/timestamp"
"github.com/hashicorp/boundary/internal/types/resource"
)
// An Entity is an object distinguished by its identity, rather than its
@@ -24,11 +25,12 @@ type Aggregate interface {
GetUpdateTime() *timestamp.Timestamp
}
// A Resource is an aggregate with a name and description.
// A Resource is an aggregate with a name, description, and resource type.
type Resource interface {
Aggregate
GetName() string
GetDescription() string
GetResourceType() resource.Type
}
// AuthzProtectedEntity is used by some functions (primarily
@@ -6,6 +6,7 @@ package static
import (
"github.com/hashicorp/boundary/internal/credential/static/store"
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/types/resource"
"google.golang.org/protobuf/proto"
)
@@ -55,6 +56,11 @@ func (cs *CredentialStore) SetTableName(n string) {
cs.tableName = n
}
// GetResourceType returns the resource type of the CredentialStore
func (cs *CredentialStore) GetResourceType() resource.Type {
return resource.CredentialStore
}
func (cs *CredentialStore) oplog(op oplog.OpType) oplog.Metadata {
metadata := oplog.Metadata{
"resource-public-id": []string{cs.PublicId},
@@ -12,6 +12,7 @@ import (
"github.com/hashicorp/boundary/internal/errors"
"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"
"github.com/hashicorp/go-kms-wrapping/v2/extras/structwrapping"
"google.golang.org/protobuf/proto"
@@ -88,6 +89,11 @@ func (c *JsonCredential) SetTableName(n string) {
c.tableName = n
}
// GetResourceType returns the resource type of the Credential
func (c *JsonCredential) GetResourceType() resource.Type {
return resource.Credential
}
func (c *JsonCredential) oplog(op oplog.OpType) oplog.Metadata {
metadata := oplog.Metadata{
"resource-public-id": []string{c.PublicId},
@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/boundary/internal/errors"
"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"
"golang.org/x/crypto/ssh"
"google.golang.org/protobuf/proto"
@@ -105,6 +106,11 @@ func (c *SshPrivateKeyCredential) SetTableName(n string) {
c.tableName = n
}
// GetResourceType returns the resource type of the Credential
func (c *SshPrivateKeyCredential) GetResourceType() resource.Type {
return resource.Credential
}
func (c *SshPrivateKeyCredential) oplog(op oplog.OpType) oplog.Metadata {
metadata := oplog.Metadata{
"resource-public-id": []string{c.PublicId},
@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/boundary/internal/errors"
"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"
"github.com/hashicorp/go-kms-wrapping/v2/extras/structwrapping"
"google.golang.org/protobuf/proto"
@@ -73,6 +74,11 @@ func (c *UsernamePasswordCredential) SetTableName(n string) {
c.tableName = n
}
// GetResourceType returns the resource type of the Credential
func (c *UsernamePasswordCredential) GetResourceType() resource.Type {
return resource.Credential
}
func (c *UsernamePasswordCredential) oplog(op oplog.OpType) oplog.Metadata {
metadata := oplog.Metadata{
"resource-public-id": []string{c.PublicId},
@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/boundary/internal/credential/vault/store"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/types/resource"
"google.golang.org/protobuf/proto"
)
@@ -103,6 +104,11 @@ func (l *CredentialLibrary) SetTableName(n string) {
l.tableName = n
}
// GetResourceType returns the resource type of the CredentialLibrary
func (l *CredentialLibrary) GetResourceType() resource.Type {
return resource.CredentialLibrary
}
func (l *CredentialLibrary) oplog(op oplog.OpType) oplog.Metadata {
metadata := oplog.Metadata{
"resource-public-id": []string{l.PublicId},
@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/types/resource"
"google.golang.org/protobuf/proto"
)
@@ -134,6 +135,11 @@ func (cs *CredentialStore) SetTableName(n string) {
cs.tableName = n
}
// GetResourceType returns the resource type of the CredentialStore
func (cs *CredentialStore) GetResourceType() resource.Type {
return resource.CredentialStore
}
func (cs *CredentialStore) oplog(op oplog.OpType) oplog.Metadata {
metadata := oplog.Metadata{
"resource-public-id": []string{cs.PublicId},
@@ -28,6 +28,7 @@ import (
"github.com/hashicorp/boundary/internal/db/timestamp"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/kms"
"github.com/hashicorp/boundary/internal/types/resource"
"github.com/hashicorp/boundary/internal/util/template"
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
"github.com/hashicorp/go-kms-wrapping/v2/extras/structwrapping"
@@ -269,6 +270,11 @@ func (pl *genericIssuingCredentialLibrary) CredentialType() globals.CredentialTy
}
}
// GetResourceType returns the resource type of the CredentialLibrary
func (pl *genericIssuingCredentialLibrary) GetResourceType() resource.Type {
return resource.CredentialLibrary
}
func (pl *genericIssuingCredentialLibrary) client(ctx context.Context) (vaultClient, error) {
const op = "vault.(genericIssuingCredentialLibrary).client"
clientConfig := &clientConfig{
@@ -496,6 +502,11 @@ type privateCredentialLibraryAllTypes struct {
func (pl *privateCredentialLibraryAllTypes) GetPublicId() string { return pl.PublicId }
// GetResourceType returns the resource type of the CredentialLibrary
func (pl *privateCredentialLibraryAllTypes) GetResourceType() resource.Type {
return resource.CredentialLibrary
}
func (pl *privateCredentialLibraryAllTypes) decrypt(ctx context.Context, cipher wrapping.Wrapper) error {
const op = "vault.(privateCredentialLibraryAllTypes).decrypt"
@@ -754,6 +765,11 @@ func (lib *sshCertIssuingCredentialLibrary) CredentialType() globals.CredentialT
}
}
// GetResourceType returns the resource type of the CredentialLibrary
func (lib *sshCertIssuingCredentialLibrary) GetResourceType() resource.Type {
return resource.CredentialLibrary
}
func (lib *sshCertIssuingCredentialLibrary) client(ctx context.Context) (vaultClient, error) {
const op = "vault.(genericIssuingCredentialLibrary).client"
clientConfig := &clientConfig{
@@ -10,6 +10,7 @@ import (
"github.com/hashicorp/boundary/internal/credential"
"github.com/hashicorp/boundary/internal/credential/vault/store"
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/types/resource"
"google.golang.org/protobuf/proto"
)
@@ -96,6 +97,11 @@ func (l *SSHCertificateCredentialLibrary) SetTableName(n string) {
l.tableName = n
}
// GetResourceType returns the resource type of the CredentialLibrary
func (l *SSHCertificateCredentialLibrary) GetResourceType() resource.Type {
return resource.CredentialLibrary
}
func (l *SSHCertificateCredentialLibrary) oplog(op oplog.OpType) oplog.Metadata {
metadata := oplog.Metadata{
"resource-public-id": []string{l.PublicId},
+6
View File
@@ -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{},
+10 -4
View File
@@ -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
}
+6
View File
@@ -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{},
+6
View File
@@ -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{},
+6
View File
@@ -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{},
+6
View File
@@ -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{},
+2 -2
View File
@@ -86,8 +86,8 @@ func (g *Group) GetScope(ctx context.Context, r db.Reader) (*Scope, error) {
return LookupScope(ctx, r, g)
}
// ResourceType returns the type of the Group.
func (*Group) ResourceType() resource.Type { return resource.Group }
// GetResourceType returns the type of the Group.
func (*Group) GetResourceType() resource.Type { return resource.Group }
// Actions returns the available actions for Group
func (*Group) Actions() map[string]action.Type {
+1 -1
View File
@@ -453,7 +453,7 @@ func TestGroup_Actions(t *testing.T) {
func TestGroup_ResourceType(t *testing.T) {
assert := assert.New(t)
r := &Group{}
ty := r.ResourceType()
ty := r.GetResourceType()
assert.Equal(ty, resource.Group)
}
+3 -3
View File
@@ -259,14 +259,14 @@ func (r *Repository) stdMetadata(ctx context.Context, resource Resource) (oplog.
"resource-public-id": []string{resource.GetPublicId()},
"scope-id": []string{newScope.PublicId},
"scope-type": []string{newScope.Type},
"resource-type": []string{resource.ResourceType().String()},
"resource-type": []string{resource.GetResourceType().String()},
}, nil
case scope.Project.String():
return oplog.Metadata{
"resource-public-id": []string{resource.GetPublicId()},
"scope-id": []string{newScope.ParentId},
"scope-type": []string{newScope.Type},
"resource-type": []string{resource.ResourceType().String()},
"resource-type": []string{resource.GetResourceType().String()},
}, nil
default:
return nil, errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("not a supported scope for metadata: %s", s.Type))
@@ -284,7 +284,7 @@ func (r *Repository) stdMetadata(ctx context.Context, resource Resource) (oplog.
"resource-public-id": []string{resource.GetPublicId()},
"scope-id": []string{scope.PublicId},
"scope-type": []string{scope.Type},
"resource-type": []string{resource.ResourceType().String()},
"resource-type": []string{resource.GetResourceType().String()},
}, nil
}
+1 -1
View File
@@ -33,7 +33,7 @@ type Resource interface {
GetScope(ctx context.Context, r db.Reader) (*Scope, error)
// Type of Resource (Target, Policy, User, Group, etc)
ResourceType() resource.Type
GetResourceType() resource.Type
// Actions that can be assigned permissions for
// the Resource in Policies. Action String() is key for
+2 -2
View File
@@ -86,8 +86,8 @@ func (role *Role) GetScope(ctx context.Context, r db.Reader) (*Scope, error) {
return LookupScope(ctx, r, role)
}
// ResourceType returns the type of the Role.
func (*Role) ResourceType() resource.Type { return resource.Role }
// GetResourceType returns the type of the Role.
func (*Role) GetResourceType() resource.Type { return resource.Role }
// Actions returns the available actions for Role.
func (*Role) Actions() map[string]action.Type {
+1 -1
View File
@@ -558,7 +558,7 @@ func TestRole_Actions(t *testing.T) {
func TestRole_ResourceType(t *testing.T) {
assert := assert.New(t)
r := &Role{}
ty := r.ResourceType()
ty := r.GetResourceType()
assert.Equal(ty, resource.Role)
}
+2 -2
View File
@@ -150,8 +150,8 @@ func (s *Scope) VetForWrite(ctx context.Context, r db.Reader, opType db.OpType,
return nil
}
// ResourceType returns the type of scope
func (s *Scope) ResourceType() resource.Type {
// GetResourceType returns the type of scope
func (s *Scope) GetResourceType() resource.Type {
return resource.Scope
}
+1 -1
View File
@@ -175,7 +175,7 @@ func TestScope_Actions(t *testing.T) {
func TestScope_ResourceType(t *testing.T) {
o, err := NewOrg(context.Background())
require.NoError(t, err)
assert.Equal(t, o.ResourceType(), resource.Scope)
assert.Equal(t, o.GetResourceType(), resource.Scope)
assert.Equal(t, o.GetParentId(), scope.Global.String())
}
+2 -2
View File
@@ -89,8 +89,8 @@ func (u *User) GetScope(ctx context.Context, r db.Reader) (*Scope, error) {
return LookupScope(ctx, r, u)
}
// ResourceType returns the type of the User
func (*User) ResourceType() resource.Type { return resource.User }
// GetResourceType returns the type of the User
func (*User) GetResourceType() resource.Type { return resource.User }
// Actions returns the available actions for Users
func (*User) Actions() map[string]action.Type {
+1 -1
View File
@@ -389,7 +389,7 @@ func TestUser_Actions(t *testing.T) {
func TestUser_ResourceType(t *testing.T) {
t.Parallel()
u := AllocUser()
assert.Equal(t, resource.User, u.ResourceType())
assert.Equal(t, resource.User, u.GetResourceType())
}
func TestUser_SetTableName(t *testing.T) {
+7
View File
@@ -14,6 +14,7 @@ import (
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/target/store"
"github.com/hashicorp/boundary/internal/types/resource"
)
// Target is a commmon interface for all target subtypes
@@ -26,6 +27,7 @@ type Target interface {
GetDescription() string
GetVersion() uint32
GetType() globals.Subtype
GetResourceType() resource.Type
GetCreateTime() *timestamp.Timestamp
GetUpdateTime() *timestamp.Timestamp
GetSessionMaxSeconds() uint32
@@ -108,6 +110,11 @@ func (t *targetView) SetTableName(n string) {
}
}
// GetResourceType returns the resource type of the Target
func (t *targetView) GetResourceType() resource.Type {
return resource.Target
}
func (t *targetView) SetHostSources(hs []HostSource) {
t.HostSource = hs
}
+6
View File
@@ -18,6 +18,7 @@ import (
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/target"
"github.com/hashicorp/boundary/internal/target/targettest/store"
"github.com/hashicorp/boundary/internal/types/resource"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
)
@@ -181,6 +182,11 @@ func (t *Target) SetDescription(description string) {
t.Description = description
}
// GetResourceType returns the resource type of the Target
func (t *Target) GetResourceType() resource.Type {
return resource.Target
}
func (t *Target) SetVersion(v uint32) {
t.Version = v
}
+6
View File
@@ -18,6 +18,7 @@ import (
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/target"
"github.com/hashicorp/boundary/internal/target/tcp/store"
"github.com/hashicorp/boundary/internal/types/resource"
"google.golang.org/protobuf/proto"
)
@@ -178,6 +179,11 @@ func (t *Target) SetDescription(description string) {
t.Description = description
}
// GetResourceType returns the resource type of the Target
func (t *Target) GetResourceType() resource.Type {
return resource.Target
}
func (t *Target) SetVersion(v uint32) {
t.Version = v
}