Issue with conditionally concatenating arrays

I’d like to have a list of start-dependencies and runtime-dependencies where when a variable flatten-dependencies is provided the dependencies of the module are only start-dependencies. When it is not provided it is start-dependencies and runtime-dependencies concatenated together. I’ve tried several ways of doing this, but haven’t been able to get it working correctly.

In my schema file I have:

    "dependencies": {
      "type": "array",
      "default": []
    },
    "runtime-dependencies": {
      "type": "array",
      "default": []
    },

In my module

    dependencies: ${inputs.dependencies + inputs.runtime-dependencies} # Fails due to 'Invalid template string (${inputs.dependencies + inputs.run…): Both terms need to be either arrays or numbers for + operator (got string and string).'

    dependencies: ${["mysql"] + ["redis"]} # This seems to work. As long as the lists are not variables.

    dependencies: ${inputs.dependencies} # dependencies is a list so this works.

inputs.dependencies and inputs.runtime-dependencies should both be arrays not strings so I’m not sure whats going on here.

Hi John,

Welcome to the community. Just to let you know we are sunsetting Discourse in a little under a month in favor of Discord.

Your working examples concatenates two arrays. I believe what’s happening in your desired example is your arrays containing strings are converted to just strings and garden does not at this time support concatenating strings though it’s something we’d like to see added.

That would explain why concatenating your two arrays each containing a string works.

String concatenation will soon be supported! See Is there a way to do string concatenation in variable interpolation - #3 by vvagaytsev