Skip to content

Commit

Permalink
Merge branch 'update-env-datasource'
Browse files Browse the repository at this point in the history
* update-env-datasource:
  Update generated provider docs
  Make targets for generating env ds
  Update to latest predefined variables listing
  • Loading branch information
rsrchboy committed Jan 14, 2022
2 parents 5f0cc47 + f75ea9a commit 1e040b4
Show file tree
Hide file tree
Showing 4 changed files with 533 additions and 313 deletions.
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test: $(binary_name)
go test `go list ./...`

clean:
rm -f $(binary_name)
rm -f $(binary_name) predefined_variables.md vars-data
rm -rf terraform.d/

fmt:
Expand Down Expand Up @@ -51,4 +51,19 @@ $(local_bin): $(binary_name)
mkdir -p $(dir $@)
cp $(binary_name) $@

# generate the bits we need for the env data source
# FIXME turn this into a proper `go generate` bit

predefined_variables.md:
curl https://gitlab.com/gitlab-org/gitlab/-/raw/master/doc/ci/variables/predefined_variables.md > $@

vars-data: predefined_variables.md
cat predefined_variables.md | grep '^| `' | awk -F\| '{ print $$2 $$5 }' > $@

env-ds-struct: vars-data
@cat $< | perl -nE '/`(\w+)`\s+(.*\S)\s+$$/; say q{"} . lc($$1) . qq{": {\nType: schema.TypeString,\nComputed: true,\nDescription: "$$2",\n},}'

env-ds-set: vars-data
@cat $< | sed -e 's/^ `//; s/`.*//' | perl -nE 'chomp; say qq{d.Set("} . lc($$_) . qq{", os.Getenv("$$_"))}'

.PHONY: build clean ci-datasource fmt vet tfa tfp test
Loading

0 comments on commit 1e040b4

Please sign in to comment.