Page MenuHomePhabricator

Fix Blubber variant expansion for boolean/int config properties
Closed, ResolvedPublic

Description

Due to the current implementation of variant expansion, Blubber cannot correctly merge/expand variants that overwrite int/boolean configuration.

Example of problematic configuration:

npm:
  install: true
runs:
  uid: 1
variants:
  foo:
    npm:
      install: false
    runs:
      uid: 0

The expected behavior here would inarguably be that the expanded foo variant should have an npm.install value of false and a runs.uid value of 0, however neither value would be merged in that way. This limitation is due to the current way that the YAML is unmarshaled into structs having fields with zero values—an int's zero value is 0 and a boolean's zero value is false—before a given variant is expanded.

Some options for refactoring might be:

  1. Use pointer types for config struct fields to allow for nil and thus more accurate expansion. (Introduces more risk of trying to access values of nil pointers at runtime of course.)
  2. Have separate types for unmarshaled (external) configuration and expanded (internal) structs, the former with pointer typed fields and the latter with value fields.
  3. Try to wrangle YAML unmarshaling to retain raw YAML before variant is expanded.

At the moment I think the ordering of these options in terms of apparent sanity is 2-1-3.

Revisions and Commits

rGBLBR Blubber
Restricted Differential Revision