Skip to content
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

Clarify SelectedPackageTypes meaning and improve its usage #30142

Merged
merged 1 commit into from
Feb 16, 2022

Conversation

AndersonQ
Copy link
Member

@AndersonQ AndersonQ commented Feb 1, 2022

  • document SelectedPackageTypes meaning
  • simplify isPackageTypeSelected

What does this PR do?

It documents the meaning of devtools.SelectedPackageTypes and simplify the implementation of isPackageTypeSelected accordingly.

Why is it important?

The current implementation of isPackageTypeSelected is unclear and threats an empty slice and nil slice differently whereas they should be equivalent.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

How to test this PR locally

Build the beats ot the elastic-agent, it should preserve the current behaviour.

- document SelectedPackageTypes meaning
- simplify isPackageTypeSelected
@AndersonQ AndersonQ added v8.0.0 cleanup backport-skip Skip notification from the automated backport with mergify Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team labels Feb 1, 2022
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Feb 1, 2022

for _, t := range SelectedPackageTypes {
if t == pkgType {
return true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly related to this change.
But the name of the function isPackageTypeSelected and the behavior of this method looks reversed to me.
It returns true when SelectedPackageTypes is nil or slice is empty?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it does. However from what I could understand, an empty/nil SelectedPackageTypes means, the environment variable PACKAGES isn't defined, therefore all package types are selected. Thus the function returning true when SelectedPackageTypes is either nil or empty.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's is counter intuitive, so I added the docs here and on the SelectedPackageTypes as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, agree, my brain did not compute correctly the func name, thanks for adding clarification.

@elasticmachine
Copy link
Collaborator

elasticmachine commented Feb 1, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-02-14T09:42:48.311+0000

  • Duration: 115 min 47 sec

Test stats 🧪

Test Results
Failed 0
Passed 48220
Skipped 4415
Total 52635

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@AndersonQ AndersonQ marked this pull request as ready for review February 2, 2022 11:07
@AndersonQ AndersonQ requested a review from a team as a code owner February 2, 2022 11:07
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@ph
Copy link
Contributor

ph commented Feb 3, 2022

/package

Copy link
Contributor

@ph ph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change look good, I've started the "packaging" test and will approve when green.

@ph ph added backport-v8.2.0 Automated backport with mergify and removed v8.0.0 backport-skip Skip notification from the automated backport with mergify labels Feb 10, 2022
@ph
Copy link
Contributor

ph commented Feb 10, 2022

LGTM

@AndersonQ
Copy link
Member Author

/test

1 similar comment
@AndersonQ
Copy link
Member Author

/test

@AndersonQ
Copy link
Member Author

/package

@AndersonQ AndersonQ merged commit 18f1e2b into main Feb 16, 2022
@AndersonQ AndersonQ deleted the simplify-isPackageTypeSelected branch February 16, 2022 15:31
v1v added a commit to v1v/beats that referenced this pull request Feb 21, 2022
…nd-k8s-env

* upstream/main:
  fix typos and improve sentences (elastic#30432)
  Add drop and explicit tests to avoid duplicate ingest of elasticsearch logs (elastic#30440)
  {,x-pack/}auditbeat: replace uses of github.com/pkg/errors with stdlib equivalents (elastic#30321)
  Spelling fix (elastic#30439)
  packetbeat/beater: make sure Npcap installation runs before interfaces are needed in all cases (elastic#30438)
  Add BC about Homebrew no longer being available in 8.0 (elastic#30419)
  Install gawk as a replacement for mawk in Docker containers. (elastic#30452)
  Clean up python-related system tests (elastic#30415)
  Fix TestNewModuleRegistry flakiness (elastic#30453)
  [Filebeat] [auditd]: Support EXECVE events with truncated argument list (elastic#30382)
  Set `log.offset` to the start of the reported line in filestream (elastic#30445)
  clarify SelectedPackageTypes meaning and improve its usage (elastic#30142)
  [elasticsearch module] serialize shards properties (elastic#30408)
  Add docs about hints and templates autodiscovery priority (elastic#30343)
v1v added a commit to v1v/beats that referenced this pull request Feb 22, 2022
…ckaging-docker

* upstream/main: (26 commits)
  Update docker/distribution to 2.8.0 (elastic#30462)
  Add `parsers` examples to `filestream` reference configuration (elastic#30529)
  extend documentation about setting orchestrator.cluster fields (elastic#30518)
  Forward-port 8.0.1 changelog to main (elastic#30522)
  Switch skip to use `CI` (elastic#30512)
  packetbeat/beater: don't attempt to install npcap when already installed (elastic#30509)
  Fix Docker module: rename fields on dashboards (elastic#30500)
  fix typos and improve sentences (elastic#30432)
  Add drop and explicit tests to avoid duplicate ingest of elasticsearch logs (elastic#30440)
  {,x-pack/}auditbeat: replace uses of github.com/pkg/errors with stdlib equivalents (elastic#30321)
  Spelling fix (elastic#30439)
  packetbeat/beater: make sure Npcap installation runs before interfaces are needed in all cases (elastic#30438)
  Add BC about Homebrew no longer being available in 8.0 (elastic#30419)
  Install gawk as a replacement for mawk in Docker containers. (elastic#30452)
  Clean up python-related system tests (elastic#30415)
  Fix TestNewModuleRegistry flakiness (elastic#30453)
  [Filebeat] [auditd]: Support EXECVE events with truncated argument list (elastic#30382)
  Set `log.offset` to the start of the reported line in filestream (elastic#30445)
  clarify SelectedPackageTypes meaning and improve its usage (elastic#30142)
  [elasticsearch module] serialize shards properties (elastic#30408)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.2.0 Automated backport with mergify cleanup Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants