allow variables to be optional without a default value
currently variable needs to be either provided a default value or made required in spin.toml. I would like to keep my default value in code near to where it is actually used. one of the reason I want to store my default values in code is because my project can run as a independent service or as a spin app and I don't want to duplicate the default values in two places.
I wanted to hear if that is something we may consider to relax or are there other reasons that we recommend configuring the default value in spin.toml?
fwiw, for now I workaround this by specifying the default value as empty string and check for empty value in my code.
I think the philosophy behind this is that it should be statically determinable which variables are available to a component - the ultimate goal at one point being for variables to be component model "value imports" (effectively each variable becoming a variable or function in the import bindings). It does make sense that a developer should be able to say "the type of this value import is option<...>", but this should be an explicit choice not an "I forgot to set it." I guess the way to replicate this in Spin would be an explicit allow_unset field or something like that.
For now, though, you're right, setting the spin.toml default to a sentinel value is the only way to tackle this.