feat: Add modify command and pipeline tag generator#3213
feat: Add modify command and pipeline tag generator#3213taylor-swanson merged 3 commits intoelastic:mainfrom
Conversation
⏳ Build in-progress, with failures
Failed CI Steps |
- Add new modify command to provide a facility for making arbitrary changes to packages - Add pipline-tag modifier to generate missing ingest pipeline processor tags - Add yamledit package to provide functions for modifying yaml documents - Add fleetpkg package to provide types and functions for fleet package types and to support modifying package yaml files via yamledit.
71aa787 to
39694da
Compare
README.md
Outdated
|
|
||
| _Context: package_ | ||
|
|
||
| Use this command to apply modifications for a package. |
There was a problem hiding this comment.
could we have some examples of what we can achieve with this command?
| } | ||
|
|
||
| // Manifest is the package manifest. | ||
| type Manifest struct { |
There was a problem hiding this comment.
There are similar structs to this already defined in internal/packages
Could they be used somehow here ?
For instance
elastic-package/internal/packages/packages.go
Line 198 in 1c096f5
There was a problem hiding this comment.
These new types use the goccy yaml package (for AST modifications, among other things), so they would conflict with the existing types that use the older yaml package. I didn't want to switch the existing types as it would be a significantly more intrusive change (potentially breaks any existing unmarshal/marshal behaviors).
There was a problem hiding this comment.
Ok, let's keep it as it is in this PR. Better to avoid those changes now if they could cause breaking changes in the current behaviors 👍
I've just opened a new issue to try to do some kind of refactor eventually if possible #3238
| }, | ||
| } | ||
|
|
||
| cmd.PersistentFlags().StringSliceP("modifiers", "m", nil, "List of modifiers to run, separated by commas") |
There was a problem hiding this comment.
I think that with StringSlice it can be also used multiple times, apart from separated by commas.
There was a problem hiding this comment.
That's my understanding as well.
There's also StringArray, but that doesn't split the arg on commas (useful if the arg has commas, but you don't want to split on those commas).
| } | ||
|
|
||
| // Manifest is the package manifest. | ||
| type Manifest struct { |
There was a problem hiding this comment.
Ok, let's keep it as it is in this PR. Better to avoid those changes now if they could cause breaking changes in the current behaviors 👍
I've just opened a new issue to try to do some kind of refactor eventually if possible #3238
Overview
This PR introduces a new subcommand for elastic-package called
modify. Its role is to provide a facility for making arbitrary modifications to a package. These changes can include things like updating the ECS version, updating the package spec version, generating tags for ingest pipeline processors, applying best practices, and so on. Changes that would be made by the modify command are implemented by "modifiers", which would be chosen when running the modify command. This PR includes one modifier for generating ingest pipeline processor tags (pipeline-tag).Proposal doc: #3158
What's New
New Subcommand
A new subcommand
modifythat provides a facility for making arbitrary changes to a package.Pipeline Tag Modifier
A modifier which generates tags for ingest pipeline processors lacking a tag.
Supporting Packages
internal/fleetpkg: Provides a package for types for fleet integrations, along with functions for loading integrations from the filesystem. Certain types (those directly backed by a yaml file) include a yamledit document for obtaining and modifying the yaml AST, which can be written back out to the file to make changes.internal/yamledit: Provides a package for reading, modifying, and writing YAML ASTs.Related