Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated examples, simplified documentation and adding pre-commit to CI #616

Merged
merged 17 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: golangci-lint
on:
pull_request:
branches:
- main

permissions:
contents: read

jobs:
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0
with:
args: --timeout=10m
66 changes: 66 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Pre-Commit

on:
push:
branches: [ main ]
paths:
- examples/**
pull_request:
branches: [ main ]
paths:
- examples/**

env:
TERRAFORM_DOCS_VERSION: v0.16.0
TFLINT_VERSION: v0.44.1

jobs:
collectInputs:
name: Collect workflow inputs
runs-on: ubuntu-latest
outputs:
directories: ${{ steps.dirs.outputs.directories }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get root directories
id: dirs
uses: clowdhaus/terraform-composite-actions/[email protected]

preCommitMinVersions:
name: Min TF pre-commit
needs: collectInputs
runs-on: ubuntu-latest
strategy:
matrix:
directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Terraform min/max versions
id: minMax
uses: clowdhaus/[email protected]
with:
directory: ${{ matrix.directory }}

- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
# Run only validate pre-commit check on min version supported
if: ${{ matrix.directory != '.' }}
uses: clowdhaus/terraform-composite-actions/[email protected]
with:
terraform-version: ${{ steps.minMax.outputs.minVersion }}
tflint-version: ${{ env.TFLINT_VERSION }}
terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}
args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'

- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
# Run only validate pre-commit check on min version supported
if: ${{ matrix.directory == '.' }}
uses: clowdhaus/terraform-composite-actions/[email protected]
with:
terraform-version: ${{ steps.minMax.outputs.minVersion }}
tflint-version: ${{ env.TFLINT_VERSION }}
terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}
args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'
3 changes: 2 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ jobs:
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: 1.20.x
go-version-file: 'go.mod'
cache: true
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
id: import_gpg
Expand Down
46 changes: 3 additions & 43 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: 1.20.x
go-version-file: 'go.mod'
cache: true
cache-dependency-path: |
**/go.sum
Expand All @@ -79,11 +79,6 @@ jobs:
fail-fast: false
matrix:
terraform:
- '1.0.*'
- '1.1.*'
- '1.2.*'
- '1.3.*'
- '1.4.*'
- '1.5.*'
- '1.6.*'
- '1.7.*'
Expand All @@ -102,41 +97,6 @@ jobs:
TF_ACC: "1"
run: go test -v -cover ./internal/provider/
timeout-minutes: 10
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: 1.20.x
- name: Setup TFLint
uses: terraform-linters/setup-tflint@19a52fbac37dacb22a09518e4ef6ee234f2d4987 # v4.0.0
- name: Lint Terraform
run: make lint
- name: Setup Kubernetes
uses: helm/kind-action@99576bfa6ddf9a8e612d83b513da5a75875caced # v1.9.0
with:
version: v0.17.0
# The versions below should target the newest Kubernetes version
# Keep this up-to-date with https://endoflife.date/kubernetes
node_image: kindest/node:v1.28.0@sha256:9f3ff58f19dcf1a0611d11e8ac989fdb30a28f40f236f59f0bea31fb956ccf5c
- name: Setup Flux CLI
uses: fluxcd/flux2/action@534684601ec8888beb0cc4f51117b59e97606c4d # v2.2.3
- name: Apply Terraform
env:
GOOS: linux
GOARCH: amd64
run: |
make build
make terraformrc
export TF_CLI_CONFIG_FILE="${PWD}/.terraformrc"
cd examples/install
terraform init
terraform apply -auto-approve -var "components_extra=[\"image-reflector-controller\", \"image-automation-controller\"]"
- name: Health check Flux
run: flux check
e2e-github:
runs-on: ubuntu-latest
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && github.actor != 'dependabot[bot]'
Expand All @@ -146,7 +106,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: 1.20.x
go-version-file: 'go.mod'
cache: true
cache-dependency-path: |
**/go.sum
Expand Down Expand Up @@ -178,7 +138,7 @@ jobs:
make build
make terraformrc
export TF_CLI_CONFIG_FILE="${PWD}/.terraformrc"
cd examples/github-ssh
cd examples/github-via-ssh
terraform init
terraform apply -auto-approve -var "github_token=${GITHUB_TOKEN}" -var "github_org=fluxcd-testing" -var "github_repository=${{ steps.vars.outputs.test_repo_name }}"
env:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ jobs:
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: 1.20.x
go-version-file: 'go.mod'
cache: true
- name: Setup Flux CLI
uses: fluxcd/flux2/action@main
with:
Expand Down
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,39 @@ repos:
- id: trailing-whitespace
- repo: https:/dnephin/pre-commit-golang.git
rev: v0.5.0
files: internal
hooks:
- id: go-fmt
- id: go-imports
- id: go-mod-tidy
- id: go-build
- id: go-unit-tests
- id: golangci-lint
- repo: https:/antonbabenko/pre-commit-terraform
rev: v1.88.0
files: examples
hooks:
- id: terraform_fmt
- id: terraform_validate
- id: terraform_docs
args:
- '--args=--lockfile=false'
- id: terraform_tflint
args:
- '--args=--only=terraform_deprecated_interpolation'
- '--args=--only=terraform_deprecated_index'
- '--args=--only=terraform_unused_declarations'
- '--args=--only=terraform_comment_syntax'
- '--args=--only=terraform_documented_outputs'
- '--args=--only=terraform_documented_variables'
- '--args=--only=terraform_typed_variables'
- '--args=--only=terraform_module_pinned_source'
- '--args=--only=terraform_naming_convention'
- '--args=--only=terraform_required_version'
- '--args=--only=terraform_required_providers'
- '--args=--only=terraform_standard_module_structure'
- '--args=--only=terraform_workspace_remote'
- repo: https:/FalcoSuessgott/tfplugindocs
rev: v0.0.2
hooks:
- id: tfplugindocs
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
[![license](https://img.shields.io/github/license/fluxcd/terraform-provider-flux.svg)](https:/fluxcd/terraform-provider-flux/blob/main/LICENSE)
[![release](https://img.shields.io/github/release/fluxcd/terraform-provider-flux/all.svg)](https:/fluxcd/terraform-provider-flux/releases)

This is the Terraform provider for Flux v2. The provider allows you to install Flux on Kubernetes
and configure it to reconcile the cluster state from a Git repository.
This is the Terraform provider for Flux v2. The provider allows you to install Flux on Kubernetes and configure it to reconcile the cluster state from a Git repository.

## Get Started

Expand Down Expand Up @@ -35,6 +34,14 @@ resource "flux_bootstrap_git" "this" {

## Guides

* [Customize Flux configuration](https://registry.terraform.io/providers/fluxcd/flux/latest/docs/resources/bootstrap_git#customizing-flux)
* [Bootstrap with GitHub](https://registry.terraform.io/providers/fluxcd/flux/latest/docs/guides/github)
* [Bootstrap with GitLab](https://registry.terraform.io/providers/fluxcd/flux/latest/docs/guides/gitlab)
The following guides are available to help you use the provider:

- [Configuration using a Github repository via SSH](examples/github-via-ssh)
- [Configuration using a Github repository via SSH and GPG](examples/github-via-ssh-with-gpg)
- [Configuration using a Github repository via SSH with flux customizations](examples/github-with-customizations)
- [Configuration using a Github repository via SSH and GPG with inline flux customizations](examples/github-with-inline-customizations)
swade1987 marked this conversation as resolved.
Show resolved Hide resolved
- [Configuration using a Gitlab repository via SSH](examples/gitlab-via-ssh)
- [Configuration using a Gitlab repository via SSH and GPG](examples/gitlab-via-ssh-with-gpg)
- [Configuration using a Helm Release and not the flux_bootstrap_git resource](examples/helm-install) **

** This is the recommended approach if you do not want to perform initial flux bootstrapping.
52 changes: 0 additions & 52 deletions docs/guides/breaking-provider-configuration.md

This file was deleted.

53 changes: 0 additions & 53 deletions docs/guides/extra-syncs.md

This file was deleted.

Loading
Loading