Skip to content

Commit bfbd778

Browse files
committed
Setting embedded_manifest to true and repo visibility to private.
Signed-off-by: Steven Wade <[email protected]>
1 parent 990e3dd commit bfbd778

File tree

15 files changed

+114
-94
lines changed

15 files changed

+114
-94
lines changed

.github/workflows/check-examples.yaml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Check examples
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "examples/**"
9+
- "**.go"
10+
pull_request:
11+
branches:
12+
- main
13+
paths:
14+
- "examples/**"
15+
- "**.go"
16+
workflow_dispatch:
17+
18+
jobs:
19+
check:
20+
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
terraform_version:
24+
- "1.6.0"
25+
- "1.7.0"
26+
- "1.8.0"
27+
env:
28+
TERM: linux
29+
steps:
30+
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
31+
with:
32+
terraform_version: ${{ matrix.terraform_version }}
33+
- name: Checkout
34+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
35+
- name: Setup Go
36+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
37+
with:
38+
go-version-file: 'go.mod'
39+
cache: true
40+
cache-dependency-path: |
41+
**/go.sum
42+
**/go.mod
43+
- name: Build provider
44+
run: |
45+
go build
46+
- name: Check examples run
47+
run: |
48+
./scripts/check_examples.sh

.github/workflows/pre-commit.yaml

-66
This file was deleted.

.pre-commit-config.yaml

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.3.0
3+
rev: v4.5.0
44
hooks:
55
- id: check-byte-order-marker
66
- id: check-case-conflict
@@ -23,7 +23,7 @@ repos:
2323
- id: go-unit-tests
2424
- id: golangci-lint
2525
- repo: https://github.com/antonbabenko/pre-commit-terraform
26-
rev: v1.88.0
26+
rev: v1.88.2
2727
files: examples
2828
hooks:
2929
- id: terraform_fmt
@@ -33,18 +33,19 @@ repos:
3333
- '--args=--lockfile=false'
3434
- id: terraform_tflint
3535
args:
36-
- '--args=--only=terraform_deprecated_interpolation'
37-
- '--args=--only=terraform_deprecated_index'
38-
- '--args=--only=terraform_unused_declarations'
3936
- '--args=--only=terraform_comment_syntax'
37+
- '--args=--only=terraform_deprecated_index'
38+
- '--args=--only=terraform_deprecated_interpolation'
4039
- '--args=--only=terraform_documented_outputs'
4140
- '--args=--only=terraform_documented_variables'
42-
- '--args=--only=terraform_typed_variables'
4341
- '--args=--only=terraform_module_pinned_source'
4442
- '--args=--only=terraform_naming_convention'
45-
- '--args=--only=terraform_required_version'
4643
- '--args=--only=terraform_required_providers'
44+
- '--args=--only=terraform_required_version'
4745
- '--args=--only=terraform_standard_module_structure'
46+
- '--args=--only=terraform_typed_variables'
47+
- '--args=--only=terraform_unused_declarations'
48+
- '--args=--only=terraform_unused_required_providers'
4849
- '--args=--only=terraform_workspace_remote'
4950
- repo: https://github.com/FalcoSuessgott/tfplugindocs
5051
rev: v0.0.2

