mirror of https://github.com/status-im/consul.git
net 2731 ip config entry OSS version (#16642)
* ip config entry * name changing * move to ent * ent version * renaming * change format * renaming * refactor * add default values
This commit is contained in:
parent
ff5887a99e
commit
152c75349e
|
@ -553,6 +553,7 @@ func validateProposedConfigEntryInGraph(
|
|||
case structs.InlineCertificate:
|
||||
case structs.HTTPRoute:
|
||||
case structs.TCPRoute:
|
||||
case structs.RateLimitIPConfig:
|
||||
default:
|
||||
return fmt.Errorf("unhandled kind %q during validation of %q", kindName.Kind, kindName.Name)
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@ const (
|
|||
InlineCertificate string = "inline-certificate"
|
||||
HTTPRoute string = "http-route"
|
||||
TCPRoute string = "tcp-route"
|
||||
// TODO: decide if we want to highlight 'ip' keyword in the name of RateLimitIPConfig
|
||||
RateLimitIPConfig string = "control-plane-request-limit"
|
||||
|
||||
ProxyConfigGlobal string = "global"
|
||||
MeshConfigMesh string = "mesh"
|
||||
|
@ -653,6 +655,9 @@ func (c *ConfigEntryRequest) UnmarshalBinary(data []byte) error {
|
|||
}
|
||||
|
||||
func MakeConfigEntry(kind, name string) (ConfigEntry, error) {
|
||||
if configEntry := makeEnterpriseConfigEntry(kind, name); configEntry != nil {
|
||||
return configEntry, nil
|
||||
}
|
||||
switch kind {
|
||||
case ServiceDefaults:
|
||||
return &ServiceConfigEntry{Name: name}, nil
|
||||
|
|
|
@ -44,3 +44,7 @@ func validateExportedServicesName(name string) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func makeEnterpriseConfigEntry(kind, name string) ConfigEntry {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ const (
|
|||
MeshConfig string = "mesh"
|
||||
ExportedServices string = "exported-services"
|
||||
SamenessGroup string = "sameness-group"
|
||||
RateLimitIPConfig string = "control-plane-request-limit"
|
||||
|
||||
ProxyConfigGlobal string = "global"
|
||||
MeshConfigMesh string = "mesh"
|
||||
|
@ -366,6 +367,8 @@ func makeConfigEntry(kind, name string) (ConfigEntry, error) {
|
|||
return &InlineCertificateConfigEntry{Kind: kind, Name: name}, nil
|
||||
case HTTPRoute:
|
||||
return &HTTPRouteConfigEntry{Kind: kind, Name: name}, nil
|
||||
case RateLimitIPConfig:
|
||||
return &RateLimitIPConfigEntry{Kind: kind, Name: name}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid config entry kind: %s", kind)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package api
|
||||
|
||||
type readWriteRatesConfig struct {
|
||||
ReadRate float64
|
||||
WriteRate float64
|
||||
}
|
||||
|
||||
type RateLimitIPConfigEntry struct {
|
||||
// Kind of the config entry. This will be set to structs.RateLimitIPConfig
|
||||
Kind string
|
||||
Name string
|
||||
Mode string // {permissive, enforcing, disabled}
|
||||
|
||||
Meta map[string]string `json:",omitempty"`
|
||||
// overall limits
|
||||
ReadRate float64
|
||||
WriteRate float64
|
||||
|
||||
//limits specific to a type of call
|
||||
ACL *readWriteRatesConfig `json:",omitempty"`
|
||||
Catalog *readWriteRatesConfig `json:",omitempty"`
|
||||
ConfigEntry *readWriteRatesConfig `json:",omitempty"`
|
||||
ConnectCA *readWriteRatesConfig `json:",omitempty"`
|
||||
Coordinate *readWriteRatesConfig `json:",omitempty"`
|
||||
DiscoveryChain *readWriteRatesConfig `json:",omitempty"`
|
||||
Health *readWriteRatesConfig `json:",omitempty"`
|
||||
Intention *readWriteRatesConfig `json:",omitempty"`
|
||||
KV *readWriteRatesConfig `json:",omitempty"`
|
||||
Tenancy *readWriteRatesConfig `json:",omitempty"`
|
||||
PreparedQuery *readWriteRatesConfig `json:",omitempty"`
|
||||
Session *readWriteRatesConfig `json:",omitempty"`
|
||||
Txn *readWriteRatesConfig `json:",omitempty"`
|
||||
|
||||
// Partition is the partition the config entry is associated with.
|
||||
// Partitioning is a Consul Enterprise feature.
|
||||
Partition string `json:",omitempty"`
|
||||
|
||||
// Namespace is the namespace the config entry is associated with.
|
||||
// Namespacing is a Consul Enterprise feature.
|
||||
Namespace string `json:",omitempty"`
|
||||
|
||||
// CreateIndex is the Raft index this entry was created at. This is a
|
||||
// read-only field.
|
||||
CreateIndex uint64
|
||||
|
||||
// ModifyIndex is used for the Check-And-Set operations and can also be fed
|
||||
// back into the WaitIndex of the QueryOptions in order to perform blocking
|
||||
// queries.
|
||||
ModifyIndex uint64
|
||||
}
|
||||
|
||||
func (r *RateLimitIPConfigEntry) GetKind() string {
|
||||
return RateLimitIPConfig
|
||||
}
|
||||
func (r *RateLimitIPConfigEntry) GetName() string {
|
||||
if r == nil {
|
||||
return ""
|
||||
}
|
||||
return r.Name
|
||||
}
|
||||
func (r *RateLimitIPConfigEntry) GetPartition() string {
|
||||
return r.Partition
|
||||
}
|
||||
func (r *RateLimitIPConfigEntry) GetNamespace() string {
|
||||
return r.Namespace
|
||||
}
|
||||
func (r *RateLimitIPConfigEntry) GetMeta() map[string]string {
|
||||
if r == nil {
|
||||
return nil
|
||||
}
|
||||
return r.Meta
|
||||
}
|
||||
func (r *RateLimitIPConfigEntry) GetCreateIndex() uint64 {
|
||||
return r.CreateIndex
|
||||
}
|
||||
func (r *RateLimitIPConfigEntry) GetModifyIndex() uint64 {
|
||||
return r.ModifyIndex
|
||||
}
|
Loading…
Reference in New Issue