Skip to content

Commit

Permalink
Add OiCS link generation to the Terraform docs. (#572)
Browse files Browse the repository at this point in the history
Merged PR #572.
  • Loading branch information
rileykarson authored and modular-magician committed Oct 19, 2018
1 parent 1f6c48c commit b6e66c2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/terraform
16 changes: 16 additions & 0 deletions provider/terraform/custom_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,22 @@ def config_example
substitute_example_paths body
end

def oics_link
hash = {
cloudshell_git_repo: 'https://github.com/terraform-google-modules/docs-examples.git',
cloudshell_working_dir: @name,
cloudshell_image: 'gcr.io/graphite-cloud-shell-images/terraform:latest',
open_in_editor: 'main.tf',
cloudshell_print: './motd',
cloudshell_tutorial: './tutorial.md'
}
URI::HTTPS.build(
host: 'console.cloud.google.com',
path: '/cloudshell/open',
query: URI.encode_www_form(hash)
)
end

def substitute_test_paths(config)
config = config.gsub('path/to/private.key', 'test-fixtures/ssl_cert/test.key')
config.gsub('path/to/certificate.crt', 'test-fixtures/ssl_cert/test.crt')
Expand Down
14 changes: 11 additions & 3 deletions templates/terraform/resource.html.markdown.erb
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,19 @@ To get more information about <%= object.name -%>, see:
<% end -%>
<% unless object.example.empty? -%>
## Example Usage
<%- object.example.each do |example| -%>
<%- unless example.skip_test -%>
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="<%= example.oics_link %>" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
<%- end -%>
## Example Usage - <%= example.name.camelize(:upper).uncombine %>
<% object.example.each do |example| -%>
<%= example.config_documentation -%>
<%- end %>
<%- end %>
<%- end -%>
## Argument Reference
Expand Down

0 comments on commit b6e66c2

Please sign in to comment.