Skip to content

Commit

Permalink
Merge pull request #71 from jgnagy/feature/preprocess-rendering
Browse files Browse the repository at this point in the history
Adding render option to apply preprocessing
  • Loading branch information
jgnagy authored Mar 31, 2021
2 parents 1a410a1 + 7ba8a8c commit b6c37e6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
skull_island (2.3.3)
skull_island (2.3.4)
deepsort (~> 0.4)
erubi (~> 1.8)
linguistics (~> 2.1)
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Commands:
skull_island help [COMMAND] # Describe available commands or one specific command
skull_island import [OPTIONS] [INPUT|-] # Import a configuration from INPUT
skull_island migrate [OPTIONS] [INPUT|-] [OUTPUT|-] # Migrate an older config from INPUT to OUTPUT
skull_island render [INPUT|-] # Render out preprocessed YAML for troubleshooting
skull_island reset # Fully reset a gateway (removing all config)
skull_island version # Display the current installed version of skull_island

Expand Down Expand Up @@ -149,6 +150,16 @@ To use this functionality, either add the `project` key to your configuration fi

When using the `project` feature of Skull Island, the CLI tool will automatically clean up old resources no longer found in your config file. This is, in fact, the _only_ circumstance under which this tool actually removes resources. Use this feature with care, as it can delete large swaths of your configuration if used incorrectly. It is **critical** that this value is unique since this project functionality is used to delete resources.

#### Troubleshooting Import Failures

If you're having trouble importing some YAML -- especially if you've done a lot of templating or have a lot of embedded ruby in your template -- you can use the `render` command to just output the raw, preprocessed YAML that Skull Island would attempt to import:

```sh
skull_island render /path/to/some/template.yml
```

This is safe to do on your local machine since it doesn't connect to a gateway. It will leave `lookup` functions but otherwise will leave the YAML without embedded ruby. This can then be linted with any YAML linter to help discover YAML-related formatting issues, etc., that cause import issues.

### Migrating

With Skull Island, it is possible to migrate a configuration from a 0.14.x, 1.1.x, 1.2.x, 1.4.x, or 1.5.x gateway to the most recent compatible gateway. If you have a previous export, you can just run `skull_island migrate /path/to/export.yml` and you'll receive a 2.3 compatible config on standard out. If you'd prefer, you can have that config written to a file as well (just like the export command) like so:
Expand Down
6 changes: 6 additions & 0 deletions lib/skull_island/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ def reset
].each { |clname| reset_class(clname, options['project']) }
end

desc('render [INPUT|-]', 'Render out preprocessed YAML for troubleshooting')
def render(input_file = '-')
raw ||= acquire_input(input_file, options['verbose'])
puts erb_preprocess(raw)
end

desc('version', 'Display the current installed version of skull_island')
def version
puts "SkullIsland Version: #{SkullIsland::VERSION}"
Expand Down
2 changes: 1 addition & 1 deletion lib/skull_island/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module SkullIsland
VERSION = [
2, # Major
3, # Minor
3 # Patch
4 # Patch
].join('.')
end

0 comments on commit b6c37e6

Please sign in to comment.