agent,config: port enterprise only fields to embedded enterprise structs

This commit is contained in:
Kit Patella 2020-04-17 13:27:39 -07:00
parent 4a86cb12c1
commit 3b105435b8
5 changed files with 12 additions and 50 deletions

View File

@ -16,7 +16,6 @@ import (
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
"sync/atomic"
"time" "time"
"github.com/hashicorp/go-connlimit" "github.com/hashicorp/go-connlimit"
@ -179,10 +178,6 @@ type Agent struct {
// In-memory sink used for collecting metrics // In-memory sink used for collecting metrics
MemSink *metrics.InmemSink MemSink *metrics.InmemSink
// Eventer provides a backend for handling event logging. APIs are provided on the agent for interacting with
// this reloadable type
Eventer atomic.Value
// delegate is either a *consul.Server or *consul.Client // delegate is either a *consul.Server or *consul.Client
// depending on the configuration // depending on the configuration
delegate delegate delegate delegate
@ -317,6 +312,9 @@ type Agent struct {
// httpConnLimiter is used to limit connections to the HTTP server by client // httpConnLimiter is used to limit connections to the HTTP server by client
// IP. // IP.
httpConnLimiter connlimit.Limiter httpConnLimiter connlimit.Limiter
// enterpriseAgent embeds fields that we only access in consul-enterprise builds
enterpriseAgent
} }
// New verifies the configuration given has a Datacenter and DataDir // New verifies the configuration given has a Datacenter and DataDir

View File

@ -9,6 +9,9 @@ import (
"github.com/hashicorp/consul/api" "github.com/hashicorp/consul/api"
) )
// enterpriseAgent embeds fields that we only access in consul-enterprise builds
type enterpriseAgent struct{}
// fillAgentServiceEnterpriseMeta is a noop stub for the func defined agent_ent.go // fillAgentServiceEnterpriseMeta is a noop stub for the func defined agent_ent.go
func fillAgentServiceEnterpriseMeta(_ *api.AgentService, _ *structs.EnterpriseMeta) {} func fillAgentServiceEnterpriseMeta(_ *api.AgentService, _ *structs.EnterpriseMeta) {}

View File

