mirror of
https://github.com/status-im/consul.git
synced 2025-01-11 06:16:08 +00:00
5fb9df1640
* Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at <Blog URL>, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
77 lines
2.0 KiB
Go
77 lines
2.0 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package structs
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"github.com/hashicorp/consul/acl"
|
|
)
|
|
|
|
type SamenessGroupConfigEntry struct {
|
|
Name string
|
|
DefaultForFailover bool `json:",omitempty" alias:"default_for_failover"`
|
|
IncludeLocal bool `json:",omitempty" alias:"include_local"`
|
|
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 {
|
|
Partition string `json:",omitempty"`
|
|
Peer string `json:",omitempty"`
|
|
}
|