Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom keys for custom provisioning in vvv-init.sh #1071

Merged
merged 4 commits into from
Jan 16, 2017

Conversation

tomjn
Copy link
Member

@tomjn tomjn commented Jan 4, 2017

The new vvv-config.yml/vvv-custom.yml allows you to specify a site or sites, with various keys. However, a vvv-init.sh may want to specify custom keys that are too specific to apply to all VVV sites.

This PR installs python-pip and the shyaml dependency, and adds a bash function named customvalue for retrieving those keys. When the custom section or the requested key are not defined or found, the function will return nothing

E.g. in vvv-init.sh

colour=`customvalue 'colour' 'pink'`
echo "Hello there :) This site is a ${colour} site"

Which when ran will print Hello there :) This site is a pink site, and can be changed as follows in vvv-custom.yml:

  redsite:
    custom:
      colour: red

Resulting in Hello there :) This site is a red site

Nested keys can be accessed using dot syntax, e.g.:

  redsite:
    custom:
      colour:
        primary: red
        secondary: blue
primarycolour=`customvalue 'colour.primary' 'pink'`
echo "Hello there :) This site is a ${primarycolour} site"

@jeremyfelt
Copy link
Member

This is really slick, thanks @tomjn!

I'd like to revisit the name customvalue as I think it can be more descriptive. How about something like get_config_key() or get_yaml_option? Happy to hear any other ideas as well.

@tomjn
Copy link
Member Author

tomjn commented Jan 4, 2017

I like get_config_key, an obvious next step in functionality here would be to return values rather than a singular value, so get_config_value makes more sense, as it leads to the get_config_values function

@tomjn
Copy link
Member Author

tomjn commented Jan 5, 2017

I've renamed the function to get_config_value

@jeremyfelt
Copy link
Member

Great stuff, thanks @tomjn!

@jeremyfelt jeremyfelt merged commit 1a930c3 into Varying-Vagrant-Vagrants:develop Jan 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants