-
Notifications
You must be signed in to change notification settings - Fork 118
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
Support flat and extended manifest files #130
Support flat and extended manifest files #130
Conversation
// manifest file. | ||
type VarValue struct { | ||
scalar string | ||
list []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why you removed VarValue
and replaced it with the broader interface{}
type. AFAICT the only types of values allowed for input configuration variables are scalars (int, string, boolean, etc.) or lists of scalars. We don't support maps/dicts. That was the intent behind creating a stricter VarValue
type that codified these rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because of ucfg which (I suppose) doesn't support UnmarshalYAML and MarshalJSON methods. It seemed to me that the codebase would be smaller, although I'm aware of the risk you brought here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you keep VarValue
and make it implement https://godoc.org/github.com/elastic/go-ucfg#ConfigUnpacker somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try to do this, although I'm not convinced it will work (didn't see this earlier).
I see the benefits of having stricter VarValue
type, so if you prefer I can switch back from ucfg
to our implementation and extend it with same trick for expanding config map keys as in package-spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I appreciate you giving it a try. There are a few examples of implementing ConfigUnpacker
in the Beats repo. You can find them in your IDE with this regex: func \(.* Unpack\(.*Config
.
If you succeed, it would allow us to preserve the strictness of what a variable value can be, which is very nice.
If it doesn't work, let's stick with ucfg
and reduce the strictness of what a variable value can be by replacing VarValue
with interface{}
. I think that's the better tradeoff than implementing some trick to parse flat values with the yaml
package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I got it fixed. Let's see what CI will say.
internal/packages/packages.go
Outdated
type Variable struct { | ||
Name string `config:"name" json:"name" yaml:"name"` | ||
Type string `config:"type" json:"type" yaml:"type"` | ||
Default interface{} `config:"default" json:"default" yaml:"default"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we're introducing the config
struct tags for ucfg
's benefit, do we still need to keep the yaml
struct tags?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right, although I have to check whether we don't call yaml.Marshal
somewhere...
type policyTemplate struct { | ||
Inputs []input `json:"inputs"` | ||
// PolicyTemplate is a configuration of inputs responsible for collecting log or metric data. | ||
type PolicyTemplate struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the visibility change needed for ucfg
to work correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's due to consistency. If somebody wants to use Manifest structure and extract policy templates to a separate variable, it wouldn't be possible (can't use a package visible field). In general exposed fields should use public structures.
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. WFG.
Something didn't work here:
I will investigate it tomorrow. |
Ok, I approached the next issue:
|
Ok, it looks that I fixed it finally. VarVariable can be either |
Issue: elastic/package-spec#55
Changes introduced in the PR:
VarValue
(scalar/list) withinterface{}
dataStream
)