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
@@ -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},
|
||||
|
||||
Reference in new issue
Block a user