Skip to content

Conversation

@ryanmrodriguez
Copy link
Contributor

Addresses #1390


Allow setting an inherit_from key in 'shipit.yml' config files.

As of now this key expects a string. It is allowed to be chained:

# shipit_2.yml
inherit_from: shipit_1.yml

c: true
d: 123
# shipit_1.yml
inherit_from: shipit_base.yml

c: false

machine:
  environment:
    PUBLIC: true
    TEST: true
# shipit_base.yml

a: 123
b: test
c: 1


machine:
  environment:
    PUBLIC: false

Loading 'shipit_2.yml' results in:

{"a"=>123, "b"=>"test", "c"=>true, "machine"=>{"environment"=>{"PUBLIC"=>true, "TEST"=>true}}, "d"=>123}

Merge (deep) precedence = child overwrites parent (config file specified in inherit_from key).

@ryanmrodriguez ryanmrodriguez force-pushed the 20250415-config-file-inheritance branch from 70b041b to 7c2340e Compare April 16, 2025 11:23
@ryanmrodriguez ryanmrodriguez marked this pull request as ready for review April 16, 2025 11:30
Comment on lines +144 to +145
inherits_from_path = path.dirname.join(config_obj.delete(SHIPIT_CONFIG_INHERIT_FROM_KEY))
if inherits_from_path.exist?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open question: does a non existing path should noop or result in an error?

The problem is kinda always the same though, we don't have a good way of reporting shipit.yml errors, so perhaps nooping is the reasonable thing to do.

@casperisfine casperisfine merged commit dc4706b into Shopify:main Apr 23, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants