Skip to content

Allow explicit provisioner selection for environment resources #488

@Siddhartha-singh01

Description

@Siddhartha-singh01

Is your feature request related to a problem? Please describe.

The built-in environment provisioner (envprov) is hardcoded into the generate command and always resolves variables via os.LookupEnv. In internal/command/generate.go:

environmentProvisioner := new(envprov.Provisioner)
loadedProvisioners = append(loadedProvisioners, environmentProvisioner)

There's no way for a developer to say "use a .env file for local dev" or "use AWS SSM in production." Which provisioner handles environment resources is silently determined by ordering in the list (slices.IndexFunc returns the first match), making it hard to debug or override.

Describe the solution you'd like

Promote envprov to a first-class, loadable provisioner type the same way templateprov and cmdprov already work. The provisioner loader in internal/provisioners/loader/load.go currently handles template:// and cmd:// URI schemes. Adding a local-env:// scheme would let the loader parse and load environment provisioners from the existing .provisioners.yaml files.

For example, a developer could define this in their provisioners file:

- uri: local-env://default-provisioners/environment
  type: environment
  description: Pulls values out of the local environment as outputs to an environment resource


The built-in `os.LookupEnv` behavior should stay as the default when nothing is configured, so existing Score files keep working as-is.

**Describe alternatives you've considered**

1. **Writing a community provisioner for each source** Works today (e.g. the `dotenv` provisioner), but the selection between built-in and community is still implicit and order-dependent.

2. **Removing the built-in provisioner entirely**  Would break backward compatibility for users relying on the current `os.LookupEnv` default.

3. **Keeping things as they are**  Functional, but the "magic" resolution gets harder to reason about as more community provisioners are added.

**Additional context**

Came out of the discussion in #483  @chris-stephenson pointed out that while the `environment` resource type is "special," the provisioner backing it shouldn't be magic and should be overridable. The current [`envprov.Provisioner`](https://github.com/score-spec/score-compose/blob/main/internal/provisioners/envprov/envprov.go) matches any resource with `type == "environment"` and `class == "default"`, and defaults its `LookupFunc` to `os.LookupEnv`  none of which the developer can change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions