From d4fc2efa5339086ced0d7023d3a0e6fadbaddfeb Mon Sep 17 00:00:00 2001 From: Michael Gaffney Date: Mon, 26 Jul 2021 14:03:15 -0400 Subject: [PATCH] Move base interfaces of the domain into a boundary package (#1415) --- internal/boundary/boundary.go | 27 +++++++++++++++++++++++++++ internal/credential/credential.go | 30 ++++-------------------------- 2 files changed, 31 insertions(+), 26 deletions(-) create mode 100644 internal/boundary/boundary.go diff --git a/internal/boundary/boundary.go b/internal/boundary/boundary.go new file mode 100644 index 0000000000..a637c85153 --- /dev/null +++ b/internal/boundary/boundary.go @@ -0,0 +1,27 @@ +// Package boundary contains global interfaces and other definitions that +// define the Boundary domain. +package boundary + +import "github.com/hashicorp/boundary/internal/db/timestamp" + +// An Entity is an object distinguished by its identity, rather than its +// attributes. It can contain value objects and other entities. +type Entity interface { + GetPublicId() string +} + +// An Aggregate is an entity that is the root of a transactional +// consistency boundary. +type Aggregate interface { + Entity + GetVersion() uint32 + GetCreateTime() *timestamp.Timestamp + GetUpdateTime() *timestamp.Timestamp +} + +// A Resource is an aggregate with a name and description. +type Resource interface { + Aggregate + GetName() string + GetDescription() string +} diff --git a/internal/credential/credential.go b/internal/credential/credential.go index 4f64aca2d0..d53367ec03 100644 --- a/internal/credential/credential.go +++ b/internal/credential/credential.go @@ -5,45 +5,23 @@ package credential import ( "context" - "github.com/hashicorp/boundary/internal/db/timestamp" + "github.com/hashicorp/boundary/internal/boundary" ) -// An Entity is an object distinguished by its identity, rather than its -// attributes. It can contain value objects and other entities. -type Entity interface { - GetPublicId() string -} - -// An Aggregate is an entity that is the root of a transactional -// consistency boundary. -type Aggregate interface { - Entity - GetVersion() uint32 - GetCreateTime() *timestamp.Timestamp - GetUpdateTime() *timestamp.Timestamp -} - -// A Resource is an aggregate with a name and description. -type Resource interface { - Aggregate - GetName() string - GetDescription() string -} - // A Store is a resource that can store, retrieve, and potentially generate // credentials of differing types and access levels. It belongs to a scope // and must support the principle of least privilege by providing // mechanisms to limit the credentials it can access to the minimum // necessary for the scope it is in. type Store interface { - Resource + boundary.Resource GetScopeId() string } // A Library is a resource that provides credentials that are of the same // type and access level from a single store. type Library interface { - Resource + boundary.Resource GetStoreId() string } @@ -72,7 +50,7 @@ type SecretData interface{} // Credential is an entity containing secret data. type Credential interface { - Entity + boundary.Entity Secret() SecretData }