From 591d5a5e76ca6c8d7f44121195d39fa3e0600bd1 Mon Sep 17 00:00:00 2001 From: Andrew Stucki Date: Thu, 12 Nov 2020 07:28:45 -0500 Subject: [PATCH] Rename XPack to ElasticLicensed --- libbeat/beat/info.go | 16 ++++---- libbeat/cmd/instance/beat.go | 24 ++++++------ libbeat/cmd/instance/settings.go | 2 +- libbeat/cmd/setup.go | 2 +- libbeat/cmd/test/config.go | 2 +- libbeat/cmd/version.go | 2 +- libbeat/template/load.go | 2 +- libbeat/template/processor.go | 8 ++-- libbeat/template/processor_test.go | 4 +- libbeat/template/template.go | 48 +++++++++++------------ libbeat/tests/system/template/template.go | 8 ++-- x-pack/auditbeat/cmd/root.go | 2 +- x-pack/filebeat/cmd/root.go | 2 +- x-pack/functionbeat/manager/cmd/root.go | 2 +- x-pack/heartbeat/cmd/root.go | 2 +- x-pack/journalbeat/cmd/root.go | 2 +- x-pack/metricbeat/cmd/root.go | 8 ++-- x-pack/packetbeat/cmd/root.go | 2 +- x-pack/winlogbeat/cmd/root.go | 2 +- 19 files changed, 70 insertions(+), 70 deletions(-) diff --git a/libbeat/beat/info.go b/libbeat/beat/info.go index cceac8932ac..c808ba214ea 100644 --- a/libbeat/beat/info.go +++ b/libbeat/beat/info.go @@ -21,14 +21,14 @@ import "github.com/gofrs/uuid" // Info stores a beats instance meta data. type Info struct { - Beat string // The actual beat's name - IndexPrefix string // The beat's index prefix in Elasticsearch. - Version string // The beat version. Defaults to the libbeat version when an implementation does not set a version - XPack bool // Whether the beat is licensed under xpack - Name string // configured beat name - Hostname string // hostname - ID uuid.UUID // ID assigned to beat machine - EphemeralID uuid.UUID // ID assigned to beat process invocation (PID) + Beat string // The actual beat's name + IndexPrefix string // The beat's index prefix in Elasticsearch. + Version string // The beat version. Defaults to the libbeat version when an implementation does not set a version + ElasticLicensed bool // Whether the beat is licensed under and Elastic License + Name string // configured beat name + Hostname string // hostname + ID uuid.UUID // ID assigned to beat machine + EphemeralID uuid.UUID // ID assigned to beat process invocation (PID) // Monitoring-related fields Monitoring struct { diff --git a/libbeat/cmd/instance/beat.go b/libbeat/cmd/instance/beat.go index 5b20cc27eee..b873ddebf95 100644 --- a/libbeat/cmd/instance/beat.go +++ b/libbeat/cmd/instance/beat.go @@ -156,7 +156,7 @@ func Run(settings Settings, bt beat.Creator) error { name := settings.Name idxPrefix := settings.IndexPrefix version := settings.Version - xpack := settings.XPack + elasticLicensed := settings.ElasticLicensed return handleError(func() error { defer func() { @@ -165,7 +165,7 @@ func Run(settings Settings, bt beat.Creator) error { "panic", r, zap.Stack("stack")) } }() - b, err := NewBeat(name, idxPrefix, version, xpack) + b, err := NewBeat(name, idxPrefix, version, elasticLicensed) if err != nil { return err } @@ -192,7 +192,7 @@ func Run(settings Settings, bt beat.Creator) error { // NewInitializedBeat creates a new beat where all information and initialization is derived from settings func NewInitializedBeat(settings Settings) (*Beat, error) { - b, err := NewBeat(settings.Name, settings.IndexPrefix, settings.Version, settings.XPack) + b, err := NewBeat(settings.Name, settings.IndexPrefix, settings.Version, settings.ElasticLicensed) if err != nil { return nil, err } @@ -203,7 +203,7 @@ func NewInitializedBeat(settings Settings) (*Beat, error) { } // NewBeat creates a new beat instance -func NewBeat(name, indexPrefix, v string, xpack bool) (*Beat, error) { +func NewBeat(name, indexPrefix, v string, elasticLicensed bool) (*Beat, error) { if v == "" { v = version.GetDefaultVersion() } @@ -228,14 +228,14 @@ func NewBeat(name, indexPrefix, v string, xpack bool) (*Beat, error) { b := beat.Beat{ Info: beat.Info{ - Beat: name, - XPack: xpack, - IndexPrefix: indexPrefix, - Version: v, - Name: hostname, - Hostname: hostname, - ID: id, - EphemeralID: ephemeralID, + Beat: name, + ElasticLicensed: elasticLicensed, + IndexPrefix: indexPrefix, + Version: v, + Name: hostname, + Hostname: hostname, + ID: id, + EphemeralID: ephemeralID, }, Fields: fields, } diff --git a/libbeat/cmd/instance/settings.go b/libbeat/cmd/instance/settings.go index 1322339d4c1..3d64ccc1fa1 100644 --- a/libbeat/cmd/instance/settings.go +++ b/libbeat/cmd/instance/settings.go @@ -33,7 +33,7 @@ type Settings struct { IndexPrefix string Version string HasDashboards bool - XPack bool + ElasticLicensed bool Monitoring report.Settings RunFlags *pflag.FlagSet ConfigOverrides []cfgfile.ConditionalOverride diff --git a/libbeat/cmd/setup.go b/libbeat/cmd/setup.go index a1fcce6108d..711ddfd027c 100644 --- a/libbeat/cmd/setup.go +++ b/libbeat/cmd/setup.go @@ -58,7 +58,7 @@ func genSetupCmd(settings instance.Settings, beatCreator beat.Creator) *cobra.Co * ILM policy (for Elasticsearch 6.5 and newer). `, Run: func(cmd *cobra.Command, args []string) { - beat, err := instance.NewBeat(settings.Name, settings.IndexPrefix, settings.Version, settings.XPack) + beat, err := instance.NewBeat(settings.Name, settings.IndexPrefix, settings.Version, settings.ElasticLicensed) if err != nil { fmt.Fprintf(os.Stderr, "Error initializing beat: %s\n", err) os.Exit(1) diff --git a/libbeat/cmd/test/config.go b/libbeat/cmd/test/config.go index 25822cf8bc8..7e93a618c56 100644 --- a/libbeat/cmd/test/config.go +++ b/libbeat/cmd/test/config.go @@ -32,7 +32,7 @@ func GenTestConfigCmd(settings instance.Settings, beatCreator beat.Creator) *cob Use: "config", Short: "Test configuration settings", Run: func(cmd *cobra.Command, args []string) { - b, err := instance.NewBeat(settings.Name, settings.IndexPrefix, settings.Version, settings.XPack) + b, err := instance.NewBeat(settings.Name, settings.IndexPrefix, settings.Version, settings.ElasticLicensed) if err != nil { fmt.Fprintf(os.Stderr, "Error initializing beat: %s\n", err) os.Exit(1) diff --git a/libbeat/cmd/version.go b/libbeat/cmd/version.go index 85244a8690a..243c9e04c02 100644 --- a/libbeat/cmd/version.go +++ b/libbeat/cmd/version.go @@ -35,7 +35,7 @@ func GenVersionCmd(settings instance.Settings) *cobra.Command { Short: "Show current version info", Run: cli.RunWith( func(_ *cobra.Command, args []string) error { - beat, err := instance.NewBeat(settings.Name, settings.IndexPrefix, settings.Version, settings.XPack) + beat, err := instance.NewBeat(settings.Name, settings.IndexPrefix, settings.Version, settings.ElasticLicensed) if err != nil { return fmt.Errorf("error initializing beat: %s", err) } diff --git a/libbeat/template/load.go b/libbeat/template/load.go index a97e88d9be5..054869998d7 100644 --- a/libbeat/template/load.go +++ b/libbeat/template/load.go @@ -183,7 +183,7 @@ func (b *templateBuilder) template(config TemplateConfig, info beat.Info, esVers b.log.Info("template config not enabled") return nil, nil } - tmpl, err := New(info.Version, info.IndexPrefix, info.XPack, esVersion, config, migration) + tmpl, err := New(info.Version, info.IndexPrefix, info.ElasticLicensed, esVersion, config, migration) if err != nil { return nil, fmt.Errorf("error creating template instance: %v", err) } diff --git a/libbeat/template/processor.go b/libbeat/template/processor.go index 7dda7503810..78decd086fd 100644 --- a/libbeat/template/processor.go +++ b/libbeat/template/processor.go @@ -28,9 +28,9 @@ import ( // Processor struct to process fields to template type Processor struct { - EsVersion common.Version - Migration bool - XPack bool + EsVersion common.Version + Migration bool + ElasticLicensed bool } var ( @@ -76,7 +76,7 @@ func (p *Processor) Process(fields mapping.Fields, state *fieldState, output com indexMapping = p.text(&field) case "wildcard": noWildcards := p.EsVersion.LessThan(common.MustNewVersion("7.9.0")) - if !p.XPack || noWildcards { + if !p.ElasticLicensed || noWildcards { indexMapping = p.keyword(&field) } else { indexMapping = p.wildcard(&field) diff --git a/libbeat/template/processor_test.go b/libbeat/template/processor_test.go index 4e0bdb1d088..78a1588532e 100644 --- a/libbeat/template/processor_test.go +++ b/libbeat/template/processor_test.go @@ -740,7 +740,7 @@ func TestProcessWildcardElastic(t *testing.T) { t.Fatal(err) } - p := Processor{EsVersion: *version, XPack: true} + p := Processor{EsVersion: *version, ElasticLicensed: true} err = p.Process(fields, nil, output) if err != nil { t.Fatal(err) @@ -782,7 +782,7 @@ func TestProcessWildcardPreSupport(t *testing.T) { t.Fatal(err) } - p := Processor{EsVersion: *version, XPack: true} + p := Processor{EsVersion: *version, ElasticLicensed: true} err = p.Process(fields, nil, output) if err != nil { t.Fatal(err) diff --git a/libbeat/template/template.go b/libbeat/template/template.go index 16864eaaee0..0fbfa30ccab 100644 --- a/libbeat/template/template.go +++ b/libbeat/template/template.go @@ -46,24 +46,24 @@ var ( // Template holds information for the ES template. type Template struct { sync.Mutex - name string - pattern string - xpack bool - beatVersion common.Version - beatName string - esVersion common.Version - config TemplateConfig - migration bool - templateType IndexTemplateType - order int - priority int + name string + pattern string + elasticLicensed bool + beatVersion common.Version + beatName string + esVersion common.Version + config TemplateConfig + migration bool + templateType IndexTemplateType + order int + priority int } // New creates a new template instance func New( beatVersion string, beatName string, - xpack bool, + elasticLicensed bool, esVersion common.Version, config TemplateConfig, migration bool, @@ -127,17 +127,17 @@ func New( } return &Template{ - pattern: pattern, - name: name, - xpack: xpack, - beatVersion: *bV, - esVersion: esVersion, - beatName: beatName, - config: config, - migration: migration, - templateType: config.Type, - order: config.Order, - priority: config.Priority, + pattern: pattern, + name: name, + elasticLicensed: elasticLicensed, + beatVersion: *bV, + esVersion: esVersion, + beatName: beatName, + config: config, + migration: migration, + templateType: config.Type, + order: config.Order, + priority: config.Priority, }, nil } @@ -160,7 +160,7 @@ func (t *Template) load(fields mapping.Fields) (common.MapStr, error) { // Start processing at the root properties := common.MapStr{} - processor := Processor{EsVersion: t.esVersion, XPack: t.xpack, Migration: t.migration} + processor := Processor{EsVersion: t.esVersion, ElasticLicensed: t.elasticLicensed, Migration: t.migration} if err := processor.Process(fields, nil, properties); err != nil { return nil, err } diff --git a/libbeat/tests/system/template/template.go b/libbeat/tests/system/template/template.go index f6e2fe72b7f..09c9e0dcb19 100644 --- a/libbeat/tests/system/template/template.go +++ b/libbeat/tests/system/template/template.go @@ -33,13 +33,13 @@ import ( const MaxDefaultFieldLength = 1000 // TestTemplate executes tests on the Beat's index template. -func TestTemplate(t *testing.T, beatName string, xpack bool) { - t.Run("default_field length", testTemplateDefaultFieldLength(beatName, xpack)) +func TestTemplate(t *testing.T, beatName string, elasticLicensed bool) { + t.Run("default_field length", testTemplateDefaultFieldLength(beatName, elasticLicensed)) } // testTemplateDefaultFieldLength constructs a template based on the embedded // fields.yml data verifies that the length is less than 1000. -func testTemplateDefaultFieldLength(beatName string, xpack bool) func(*testing.T) { +func testTemplateDefaultFieldLength(beatName string, elasticLicensed bool) func(*testing.T) { return func(t *testing.T) { // 7.0 is when default_field was introduced. esVersion, err := common.NewVersion("7.0.0") @@ -48,7 +48,7 @@ func testTemplateDefaultFieldLength(beatName string, xpack bool) func(*testing.T } // Generate a template based on the embedded fields.yml data. - tmpl, err := template.New(version.GetDefaultVersion(), beatName, xpack, *esVersion, template.TemplateConfig{}, false) + tmpl, err := template.New(version.GetDefaultVersion(), beatName, elasticLicensed, *esVersion, template.TemplateConfig{}, false) if err != nil { t.Fatal(err) } diff --git a/x-pack/auditbeat/cmd/root.go b/x-pack/auditbeat/cmd/root.go index 094a24c806e..7e805a92e7d 100644 --- a/x-pack/auditbeat/cmd/root.go +++ b/x-pack/auditbeat/cmd/root.go @@ -21,7 +21,7 @@ var RootCmd *cmd.BeatsRootCmd func init() { settings := auditbeatcmd.AuditbeatSettings() - settings.XPack = true + settings.ElasticLicensed = true RootCmd = auditbeatcmd.Initialize(settings) xpackcmd.AddXPack(RootCmd, auditbeatcmd.Name) } diff --git a/x-pack/filebeat/cmd/root.go b/x-pack/filebeat/cmd/root.go index 9a395cff739..b95a3cb9e96 100644 --- a/x-pack/filebeat/cmd/root.go +++ b/x-pack/filebeat/cmd/root.go @@ -19,7 +19,7 @@ const Name = fbcmd.Name // Filebeat build the beat root command for executing filebeat and it's subcommands. func Filebeat() *cmd.BeatsRootCmd { settings := fbcmd.FilebeatSettings() - settings.XPack = true + settings.ElasticLicensed = true command := fbcmd.Filebeat(inputs.Init, settings) xpackcmd.AddXPack(command, Name) return command diff --git a/x-pack/functionbeat/manager/cmd/root.go b/x-pack/functionbeat/manager/cmd/root.go index 7533fff7810..ca9e8bda81a 100644 --- a/x-pack/functionbeat/manager/cmd/root.go +++ b/x-pack/functionbeat/manager/cmd/root.go @@ -26,7 +26,7 @@ func init() { Name: Name, HasDashboards: false, ConfigOverrides: config.Overrides, - XPack: true, + ElasticLicensed: true, }) RootCmd.RemoveCommand(RootCmd.RunCmd) diff --git a/x-pack/heartbeat/cmd/root.go b/x-pack/heartbeat/cmd/root.go index 1761c039e8e..8e25993bd87 100644 --- a/x-pack/heartbeat/cmd/root.go +++ b/x-pack/heartbeat/cmd/root.go @@ -15,7 +15,7 @@ var RootCmd *cmd.BeatsRootCmd func init() { settings := heartbeatCmd.HeartbeatSettings() - settings.XPack = true + settings.ElasticLicensed = true RootCmd = heartbeatCmd.Initialize(settings) xpackcmd.AddXPack(RootCmd, heartbeatCmd.Name) } diff --git a/x-pack/journalbeat/cmd/root.go b/x-pack/journalbeat/cmd/root.go index 9f8f39fa07b..7d27c7e8fef 100644 --- a/x-pack/journalbeat/cmd/root.go +++ b/x-pack/journalbeat/cmd/root.go @@ -15,7 +15,7 @@ var RootCmd *cmd.BeatsRootCmd func init() { settings := journalbeatCmd.JournalbeatSettings() - settings.XPack = true + settings.ElasticLicensed = true RootCmd = journalbeatCmd.Initialize(settings) xpackcmd.AddXPack(RootCmd, journalbeatCmd.Name) } diff --git a/x-pack/metricbeat/cmd/root.go b/x-pack/metricbeat/cmd/root.go index 5b37a65c19d..6cb0977b181 100644 --- a/x-pack/metricbeat/cmd/root.go +++ b/x-pack/metricbeat/cmd/root.go @@ -34,10 +34,10 @@ func init() { var runFlags = pflag.NewFlagSet(Name, pflag.ExitOnError) runFlags.AddGoFlag(flag.CommandLine.Lookup("system.hostfs")) settings := instance.Settings{ - RunFlags: runFlags, - Name: Name, - HasDashboards: true, - XPack: true, + RunFlags: runFlags, + Name: Name, + HasDashboards: true, + ElasticLicensed: true, } RootCmd = cmd.GenRootCmdWithSettings(beater.DefaultCreator(), settings) RootCmd.AddCommand(cmd.GenModulesCmd(Name, "", mbcmd.BuildModulesManager)) diff --git a/x-pack/packetbeat/cmd/root.go b/x-pack/packetbeat/cmd/root.go index eb525d138c9..e5dd5bb7918 100644 --- a/x-pack/packetbeat/cmd/root.go +++ b/x-pack/packetbeat/cmd/root.go @@ -18,7 +18,7 @@ var RootCmd *cmd.BeatsRootCmd func init() { settings := packetbeatCmd.PacketbeatSettings() - settings.XPack = true + settings.ElasticLicensed = true RootCmd = packetbeatCmd.Initialize(settings) xpackcmd.AddXPack(RootCmd, packetbeatCmd.Name) } diff --git a/x-pack/winlogbeat/cmd/root.go b/x-pack/winlogbeat/cmd/root.go index 2480c958b67..bc6cd4b0afd 100644 --- a/x-pack/winlogbeat/cmd/root.go +++ b/x-pack/winlogbeat/cmd/root.go @@ -21,7 +21,7 @@ var RootCmd *cmd.BeatsRootCmd func init() { settings := winlogbeatCmd.WinlogbeatSettings() - settings.XPack = true + settings.ElasticLicensed = true RootCmd = winlogbeatCmd.Initialize(settings) xpackcmd.AddXPack(RootCmd, winlogbeatCmd.Name) }