Garden sources requiring to pass all variables
# 🌱|help-and-getting-started
b
Hey there! Got a question; When using
sources
to bring modules from external repositories; I have to repeat all the variables (copy and paste all the vars from one module into the module I'm invoking it from), is it possible to set some sort of inheritance so I don't have to do that? Main problem is that If I'm bringing 3+ services to a parent application I have to add HUNDREDS of variables and keep them in sync between different repos, kind of a nightmare it would be great if I could just inherit all the variables and do overrides only in case I need to. Thanks y'all!
f
Hi @bright-policeman-43626 , there is currently no standardized way of doing this but a workaround is to create an exec action with all the variables. Those can than be referenced by other actions e.g.
Copy code
kind: Run
name: myvars
description: Helper action for storing variables that are used by other API related actions.
type: exec
include: []
# This is required but we're only using it to store variables
# Replace this with `kind: Config` when we support that.
spec:
  command: []

variables:
  env:
    FOO: BAR
    BAZ: FOO
---

...
env:
  $forEach: ${actions.run.myvars.var.env}
  $return:
     name: ${item.key}
     value: ${item.value}
b
So I could bring this variables with remoteSources and everything would be available for my config? That’s a nice hacky way! I will give it a try thanks @freezing-pharmacist-34446
f
Yup that should work. Did you have a chance to try it out yet?
b
Haven't had a chance to try but I will!
2 Views