@ -188,7 +188,6 @@ type Config struct {
AdvertiseAddrWAN *string `json:"advertise_addr_wan,omitempty" hcl:"advertise_addr_wan" mapstructure:"advertise_addr_wan"` AdvertiseAddrWAN *string `json:"advertise_addr_wan,omitempty" hcl:"advertise_addr_wan" mapstructure:"advertise_addr_wan"`
AdvertiseAddrWANIPv4 *string `json:"advertise_addr_wan_ipv4,omitempty" hcl:"advertise_addr_wan_ipv4" mapstructure:"advertise_addr_wan_ipv4"` AdvertiseAddrWANIPv4 *string `json:"advertise_addr_wan_ipv4,omitempty" hcl:"advertise_addr_wan_ipv4" mapstructure:"advertise_addr_wan_ipv4"`
AdvertiseAddrWANIPv6 *string `json:"advertise_addr_wan_ipv6,omitempty" hcl:"advertise_addr_wan_ipv6" mapstructure:"advertise_addr_ipv6"` AdvertiseAddrWANIPv6 *string `json:"advertise_addr_wan_ipv6,omitempty" hcl:"advertise_addr_wan_ipv6" mapstructure:"advertise_addr_ipv6"`
Audit Audit `json:"audit,omitempty" hcl:"audit" mapstructure:"audit"`
Autopilot Autopilot `json:"autopilot,omitempty" hcl:"autopilot" mapstructure:"autopilot"` Autopilot Autopilot `json:"autopilot,omitempty" hcl:"autopilot" mapstructure:"autopilot"`
BindAddr *string `json:"bind_addr,omitempty" hcl:"bind_addr" mapstructure:"bind_addr"` BindAddr *string `json:"bind_addr,omitempty" hcl:"bind_addr" mapstructure:"bind_addr"`
Bootstrap *bool `json:"bootstrap,omitempty" hcl:"bootstrap" mapstructure:"bootstrap"` Bootstrap *bool `json:"bootstrap,omitempty" hcl:"bootstrap" mapstructure:"bootstrap"`
@ -317,6 +316,9 @@ type Config struct {
SyncCoordinateRateTarget *float64 `json:"sync_coordinate_rate_target,omitempty" hcl:"sync_coordinate_rate_target" mapstructure:"sync_coordinate_rate_target"` SyncCoordinateRateTarget *float64 `json:"sync_coordinate_rate_target,omitempty" hcl:"sync_coordinate_rate_target" mapstructure:"sync_coordinate_rate_target"`
Version *string `json:"version,omitempty" hcl:"version" mapstructure:"version"` Version *string `json:"version,omitempty" hcl:"version" mapstructure:"version"`
VersionPrerelease *string `json:"version_prerelease,omitempty" hcl:"version_prerelease" mapstructure:"version_prerelease"` VersionPrerelease *string `json:"version_prerelease,omitempty" hcl:"version_prerelease" mapstructure:"version_prerelease"`
// enterpriseConfig embeds fields that we only access in consul-enterprise builds
EnterpriseConfig `hcl:",squash" mapstructure:",squash"`
} }
type GossipLANConfig struct { type GossipLANConfig struct {
@ -368,24 +370,6 @@ type AdvertiseAddrsConfig struct {
SerfWAN *string `json:"serf_wan,omitempty" hcl:"serf_wan" mapstructure:"serf_wan"` SerfWAN *string `json:"serf_wan,omitempty" hcl:"serf_wan" mapstructure:"serf_wan"`
} }
// AuditSink can be provided multiple times to define pipelines for auditing
type AuditSink struct {
Name *string `json:"name,omitempty" hcl:"name" mapstructure:"name"`
Type *string `json:"type,omitempty" hcl:"type" mapstructure:"type"`
Format *string `json:"format,omitempty" hcl:"format" mapstructure:"format"`
Path *string `json:"path,omitempty" hcl:"path" mapstructure:"path"`
DeliveryGuarantee *string `json:"delivery_guarantee,omitempty" hcl:"delivery_guarantee" mapstructure:"delivery_guarantee"`
RotateBytes *int `json:"rotate_bytes,omitempty" hcl:"rotate_bytes" mapstructure:"rotate_bytes"`
RotateDuration *string `json:"rotate_duration,omitempty" hcl:"rotate_duration" mapstructure:"rotate_duration"`
RotateMaxFiles *int `json:"rotate_max_files,omitempty" hcl:"rotate_max_files" mapstructure:"rotate_max_files"`
}
// Audit allows us to enable and define destinations for auditing
type Audit struct {
Enabled *bool `json:"enabled,omitempty" hcl:"enabled" mapstructure:"enabled"`
Sinks map[string]AuditSink `json:"sink,omitempty" hcl:"sink" mapstructure:"sink"`
}
type Autopilot struct { type Autopilot struct {
CleanupDeadServers *bool `json:"cleanup_dead_servers,omitempty" hcl:"cleanup_dead_servers" mapstructure:"cleanup_dead_servers"` CleanupDeadServers *bool `json:"cleanup_dead_servers,omitempty" hcl:"cleanup_dead_servers" mapstructure:"cleanup_dead_servers"`
DisableUpgradeMigration *bool `json:"disable_upgrade_migration,omitempty" hcl:"disable_upgrade_migration" mapstructure:"disable_upgrade_migration"` DisableUpgradeMigration *bool `json:"disable_upgrade_migration,omitempty" hcl:"disable_upgrade_migration" mapstructure:"disable_upgrade_migration"`

View File

@ -4,6 +4,9 @@ package config
import "github.com/hashicorp/consul/agent/structs" import "github.com/hashicorp/consul/agent/structs"
// EnterpriseMeta provides a stub for the corresponding struct in config_ent.go
type EnterpriseConfig struct{}
// EnterpriseMeta stub // EnterpriseMeta stub
type EnterpriseMeta struct{} type EnterpriseMeta struct{}

View File

@ -3884,20 +3884,6 @@ func TestFullConfig(t *testing.T) {
}, },
"advertise_addr": "17.99.29.16", "advertise_addr": "17.99.29.16",
"advertise_addr_wan": "78.63.37.19", "advertise_addr_wan": "78.63.37.19",
"audit": {
"enabled": true,
"sink": {
"test": {
"type": "file",
"format": "json",
"delivery_guarantee": "best-effort",
"path": "/test/path",
"rotate_bytes": 0,
"rotate_max_files": 0,
"rotate_duration": "0"
}
}
},
"autopilot": { "autopilot": {
"cleanup_dead_servers": true, "cleanup_dead_servers": true,
"disable_upgrade_migration": true, "disable_upgrade_migration": true,
@ -4529,18 +4515,6 @@ func TestFullConfig(t *testing.T) {
} }
advertise_addr = "17.99.29.16" advertise_addr = "17.99.29.16"
advertise_addr_wan = "78.63.37.19" advertise_addr_wan = "78.63.37.19"
audit {
enabled = true
sink "test" {
type = "file"
format = "json"
delivery_guarantee = "best-effort"
path = "/test/path"
rotate_bytes = 0
rotate_max_files = 0
rotate_duration = "0"
}
}
autopilot = { autopilot = {
cleanup_dead_servers = true cleanup_dead_servers = true
disable_upgrade_migration = true disable_upgrade_migration = true