Hi Fleet team, when will fleet setup env with pref...
# fleet
w
Hi Fleet team, when will fleet setup env with prefix like "FLEET_DANGEROUS_REPLACE_XXX"?
k
He @wennan.he. Are you looking for a template for .env?
w
actually, i found this some where but forgot where exactly probably in the code.
k
I’m sorry, I’m not quite sure what the question is. Can you clarify a little for me?
w
for distribute_read api, i can see the interior logic when loading the detail queries, fleet would check whether any env has prefix "FLEET_DANGEROUS_REPLACE_XXX", if yes, it will push the val of this env into a map, i want to know why?
z
It allows overriding the queries that Fleet sends to collect details about hosts. It's marked "DANGEROUS" because it could cause unexpected behavior and we would not typically recommend configuring it.
k
Thanks @zwass !
w
ok, can i say if we dont set this FLEET_DANGEROUS_REPLACE_XXX env, this snippet of code shown below doesn't have usage right?
Copy code
for _, env := range os.Environ() {
   prefix := "FLEET_DANGEROUS_REPLACE_"
   if !strings.HasPrefix(env, prefix) {
      continue
   }
   if i := strings.Index(env, "="); i >= 0 {
      queryName := strings.ToLower(strings.TrimPrefix(env[:i], prefix))
      newQuery := env[i+1:]
      query := generatedMap[queryName]
      query.Query = newQuery
      generatedMap[queryName] = query
   }
}
z
The for loop will run but the first
if
will always be true and so the code should ultimately have no effect.
l
Hi folks! FYI: We are removing
FLEET_DANGEROUS_REPLACE_XXX
in
v4.26.0
(soon to be released) and adding the following feature instead: https://fleetdm.com/docs/using-fleet/configuration-files#features-detail-query-overrides