examples/github-self-managed-ssh-keypair/main.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ resource "kind_cluster" "this" {
4040
resource "github_repository" "this" {
4141
name = var.github_repository
4242
description = var.github_repository
43-
visibility = "public"
43+
visibility = "private"
4444
auto_init = true # This is extremely important as flux_bootstrap_git will not work without a repository that has been initialised
4545
}
4646

@@ -98,6 +98,7 @@ resource "kubernetes_secret" "ssh_keypair" {
9898
resource "flux_bootstrap_git" "this" {
9999
depends_on = [github_repository_deploy_key.this, kubernetes_secret.ssh_keypair]
100100

101-
path = "clusters/my-cluster"
102101
disable_secret_creation = true
102+
embedded_manifests = true
103+
path = "clusters/my-cluster"
103104
}

examples/github-via-pat/main.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ resource "kind_cluster" "this" {
3232
resource "github_repository" "this" {
3333
name = var.github_repository
3434
description = var.github_repository
35-
visibility = "public"
35+
visibility = "private"
3636
auto_init = true # This is extremely important as flux_bootstrap_git will not work without a repository that has been initialised
3737
}
3838

@@ -43,5 +43,6 @@ resource "github_repository" "this" {
4343
resource "flux_bootstrap_git" "this" {
4444
depends_on = [github_repository.this]
4545

46-
path = "clusters/my-cluster"
46+
embedded_manifests = true
47+
path = "clusters/my-cluster"
4748
}

examples/github-via-ssh-with-gpg/main.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ resource "kind_cluster" "this" {
3636
resource "github_repository" "this" {
3737
name = var.github_repository
3838
description = var.github_repository
39-
visibility = "public"
39+
visibility = "private"
4040
auto_init = true # This is extremely important as flux_bootstrap_git will not work without a repository that has been initialised
4141
}
4242

@@ -63,5 +63,6 @@ resource "github_repository_deploy_key" "this" {
6363
resource "flux_bootstrap_git" "this" {
6464
depends_on = [github_repository_deploy_key.this]
6565

66-
path = "clusters/my-cluster"
66+
embedded_manifests = true
67+
path = "clusters/my-cluster"
6768
}

examples/github-via-ssh/main.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ resource "kind_cluster" "this" {
3636
resource "github_repository" "this" {
3737
name = var.github_repository
3838
description = var.github_repository
39-
visibility = "public"
39+
visibility = "private"
4040
auto_init = true # This is extremely important as flux_bootstrap_git will not work without a repository that has been initialised
4141
}
4242

@@ -63,5 +63,6 @@ resource "github_repository_deploy_key" "this" {
6363
resource "flux_bootstrap_git" "this" {
6464
depends_on = [github_repository_deploy_key.this]
6565

66-
path = "clusters/my-cluster"
66+
embedded_manifests = true
67+
path = "clusters/my-cluster"
6768
}

examples/github-with-customizations/main.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ resource "kind_cluster" "this" {
3636
resource "github_repository" "this" {
3737
name = var.github_repository
3838
description = var.github_repository
39-
visibility = "public"
39+
visibility = "private"
4040
auto_init = true # This is extremely important as flux_bootstrap_git will not work without a repository that has been initialised
4141
}
4242

@@ -63,10 +63,11 @@ resource "github_repository_deploy_key" "this" {
6363
resource "flux_bootstrap_git" "this" {
6464
depends_on = [github_repository_deploy_key.this]
6565

66-
path = "clusters/my-cluster"
6766
components_extra = [
6867
"image-reflector-controller",
6968
"image-automation-controller"
7069
]
70+
embedded_manifests = true
7171
kustomization_override = file("${path.root}/resources/flux-kustomization-patch.yaml")
72+
path = "clusters/my-cluster"
7273
}

examples/github-with-inline-customizations/main.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ resource "kind_cluster" "this" {
3636
resource "github_repository" "this" {
3737
name = var.github_repository
3838
description = var.github_repository
39-
visibility = "public"
39+
visibility = "private"
4040
auto_init = true # This is extremely important as flux_bootstrap_git will not work without a repository that has been initialised
4141
}
4242

@@ -63,10 +63,11 @@ resource "github_repository_deploy_key" "this" {
6363
resource "flux_bootstrap_git" "this" {
6464
depends_on = [github_repository_deploy_key.this]
6565

66-
path = "clusters/my-cluster"
6766
components_extra = [
6867
"image-reflector-controller",
6968
"image-automation-controller"
7069
]
70+
embedded_manifests = true
7171
kustomization_override = templatefile("${path.root}/resources/flux-kustomization-patch.tftpl", { role_arn = var.role_arn })
72+
path = "clusters/my-cluster"
7273
}

examples/gitlab-via-ssh-with-gpg/main.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ resource "kind_cluster" "this" {
3636
resource "gitlab_project" "this" {
3737
name = var.gitlab_project
3838
description = "flux-bootstrap"
39-
visibility_level = "public"
39+
visibility_level = "private"
4040
initialize_with_readme = true # This is extremely important as Flux expects an initialised repository
4141
}
4242

@@ -63,5 +63,6 @@ resource "gitlab_deploy_key" "this" {
6363
resource "flux_bootstrap_git" "this" {
6464
depends_on = [gitlab_deploy_key.this]
6565

66-
path = "clusters/my-cluster"
66+
embedded_manifests = true
67+
path = "clusters/my-cluster"
6768
}

examples/gitlab-via-ssh/main.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ resource "kind_cluster" "this" {
3636
resource "gitlab_project" "this" {
3737
name = var.gitlab_project
3838
description = "flux-bootstrap"
39-
visibility_level = "public"
39+
visibility_level = "private"
4040
initialize_with_readme = true # This is extremely important as Flux expects an initialised repository
4141
}
4242

@@ -63,5 +63,6 @@ resource "gitlab_deploy_key" "this" {
6363
resource "flux_bootstrap_git" "this" {
6464
depends_on = [gitlab_deploy_key.this]
6565

66-
path = "clusters/my-cluster"
66+
embedded_manifests = true
67+
path = "clusters/my-cluster"
6768
}

examples/helm-install/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ However, using the Flux Helm chart is a better option when Flux needs to be inst
1414
| Name | Version |
1515
|------|---------|
1616
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.7.0 |
17-
| <a name="requirement_flux"></a> [flux](#requirement\_flux) | >= 1.2 |
1817
| <a name="requirement_github"></a> [github](#requirement\_github) | >= 6.1 |
1918
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.12 |
2019
| <a name="requirement_kind"></a> [kind](#requirement\_kind) | >= 0.4 |

examples/helm-install/main.tf

-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ terraform {
22
required_version = ">= 1.7.0"
33

44
required_providers {
5-
flux = {
6-
source = "fluxcd/flux"
7-
version = ">= 1.2"
8-
}
95
github = {
106
source = "integrations/github"
117
version = ">= 6.1"

internal/provider/resource_bootstrap_git.go

+2
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ func (r *bootstrapGitResource) Schema(ctx context.Context, req resource.SchemaRe
203203
"embedded_manifests": schema.BoolAttribute{
204204
Description: "When enabled, the Flux manifests will be extracted from the provider binary instead of being downloaded from github.com. Defaults to `false`.",
205205
Optional: true,
206+
Computed: true,
207+
Default: booldefault.StaticBool(false),
206208
},
207209
"id": schema.StringAttribute{
208210
Computed: true,

scripts/check_examples.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
set -x
4+
set -e
5+
6+
TF_IN_AUTOMATION=true
7+
TF_PLUGIN_VERSION="99.0.0"
8+
TF_PLUGIN_BINARY_NAME="terraform-provider-flux"
9+
TF_PLUGIN_BINARY_PATH="${HOME}/.terraform.d/plugins/registry.terraform.io/fluxcd/flux/$TF_PLUGIN_VERSION/$(go env GOOS)_$(go env GOARCH)/"
10+
11+
if [ ! -f $TF_PLUGIN_BINARY_PATH ]; then
12+
mkdir -p $TF_PLUGIN_BINARY_PATH
13+
fi
14+
15+
cp ./$TF_PLUGIN_BINARY_NAME $TF_PLUGIN_BINARY_PATH
16+
17+
SKIP_CHECKS=.skip_checks
18+
for example in $PWD/examples/*; do
19+
cd "$example"
20+
echo 🔍 $(tput bold)$(tput setaf 3)Checking $(basename $example)...
21+
if [ -f "$SKIP_CHECKS" ]; then
22+
echo "$SKIP_CHECKS specified. Skipping this example."
23+
continue
24+
fi
25+
terraform init
26+
terraform validate
27+
terraform plan -out tfplan > /dev/null
28+
terraform apply tfplan
29+
terraform refresh
30+
terraform destroy -auto-approve
31+
echo
32+
done

0 commit comments

Comments
 (0)