Changing the ID of entities to a pointer to platform.ID
parent
fac113821e
commit
a3f2eccc2a
|
@ -32,8 +32,8 @@ type DBRPMapping struct {
|
|||
// Default indicates if this mapping is the default for the cluster and database.
|
||||
Default bool `json:"default"`
|
||||
|
||||
OrganizationID ID `json:"organization_id"`
|
||||
BucketID ID `json:"bucket_id"`
|
||||
OrganizationID *ID `json:"organization_id"`
|
||||
BucketID *ID `json:"bucket_id"`
|
||||
}
|
||||
|
||||
// Validate reports any validation errors for the mapping.
|
||||
|
@ -47,10 +47,10 @@ func (m DBRPMapping) Validate() error {
|
|||
if !validName(m.RetentionPolicy) {
|
||||
return errors.New("RetentionPolicy must contain at least one character and only be letters, numbers, '_', '-', and '.'")
|
||||
}
|
||||
if len(m.OrganizationID) == 0 {
|
||||
if m.OrganizationID == nil {
|
||||
return errors.New("OrganizationID is required")
|
||||
}
|
||||
if len(m.BucketID) == 0 {
|
||||
if m.BucketID == nil {
|
||||
return errors.New("BucketID is required")
|
||||
}
|
||||
return nil
|
||||
|
@ -82,8 +82,11 @@ func (m *DBRPMapping) Equal(o *DBRPMapping) bool {
|
|||
m.Database == o.Database &&
|
||||
m.RetentionPolicy == o.RetentionPolicy &&
|
||||
m.Default == o.Default &&
|
||||
bytes.Equal(m.OrganizationID, o.OrganizationID) &&
|
||||
bytes.Equal(m.BucketID, o.BucketID)
|
||||
// Since empty IDs encodes into a byte array of zeros we could want to check if they are empty or not
|
||||
// m.OrganizationID != nil &&
|
||||
// m.BucketID != nil &&
|
||||
bytes.Equal(m.OrganizationID.Encode(), o.OrganizationID.Encode()) &&
|
||||
bytes.Equal(m.BucketID.Encode(), o.BucketID.Encode())
|
||||
}
|
||||
|
||||
// DBRPMappingFilter represents a set of filters that restrict the returned results by cluster, database and retention policy.
|
||||
|
|
2
owner.go
2
owner.go
|
@ -4,7 +4,7 @@ import "encoding/hex"
|
|||
|
||||
// Owner represents a resource owner
|
||||
type Owner struct {
|
||||
ID ID
|
||||
ID *ID
|
||||
}
|
||||
|
||||
// Decode parses b as a hex-encoded byte-slice-string.
|
||||
|
|
|
@ -13,16 +13,16 @@ type OwnerMappingService interface {
|
|||
|
||||
// OwnerMapping represents a mapping of a resource to its owner
|
||||
type OwnerMapping struct {
|
||||
ResourceID ID `json:"resource_id"`
|
||||
ResourceID *ID `json:"resource_id"`
|
||||
Owner Owner `json:"owner_id"`
|
||||
}
|
||||
|
||||
// Validate reports any validation errors for the mapping.
|
||||
func (m OwnerMapping) Validate() error {
|
||||
if len(m.ResourceID) == 0 {
|
||||
if m.ResourceID == nil {
|
||||
return errors.New("ResourceID is required")
|
||||
}
|
||||
if len(m.Owner.ID) == 0 {
|
||||
if m.Owner.ID == nil {
|
||||
return errors.New("An Owner with an ID is required")
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue