Skip to content

Commit

Permalink
Rename XPack to ElasticLicensed
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Stucki committed Nov 12, 2020
1 parent 165004c commit 591d5a5
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 70 deletions.
16 changes: 8 additions & 8 deletions libbeat/beat/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 12 additions & 12 deletions libbeat/cmd/instance/beat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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()
}
Expand All @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion libbeat/cmd/instance/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libbeat/cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion libbeat/cmd/test/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion libbeat/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion libbeat/template/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions libbeat/template/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions libbeat/template/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
48 changes: 24 additions & 24 deletions libbeat/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions libbeat/tests/system/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/auditbeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion x-pack/filebeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x-pack/functionbeat/manager/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func init() {
Name: Name,
HasDashboards: false,
ConfigOverrides: config.Overrides,
XPack: true,
ElasticLicensed: true,
})

RootCmd.RemoveCommand(RootCmd.RunCmd)
Expand Down
2 changes: 1 addition & 1 deletion x-pack/heartbeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion x-pack/journalbeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
8 changes: 4 additions & 4 deletions x-pack/metricbeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion x-pack/packetbeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion x-pack/winlogbeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 591d5a5

Please sign in to comment.