-
Notifications
You must be signed in to change notification settings - Fork 5k
Refactor and add tests for template and ilm handling. #12065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e6bb393
bc98f7a
0efa03e
530f6e7
b0e027f
679d402
293210a
e746f1c
331aebd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,22 @@ type Alias struct { | |
|
|
||
| // DefaultSupport configures a new default ILM support implementation. | ||
| func DefaultSupport(log *logp.Logger, info beat.Info, config *common.Config) (Supporter, error) { | ||
| cfg := defaultConfig(info) | ||
| if config != nil { | ||
| if err := config.Unpack(&cfg); err != nil { | ||
| return nil, err | ||
| } | ||
| } | ||
|
|
||
| if cfg.Mode == ModeDisabled { | ||
| return NewNoopSupport(info, config) | ||
| } | ||
|
|
||
| return StdSupport(log, info, config) | ||
| } | ||
|
|
||
| // StdSupport configures a new std ILM support implementation. | ||
| func StdSupport(log *logp.Logger, info beat.Info, config *common.Config) (Supporter, error) { | ||
| if log == nil { | ||
| log = logp.NewLogger("ilm") | ||
| } else { | ||
|
|
@@ -83,10 +99,6 @@ func DefaultSupport(log *logp.Logger, info beat.Info, config *common.Config) (Su | |
| } | ||
| } | ||
|
|
||
| if cfg.Mode == ModeDisabled { | ||
| return NoopSupport(info, config) | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Semantic change, bug fix or noop-change? The cfg.Mode is unpacked from the config at the code block right before this check. Does stdSupport act like noopSupport if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noop, the diff is a bit confusing. Basically I only introduce two new public fcts There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this I noticed. But StdSupport can still be disabled via settings. Is it guaranteed to behave like NoopSupport in this case?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No I simply extracted creating the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I noticed that DefaultSupport semantics didn't change. I'm just curious if StdSupport behaves correctly if This turns the Manager interface more into a protocol in a sense of: The other methods MUST NOT be used if Enabled did return false. This is true in the current code base, but only some internal assumption. |
||
|
|
||
| name, err := applyStaticFmtstr(info, &cfg.PolicyName) | ||
| if err != nil { | ||
| return nil, errors.Wrap(err, "failed to read ilm policy name") | ||
|
|
@@ -115,8 +127,13 @@ func DefaultSupport(log *logp.Logger, info beat.Info, config *common.Config) (Su | |
| policy.Body = body | ||
| } | ||
|
|
||
| log.Infof("Policy name: %v", name) | ||
| return NewDefaultSupport(log, cfg.Mode, alias, policy, cfg.Overwrite, cfg.CheckExists), nil | ||
| return NewStdSupport(log, cfg.Mode, alias, policy, cfg.Overwrite, cfg.CheckExists), nil | ||
| } | ||
|
|
||
| // NoopSupport configures a new noop ILM support implementation, | ||
| // should be used when ILM is disabled | ||
| func NoopSupport(_ *logp.Logger, info beat.Info, config *common.Config) (Supporter, error) { | ||
| return NewNoopSupport(info, config) | ||
| } | ||
|
|
||
| func applyStaticFmtstr(info beat.Info, fmt *fmtstr.EventFormatString) (string, error) { | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.