-
Notifications
You must be signed in to change notification settings - Fork 166
Adds a template to generate modular input and use it in a golang runner #6132
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
Conversation
e71a1c2
to
a9ae62d
Compare
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 it is looking good, will do a more detailed review once it is out of draft. It should have a CI workflow running the tests.
packaging/technical-addon/go.mod
Outdated
@@ -0,0 +1,17 @@ | |||
module github.com/splunk/otel-technical-addon |
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 not sure if the prefix otel-
belongs 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.
Fair enough, just technical-addon
? Maybe splunk-technical-addon
?
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.
replace with splunk-technical-addon
@@ -0,0 +1,120 @@ | |||
package modularinput |
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.
nit: files are missing headers with license - isn't this being flagged by addlicense tool? I'm pretty sure we have this in the repo...
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.
Huh, it's not in the paths returned via
go list -f '{{ .Dir }}' ./...
, which at least for me only returns results in cmd
and internal
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.
Our addlicense misses anything in
pkg
packaging
examples
tests
Maybe we should make fixing this a different issue? I'll manually add licenses to these new files for now
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.
Fixed it locally at least
"path/filepath" | ||
) | ||
|
||
func PackageAddon(sourceDir, outputFile string) error { |
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 this is not being used right now... anyway, why do you think this needs to be implemented directly? Portability?
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.
So far it's just for testing, don't think it was used in this review
I was debating not using it for testing and instead having the "build all addons" target using golang to package instead of shell, but not sure. In general all addons would want some way to package an addon for testing, as you need to zip it up to pass an app into a splunk docker container for purposes of installation testing.
Currently, in our shell tests, we have a "repackage" function that takes in the default artifact we vend, extracts it, makes some changes to inputs.conf etc, then repackages it, and passes that to orca or docker. I could see this as a reusable component to do the repackaging part of that process.
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.
The advantage of having this in golang would be portability: no dependency on what your machine has installed or compatibility with specific tools, e.g.: IRCC tar
on mac as a different set of parameters them the one on the GH runners.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6132 +/- ##
==========================================
+ Coverage 36.29% 44.45% +8.16%
==========================================
Files 381 390 +9
Lines 26751 27014 +263
==========================================
+ Hits 9710 12010 +2300
+ Misses 16087 14161 -1926
+ Partials 954 843 -111 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
94faf3d
to
f2fb552
Compare
6016462
to
211b9b0
Compare
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, more Qs than suggestions.
SOURCE_DIR?=$(dir $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
BUILD_DIR?=$(git rev-parse --show-toplevel) |
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.
nit: these two are already defined in Makefile.Common
@@ -11,7 +13,7 @@ GIT_SHA=$(shell git rev-parse --short HEAD) | |||
GOARCH=$(shell go env GOARCH) | |||
GOOS=$(shell go env GOOS) | |||
|
|||
FIND_MOD_ARGS=-type f -name "go.mod" | |||
FIND_MOD_ARGS=-type f -name "go.mod" -not -path "./packaging/technical-addon/*" |
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.
Q.: any specific reason to exclude it? I mean does it break something? It make sense since it is not shipped, but, I'm curious if there is any other reason for that.
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 is also defined in Makefile.Common
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.
The addon has some build dependencies which would break a few build targets (ex gotest-ith-codecov
)
Honestly, this was rage-building to fix errors, I'll see if I can clean it up. Maybe my Makefile variables aren't consistent across the files?
... Will clean up in a separate PR if that's okay though
func generateTaModInputConfs(config *modularinput.TemplateData, addonSourceDir string, outDir string) error { | ||
// handle README/inputs.conf.spec | ||
specTemplatePath := filepath.Join(addonSourceDir, "assets", "inputs.conf.spec.tmpl") | ||
if _, err := os.Stat(specTemplatePath); os.IsNotExist(err) { |
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.
Q.: just curious: do you know if os.Stat
works on Windows? Not a problem if doesn't: it should work under Git Bash anyway.
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.
Given that the generator only needs to run on Linux (this is a build tool, would not touch a customer machine), I'm not sure how much it'd matter.
I think we're only going to build the stuff on linux, at least... testing the generated TA binaries would be done on windows yes, but most of our addons are cross platform anyway and thus should probably be built on a single platform before being tested on others.
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.
But yes, for windows developers, git bash should work
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.
looks like it'd work in windows as well
"path/filepath" | ||
) | ||
|
||
func PackageAddon(sourceDir, outputFile string) error { |
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.
The advantage of having this in golang would be portability: no dependency on what your machine has installed or compatibility with specific tools, e.g.: IRCC tar
on mac as a different set of parameters them the one on the GH runners.
We've been talking about doing this for a while. This expands on Paulo's work getting an XML reader for modular input and go binary for running the addon instead of the .cmd and .sh files we've historically used.
One of the most common frustrations we've seen is the duplicative logic between windows and linux that was necessary when using .cmd and .sh. As we're now supporting three addons, and looking to potentially introduce flavors, this isn't tenable in the future. It currently requires duplicative testing between windows and linux. Given we can only currently test windows using splunk internal provisioning, this also makes development super annoying since we can only test linux with splunk-docker.
Writing the addon in golang allows us to reuse almost all of the same logic between windows and linux, allows us to use gotest on some of that logic, and given the significantly increased shared logic, we can be more confident that windows will work when running docker tests.