Skip to content

Commit

Permalink
chore(configuration): add resource configuration; fix Makefile recipes (
Browse files Browse the repository at this point in the history
#3)

Signed-off-by: Jordan Levin <[email protected]>
Signed-off-by: Christopher Haar <[email protected]>
Co-authored-by: Christopher Haar <[email protected]>
  • Loading branch information
jaylevin and haarchri authored Sep 22, 2023
1 parent ac9e9c7 commit 9182965
Show file tree
Hide file tree
Showing 71 changed files with 4,207 additions and 3,223 deletions.
40 changes: 32 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=30m
version: ${{ env.GOLANGCI_VERSION }}

check-diff:
Expand Down Expand Up @@ -114,12 +115,35 @@ jobs:
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-pkg-

- name: Vendor Dependencies
run: make vendor vendor.check
- name: make generate
run: |
make generate > /dev/null || true
- name: debug
run: |
tree .work || true
- name: pre-process-docs
continue-on-error: true
run: |
set +e
broken_doc_file=".work/confluentinc/confluent/docs/resources/confluent_ksql_cluster.md"
if ! grep -q page_title "$broken_doc_file"; then
echo '---
# generated by Github Action
page_title: "confluent_ksql_cluster Resource - terraform-provider-confluent"
subcategory: ""
description: |-
---' | cat - $broken_doc_file > temp && mv temp $broken_doc_file
fi
- name: Check Diff
run: make check-diff
run: |
set +e
go install golang.org/x/tools/cmd/goimports@latest
make generate && make check-diff
git status
unit-tests:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -289,36 +313,36 @@ jobs:
# We're using docker buildx, which doesn't actually load the images it
# builds by default. Specifying --load does so.
BUILD_ARGS: "--load"

- name: Publish Artifacts to GitHub
uses: actions/upload-artifact@v2
with:
name: output
path: _output/**

- name: Login to Docker
uses: docker/login-action@v1
if: env.CONTRIB_DOCKER_USR != ''
with:
username: ${{ secrets.CONTRIB_DOCKER_USR }}
password: ${{ secrets.CONTRIB_DOCKER_PSW }}

- name: Login to Upbound
uses: docker/login-action@v1
if: env.XPKG_ACCESS_ID != ''
with:
registry: xpkg.upbound.io
username: ${{ secrets.XPKG_ACCESS_ID }}
password: ${{ secrets.XPKG_TOKEN }}

- name: Publish Artifacts to S3 and Docker Hub
run: make -j2 publish BRANCH_NAME=${GITHUB_REF##*/}
if: env.AWS_USR != '' && env.CONTRIB_DOCKER_USR != ''
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_USR }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PSW }}
GIT_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Promote Artifacts in S3 and Docker Hub
if: github.ref == 'refs/heads/master' && env.AWS_USR != '' && env.CONTRIB_DOCKER_USR != ''
run: make -j2 promote
Expand All @@ -327,4 +351,4 @@ jobs:
CHANNEL: master
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_USR }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PSW }}

13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/.cache
/.work
/_output
cover.out
/vendor
/.vendor-new

# asdf loca go version
.tool-versions

# ignore IDE folders
.vscode/
.idea/
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export TERRAFORM_PROVIDER_SOURCE := confluentinc/confluent
export TERRAFORM_PROVIDER_REPO := https://github.com/confluentinc/terraform-provider-confluent
export TERRAFORM_PROVIDER_VERSION := 1.28.0
export TERRAFORM_PROVIDER_DOWNLOAD_NAME := terraform-provider-confluent
export TERRAFORM_PROVIDER_DOWNLOAD_URL_PREFIX ?= $(TERRAFORM_PROVIDER_REPO)/releases/download/v$(TERRAFORM_PROVIDER_VERSION)
export TERRAFORM_NATIVE_PROVIDER_BINARY := terraform-provider-confluent_1.28.0
export TERRAFORM_DOCS_PATH := docs/resources

Expand Down Expand Up @@ -51,7 +52,7 @@ GO111MODULE = on
# ====================================================================================
# Setup Kubernetes tools

UP_VERSION = v0.13.0
UP_VERSION = v0.19.0
UP_CHANNEL = stable
-include build/makelib/k8s_tools.mk

Expand Down Expand Up @@ -135,6 +136,15 @@ run: go.build
@# To see other arguments that can be provided, run the command with --help instead
$(GO_OUT_DIR)/provider --debug

pull-docs:
@if [ ! -d "$(WORK_DIR)/$(TERRAFORM_PROVIDER_SOURCE)" ]; then \
mkdir -p "$(WORK_DIR)/$(TERRAFORM_PROVIDER_SOURCE)" && \
git clone -c advice.detachedHead=false --depth 1 --filter=blob:none --branch "v$(TERRAFORM_PROVIDER_VERSION)" --sparse "$(TERRAFORM_PROVIDER_REPO)" "$(WORK_DIR)/$(TERRAFORM_PROVIDER_SOURCE)"; \
fi
@git -C "$(WORK_DIR)/$(TERRAFORM_PROVIDER_SOURCE)" sparse-checkout set "$(TERRAFORM_DOCS_PATH)"

generate.init: $(TERRAFORM_PROVIDER_SCHEMA) pull-docs

.PHONY: cobertura manifests submodules fallthrough test-integration run crds.clean

# ====================================================================================
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ Confluent API.

## Getting Started

### Fix for make generate
The Confluent Provider Terraform documentation has a missing block that will cause the `make generate` command to fail with the following error:
```shell
scraper: error: Failed to scrape Terraform provider metadata: cannot scrape Terraform registry: failed to scrape resource metadata from path: ../.work/confluentinc/confluent/docs/resources/confluent_ksql_cluster.md: failed to find the prelude of the document using the xpath expressions: //text()[contains(., "description") and contains(., "page_title")]
```

To fix this, run:
```shell
broken_doc_file=".work/confluentinc/confluent/docs/resources/confluent_ksql_cluster.md"
echo '---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "confluent_ksql_cluster Resource - terraform-provider-confluent"
subcategory: ""
description: |-
---' | cat - $broken_doc_file > temp && mv temp $broken_doc_file
```


Install the provider by using the following command after changing the image tag
to the [latest release](https://marketplace.upbound.io/providers/crossplane-contrib/provider-confluent):
```
Expand Down
Loading

0 comments on commit 9182965

Please sign in to comment.