Skip to content

Commit

Permalink
Dynamic datasources support (#100)
Browse files Browse the repository at this point in the history
* feat(modules/readme): dynamic datasources support

Now use url from arg datasource if it passed
Regenerate readme

* chore(packages/Makefile): bump packages version

* feat(readme): add inline datasources support

Now datasource for readme defines in template
Also exist possibility override datasource due env variable

* fix(Makefile): clean up output of defineDatasource

* fix(template, Makefile): use inline regexp

* style(README): fix spaces

* refactor(readme): mv datasource decl from makefile

* refactor(readme): remove useless variable

* refactor(*): rename INCLUDES var

* refactor(README): rename variable
  • Loading branch information
vadim-gleif authored and osterman committed Sep 28, 2018
1 parent 518fc1e commit c737e5a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!-- This file was automatically generated by the `build-harness`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. -->


[![Cloud Posse](https://cloudposse.com/logo-300x69.svg)](https://cloudposse.com)

# Build Harness [![Build Status](https://travis-ci.org/cloudposse/build-harness.svg?branch=master)](https://travis-ci.org/cloudposse/build-harness) [![Latest Release](https://img.shields.io/github/release/cloudposse/build-harness.svg)](https://github.com/cloudposse/build-harness/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
Expand Down Expand Up @@ -106,6 +107,8 @@ Available targets:
github/download-private-release Download release from github
github/download-public-release Download release from github
github/push-artifacts Push all release artifacts to GitHub (Required: `GITHUB_TOKEN`)
gitleaks/install Install gitleaks
gitleaks/scan Scan current repository
go/build Build binary
go/build-all Build binary for all platforms
go/clean Clean compiled binary
Expand Down Expand Up @@ -169,6 +172,7 @@ Available targets:
terraform/get-plugins Ensure all plugins can be fetched
terraform/install Install terraform
terraform/lint Lint check Terraform
terraform/upgrade-modules Upgrade all terraform module sources
terraform/validate Basic terraform sanity check
travis/docker-login Login into docker hub
travis/docker-tag-and-push Tag & Push according Travis environment variables
Expand Down
3 changes: 3 additions & 0 deletions docs/targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Available targets:
github/download-private-release Download release from github
github/download-public-release Download release from github
github/push-artifacts Push all release artifacts to GitHub (Required: `GITHUB_TOKEN`)
gitleaks/install Install gitleaks
gitleaks/scan Scan current repository
go/build Build binary
go/build-all Build binary for all platforms
go/clean Clean compiled binary
Expand Down Expand Up @@ -102,6 +104,7 @@ Available targets:
terraform/get-plugins Ensure all plugins can be fetched
terraform/install Install terraform
terraform/lint Lint check Terraform
terraform/upgrade-modules Upgrade all terraform module sources
terraform/validate Basic terraform sanity check
travis/docker-login Login into docker hub
travis/docker-tag-and-push Tag & Push according Travis environment variables
Expand Down
2 changes: 1 addition & 1 deletion modules/packages/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export INSTALL_PATH ?= $(BUILD_HARNESS_PATH)/vendor
export PACKAGES_VERSION ?= 0.24.0
export PACKAGES_VERSION ?= 0.24.1
export PACKAGES_PATH ?= $(BUILD_HARNESS_PATH)/vendor/packages

## Delete packages
Expand Down
9 changes: 4 additions & 5 deletions modules/readme/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ export README_LINT ?= $(TMP)/README.md
export README_FILE ?= README.md
export README_YAML ?= README.yaml
export README_TEMPLATE_FILE ?= $(BUILD_HARNESS_PATH)/templates/README.md
export README_TEMPLATE_YAML ?= $(BUILD_HARNESS_PATH)/templates/README.yaml
export README_TEMPLATE_YAML := $(if $(findstring http,$(README_YAML)),$(README_YAML),$(BUILD_HARNESS_PATH)/templates/$(README_YAML))
export README_INCLUDES ?= $(file://$(shell pwd)/?type=text/plain)

## Alias for readme/build
readme: readme/build
Expand All @@ -29,7 +30,5 @@ readme/lint:
## Create README.md by building it from README.yaml
readme/build: $(README_DEPS)
@gomplate --file $(README_TEMPLATE_FILE) \
--out $(README_FILE) \
--datasource config=$(README_YAML) \
--datasource includes='file://$(shell pwd)/?type=text/plain'
@echo "Generated $(README_FILE) from $(README_TEMPLATE_FILE) using data from $(README_TEMPLATE_YAML)"
--out $(README_FILE)
@echo "Generated $(README_FILE) from $(README_TEMPLATE_FILE) using data from $(README_TEMPLATE_YAML)"
3 changes: 2 additions & 1 deletion templates/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!-- This file was automatically generated by the `build-harness`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. -->

{{ defineDatasource "config" .Env.README_YAML | regexp.Replace ".*" "" }}
{{ defineDatasource "includes" .Env.README_INCLUDES | regexp.Replace ".*" "" }}
[![Cloud Posse](https://cloudposse.com/logo-300x69.svg)](https://cloudposse.com)

# {{(ds "config").name}}{{ if gt (len (ds "config").name) 34 }}{{ print "\n\n" }}{{ end }}{{ if has (ds "config") "badges" }}{{- range $badge := (ds "config").badges -}}{{ printf " [![%s](%s)](%s)" $badge.name $badge.image $badge.url }}{{ end }}{{ end }}
Expand Down

0 comments on commit c737e5a

Please sign in to comment.