2023-03-28 18:39:22 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-28 18:39:22 +00:00
|
|
|
|
2023-03-13 21:19:11 +00:00
|
|
|
package structs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/hashicorp/consul/acl"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SamenessGroupConfigEntry struct {
|
|
|
|
Name string
|
2023-03-31 18:35:56 +00:00
|
|
|
DefaultForFailover bool `json:",omitempty" alias:"default_for_failover"`
|
|
|
|
IncludeLocal bool `json:",omitempty" alias:"include_local"`
|
2023-03-13 21:19:11 +00:00
|
|
|
Members []SamenessGroupMember
|
|
|
|
Meta map[string]string `json:",omitempty"`
|
|
|
|
acl.EnterpriseMeta `hcl:",squash" mapstructure:",squash"`
|
|
|
|
RaftIndex
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SamenessGroupConfigEntry) GetKind() string { return SamenessGroup }
|
|
|
|
func (s *SamenessGroupConfigEntry) GetName() string { return s.Name }
|
|
|
|
func (s *SamenessGroupConfigEntry) GetMeta() map[string]string { return s.Meta }
|
|
|
|
func (s *SamenessGroupConfigEntry) GetCreateIndex() uint64 { return s.CreateIndex }
|
|
|
|
func (s *SamenessGroupConfigEntry) GetModifyIndex() uint64 { return s.ModifyIndex }
|
|
|
|
|
|
|
|
func (s *SamenessGroupConfigEntry) GetRaftIndex() *RaftIndex {
|
|
|
|
if s == nil {
|
|
|
|
return &RaftIndex{}
|
|
|
|
}
|
|
|
|
return &s.RaftIndex
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SamenessGroupConfigEntry) GetEnterpriseMeta() *acl.EnterpriseMeta {
|
|
|
|
if s == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return &s.EnterpriseMeta
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SamenessGroupConfigEntry) Normalize() error {
|
|
|
|
if s == nil {
|
|
|
|
return fmt.Errorf("config entry is nil")
|
|
|
|
}
|
|
|
|
s.EnterpriseMeta.Normalize()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SamenessGroupConfigEntry) CanRead(authz acl.Authorizer) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SamenessGroupConfigEntry) CanWrite(authz acl.Authorizer) error {
|
|
|
|
var authzContext acl.AuthorizerContext
|
|
|
|
s.FillAuthzContext(&authzContext)
|
|
|
|
return authz.ToAllowAuthorizer().MeshWriteAllowed(&authzContext)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SamenessGroupConfigEntry) MarshalJSON() ([]byte, error) {
|
|
|
|
type Alias SamenessGroupConfigEntry
|
|
|
|
source := &struct {
|
|
|
|
Kind string
|
|
|
|
*Alias
|
|
|
|
}{
|
|
|
|
Kind: SamenessGroup,
|
|
|
|
Alias: (*Alias)(s),
|
|
|
|
}
|
|
|
|
return json.Marshal(source)
|
|
|
|
}
|
|
|
|
|
|
|
|
type SamenessGroupMember struct {
|
2023-04-21 13:18:32 +00:00
|
|
|
Partition string `json:",omitempty"`
|
|
|
|
Peer string `json:",omitempty"`
|
2023-03-13 21:19:11 +00:00
|
|
|
}
|