Skip to content

Commit 4f3ed82

Browse files
authored
Merge pull request #1 from Swile/swile-network-mirror
Setup Terraform Provider Network Mirror with GitHub Pages
2 parents 450ce85 + dd32136 commit 4f3ed82

File tree

13 files changed

+611
-40
lines changed

13 files changed

+611
-40
lines changed

.github/workflows/golangci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ jobs:
1212
- name: Checkout
1313
uses: actions/checkout@v5
1414

15-
- name: Setup Go
16-
uses: actions/setup-go@v5
15+
- uses: actions/setup-go@v6
1716
with:
18-
go-version: 1.24.x
17+
cache: true
18+
cache-dependency-path: 'go.sum'
19+
go-version-file: 'go.mod'
1920

2021
- run: go mod vendor
2122

.github/workflows/release.yml

Lines changed: 102 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,133 @@
11
# This GitHub action can publish assets for release when a tag is created.
22
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
33
#
4-
# This uses an action (paultyng/ghaction-import-gpg) that assumes you set your
4+
# This uses an action (paultyng/ghaction-import-gpg) that assumes you set your
55
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
66
# secret. If you would rather own your own GPG handling, please fork this action
77
# or use an alternative one for key handling.
88
#
9-
# You will need to pass the `--batch` flag to `gpg` in your signing step
9+
# You will need to pass the `--batch` flag to `gpg` in your signing step
1010
# in `goreleaser` to indicate this is being used in a non-interactive mode.
1111
#
1212
name: release
1313
on:
1414
push:
1515
tags:
1616
- 'v*'
17+
18+
concurrency:
19+
# Allow only run per ref
20+
# Mitigate https://intuit.github.io/auto/docs/welcome/quick-merge
21+
group: ${{ github.workflow }}-${{ github.ref }}
22+
1723
jobs:
1824
goreleaser:
1925
runs-on: ubuntu-latest
26+
permissions:
27+
contents: write
2028
steps:
2129
-
2230
name: Checkout
23-
uses: actions/checkout@v4
31+
uses: actions/checkout@v6
2432
-
2533
name: Unshallow
2634
run: git fetch --prune --unshallow
27-
-
28-
name: Set up Go
29-
uses: actions/setup-go@v5
30-
with:
31-
go-version: '1.24'
32-
-
33-
name: Import GPG key
34-
id: import_gpg
35-
uses: crazy-max/ghaction-import-gpg@v6.1.0
35+
36+
- uses: actions/setup-go@v6
3637
with:
37-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
38-
passphrase: ${{ secrets.PASSPHRASE }}
38+
cache: true
39+
cache-dependency-path: 'go.sum'
40+
go-version-file: 'go.mod'
41+
# -
42+
# name: Import GPG key
43+
# id: import_gpg
44+
# uses: crazy-max/ghaction-import-gpg@v6.1.0
45+
# with:
46+
# gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
47+
# passphrase: ${{ secrets.PASSPHRASE }}
3948
-
4049
name: Run GoReleaser
50+
id: release
4151
uses: goreleaser/goreleaser-action@v6
4252
with:
4353
version: latest
4454
args: release --clean
4555
env:
46-
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
47-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
#GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
57+
GITHUB_TOKEN: ${{ github.token }}
58+
59+
publish-mirror:
60+
needs: goreleaser
61+
runs-on: ubuntu-latest
62+
permissions:
63+
contents: write
64+
pages: write
65+
id-token: write
66+
environment:
67+
name: github-pages
68+
url: ${{ steps.deployment.outputs.page_url }}
69+
env:
70+
NAMESPACE: 'cyrilgdn'
71+
PROVIDER_NAME: 'postgresql'
72+
REGISTRY: 'registry.terraform.io'
73+
MIRROR_DIR: 'mirror'
74+
steps:
75+
- name: Set VERSION from tag
76+
run: |
77+
VERSION="${GITHUB_REF_NAME#v}"
78+
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
79+
80+
- uses: actions/checkout@v6
81+
82+
- uses: actions/checkout@v6
83+
with:
84+
ref: gh-pages
85+
path: gh-pages
86+
87+
- name: Download release artifacts
88+
env:
89+
GH_TOKEN: ${{ github.token }}
90+
run: |
91+
echo "Downloading artifacts for version ${VERSION}"
92+
MIRROR_VERSION_DIR="${{env.MIRROR_DIR}}/${{env.REGISTRY}}/${{env.NAMESPACE}}/${{env.PROVIDER_NAME}}/${{env.VERSION}}"
93+
94+
# Create directory structure for network mirror
95+
mkdir -p "${MIRROR_VERSION_DIR}"
96+
97+
# Download release assets
98+
gh release download "v${VERSION}" -D "${MIRROR_VERSION_DIR}"
99+
100+
- name: Generate network mirror metadata
101+
run: |
102+
# Make script executable
103+
chmod +x scripts/generate-mirror-metadata.sh
104+
105+
# Generate metadata
106+
./scripts/generate-mirror-metadata.sh "${VERSION}" "${NAMESPACE}" "${PROVIDER_NAME}" "${MIRROR_DIR}/${REGISTRY}"
107+
108+
# Update root simple index.html
109+
cp -f ./docs/mirror-index.html ${MIRROR_DIR}/index.html
110+
111+
# Update gh-pages content
112+
cp -r ${MIRROR_DIR}/* ./gh-pages/
113+
114+
- name: Commit and push to gh-pages
115+
run: |
116+
cd gh-pages
117+
git config user.name "github-actions[bot]"
118+
git config user.email "github-actions[bot]@users.noreply.github.com"
119+
git add .
120+
git commit -m "Release version ${VERSION}" || echo "No changes to commit"
121+
git push origin gh-pages
122+
123+
- name: Setup Pages
124+
uses: actions/configure-pages@v5
125+
126+
- name: Upload artifact
127+
uses: actions/upload-pages-artifact@v3
128+
with:
129+
path: ./gh-pages
130+
131+
- name: Deploy to GitHub Pages
132+
id: deployment
133+
uses: actions/deploy-pages@v4

.github/workflows/test.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ jobs:
1919

2020
steps:
2121
- name: Checkout
22-
uses: actions/checkout@v4
22+
uses: actions/checkout@v6
2323

24-
- name: Set up Go
25-
uses: actions/setup-go@v5
24+
- uses: actions/setup-go@v6
2625
with:
27-
go-version: '1.24'
26+
cache: true
27+
cache-dependency-path: 'go.sum'
28+
go-version-file: 'go.mod'
2829

2930
- name: test
3031
run: make test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
.*.swp
66
tests/docker-compose.*.yml
77
terraform-provider-postgresql
8+
9+
# Network mirror artifacts (deployed to gh-pages)
10+
mirror/

.go-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.goreleaser.yml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,29 @@ builds:
2929
ignore:
3030
- goos: darwin
3131
goarch: '386'
32+
- goos: windows
33+
goarch: arm
34+
- goos: windows
35+
goarch: arm64
3236
binary: '{{ .ProjectName }}_v{{ .Version }}'
3337
archives:
34-
- format: zip
38+
- formats: ['zip']
3539
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
3640
checksum:
3741
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
3842
algorithm: sha256
39-
signs:
40-
- artifacts: checksum
41-
args:
42-
# if you are using this is a GitHub action or some other automated pipeline, you
43-
# need to pass the batch flag to indicate it's not interactive.
44-
- "--batch"
45-
- "--local-user"
46-
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
47-
- "--output"
48-
- "${signature}"
49-
- "--detach-sign"
50-
- "${artifact}"
43+
#signs:
44+
# - artifacts: checksum
45+
# args:
46+
# # if you are using this is a GitHub action or some other automated pipeline, you
47+
# # need to pass the batch flag to indicate it's not interactive.
48+
# - "--batch"
49+
# - "--local-user"
50+
# - "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
51+
# - "--output"
52+
# - "${signature}"
53+
# - "--detach-sign"
54+
# - "${artifact}"
5155
release: {}
5256
# If you want to manually examine the release before its live, uncomment this line:
5357
# draft: true

README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
Terraform Provider for PostgreSQL
22
=================================
33

4+
Fork of Terraform PostgreSQL provider : https://github.com/cyrilgdn/terraform-provider-postgresql
5+
6+
This intent of this fork is to maintain a working version of the provider while waiting for the original repository to be updated.
7+
8+
This repository aims to be up to date with the original one, and also to add some features that are needed for our use cases.
9+
We re-integrated the following PRs that were open on the original repository:
10+
11+
- [Use object-level locks for concurrent grants to improve parallelism](https://github.com/cyrilgdn/terraform-provider-postgresql/pull/595)
12+
- [Support role configuration parameters](https://github.com/cyrilgdn/terraform-provider-postgresql/pull/305)
13+
14+
---
15+
416
This provider allows to manage with Terraform [Postgresql](https://www.postgresql.org/) objects like databases, extensions, roles, etc.
517

618
It's published on the [Terraform registry](https://registry.terraform.io/providers/cyrilgdn/postgresql/latest/docs).
@@ -36,6 +48,27 @@ Using the provider
3648

3749
Usage examples can be found in the Terraform [provider documentation](https://www.terraform.io/docs/providers/postgresql/index.html)
3850

51+
Network Mirror
52+
----------------------
53+
54+
This repository publishes a [Terraform provider network mirror](docs/NETWORK_MIRROR.md) on GitHub Pages, allowing you to use this provider without relying on external registries.
55+
56+
**Quick setup:**
57+
58+
Add to your `~/.terraformrc`:
59+
60+
```hcl
61+
provider_installation {
62+
network_mirror {
63+
url = "https://swile.github.io/terraform-provider-postgresql/"
64+
include = ["registry.terraform.io/cyrilgdn/postgresql"]
65+
}
66+
}
67+
```
68+
69+
See the [Network Mirror documentation](docs/NETWORK_MIRROR.md) for more details.
70+
71+
3972
Developing the Provider
4073
---------------------------
4174

@@ -58,7 +91,7 @@ $ make test
5891

5992
In order to run the full suite of Acceptance tests, run `make testacc`.
6093

61-
*Note:*
94+
*Note:*
6295
- Acceptance tests create real resources, and often cost money to run.
6396

6497
```sh
@@ -68,7 +101,7 @@ $ make testacc
68101
In order to manually run some Acceptance test locally, run the following commands:
69102
```sh
70103
# spins up a local docker postgres container
71-
make testacc_setup
104+
make testacc_setup
72105

73106
# Load the needed environment variables for the tests
74107
source tests/switch_superuser.sh
@@ -77,5 +110,5 @@ source tests/switch_superuser.sh
77110
TF_LOG=INFO go test -v ./postgresql -run ^TestAccPostgresqlRole_Basic$
78111

79112
# cleans the env and tears down the postgres container
80-
make testacc_cleanup
113+
make testacc_cleanup
81114
```

0 commit comments

Comments
 (0)