Embed templates inside dd agent binary#4782
Conversation
9448008 to
f3c70d2
Compare
Codecov Report
@@ Coverage Diff @@
## master #4782 +/- ##
==========================================
+ Coverage 52.32% 52.39% +0.06%
==========================================
Files 709 709
Lines 51004 50947 -57
==========================================
+ Hits 26689 26692 +3
+ Misses 22735 22676 -59
+ Partials 1580 1579 -1
Continue to review full report at Codecov.
|
It relies on go-bindata and a go:generate statement to create a go file out of the template files so they are not required anymore at runtime.
f3c70d2 to
1396e4e
Compare
truthbk
left a comment
There was a problem hiding this comment.
This looks very clean to me! Just a comment on the go-bindata tool we'll be using: we should pin it.
| ns.add_task(audit_tag_impact) | ||
| ns.add_task(e2e_tests) | ||
| ns.add_task(make_kitchen_gitlab_yml) | ||
| ns.add_task(generate) |
There was a problem hiding this comment.
I was wondering if agent:generate wasn't a better invoke target, but I realized, also from your changes, that generate may be required by other tasks in the main collection too, so I guess putting it here is the sensible thing to do.
| ctx.run("rm -rf ./vendor") | ||
|
|
||
| @task | ||
| def generate(ctx): |
There was a problem hiding this comment.
Nit for later: the name feels a bit too generic for what this function does: for instance, it's difficult to understand without going into the specifics of the function that the:
def build(...):
...
# Generate go source from template
generate(ctx)
...line in tasks/agent.py means we apply go generate on ./pkg/status.
Moreover, we use go generate in some other places (such as tasks/cluster_agent.py:
datadog-agent/tasks/cluster_agent.py
Lines 66 to 67 in 527af5e
tasks/dogstatsd.py: datadog-agent/tasks/dogstatsd.py
Lines 95 to 96 in 527af5e
tasks/trace_agent.py: datadog-agent/tasks/trace_agent.py
Lines 75 to 76 in 527af5e
I'd either:
- Not change anything, but show explicitly that this function renders only what's specified in
GO_GENERATE_TARGETS(eg. by adding a comment around its invocation intasks/agent.pyandtasks/cluster_agent.py) so that someone reading the build tasks understands what's happening without having to read the internal function's behavior), - Make this function more generic by accepting a list of targets (and maybe a list of options if needed)
There was a problem hiding this comment.
I agree that it will make sense at some point to write a full-featured wrapper for go generate. In-between I took option #1 and added more meaningful comments.
Co-Authored-By: Cedric Lamoriniere <cedric.lamoriniere@datadoghq.com>
|
I wonder if we could also do this for the html files we use in the |
|
IMHO that would worth trying but in the meantime we have a windows issue likely related to this change. I will try to follow up on that topic. |
What does this PR do?
It embeds templates files into the agent binary at compilation time.
Motivation
It makes the agent binary able to run
agent statuswithout requiringto the original template file.
Additional Notes
It relies on go-bindata that has been added to the dependencies.