Skip to content

Commit 910a026

Browse files
committed
add precommit and fix postgres job
1 parent dc9d8bb commit 910a026

9 files changed

Lines changed: 137 additions & 27 deletions

File tree

‎.github/workflows/pre-commit.yml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Pre-Commit Checks
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
pre-commit:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout code
10+
uses: actions/checkout@v2
11+
12+
- name: Set up Python
13+
uses: actions/setup-python@v2
14+
with:
15+
python-version: '3.8'
16+
17+
- name: Install pre-commit
18+
run: pip install pre-commit
19+
20+
- name: Run pre-commit hooks
21+
run: git diff --name-only HEAD^ | grep '\.yaml\|\.md' | xargs pre-commit run --files

‎.pre-commit-config.yaml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: end-of-file-fixer
6+
- id: trailing-whitespace
7+
- id: mixed-line-ending
8+
args: [--fix=lf]
9+
- id: check-yaml
10+
exclude: packages/apps/postgres/templates/init-script.yaml
11+
args: [--unsafe]
12+
- repo: https://github.com/igorshubovych/markdownlint-cli
13+
rev: v0.41.0
14+
hooks:
15+
- id: markdownlint
16+
args: [--fix, --disable, MD013, MD041, --]

‎README.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@
66
[![Support](https://img.shields.io/badge/$-support-12a0df.svg?style=flat)](https://aenix.io/contact-us/#meet)
77
[![Active](http://img.shields.io/badge/Status-Active-green.svg)](https://aenix.io/cozystack/)
88
[![GitHub Release](https://img.shields.io/github/release/aenix-io/cozystack.svg?style=flat)](https://github.com/aenix-io/cozystack)
9-
[![GitHub Commit](https://img.shields.io/github/commit-activity/y/aenix-io/cozystack)](https://github.com/aenix-io/cozystack)
9+
[![GitHub Commit](https://img.shields.io/github/commit-activity/y/aenix-io/cozystack)](https://github.com/aenix-io/cozystack)
1010

1111
# Cozystack
1212

1313
**Cozystack** is a free PaaS platform and framework for building clouds.
1414

1515
With Cozystack, you can transform your bunch of servers into an intelligent system with a simple REST API for spawning Kubernetes clusters, Database-as-a-Service, virtual machines, load balancers, HTTP caching services, and other services with ease.
1616

17-
You can use Cozystack to build your own cloud or to provide a cost-effective development environments.
17+
You can use Cozystack to build your own cloud or to provide a cost-effective development environments.
1818

1919
## Use-Cases
2020

21-
* [**Using Cozystack to build public cloud**](https://cozystack.io/docs/use-cases/public-cloud/)
21+
* [**Using Cozystack to build public cloud**](https://cozystack.io/docs/use-cases/public-cloud/)
2222
You can use Cozystack as backend for a public cloud
2323

24-
* [**Using Cozystack to build private cloud**](https://cozystack.io/docs/use-cases/private-cloud/)
24+
* [**Using Cozystack to build private cloud**](https://cozystack.io/docs/use-cases/private-cloud/)
2525
You can use Cozystack as platform to build a private cloud powered by Infrastructure-as-Code approach
2626

27-
* [**Using Cozystack as Kubernetes distribution**](https://cozystack.io/docs/use-cases/kubernetes-distribution/)
27+
* [**Using Cozystack as Kubernetes distribution**](https://cozystack.io/docs/use-cases/kubernetes-distribution/)
2828
You can use Cozystack as Kubernetes distribution for Bare Metal
2929

3030
## Screenshot
@@ -41,10 +41,10 @@ If you encounter any difficulties, start with the [troubleshooting guide](https:
4141

4242
## Versioning
4343

44-
Versioning adheres to the [Semantic Versioning](http://semver.org/) principles.
44+
Versioning adheres to the [Semantic Versioning](http://semver.org/) principles.
4545
A full list of the available releases is available in the GitHub repository's [Release](https://github.com/aenix-io/cozystack/releases) section.
4646

47-
- [Roadmap](https://github.com/orgs/aenix-io/projects/2)
47+
* [Roadmap](https://github.com/orgs/aenix-io/projects/2)
4848

4949
## Contributions
5050

@@ -62,7 +62,7 @@ You can join our weekly community meetings (just add this events to your [Google
6262

6363
## License
6464

65-
Cozystack is licensed under Apache 2.0.
65+
Cozystack is licensed under Apache 2.0.
6666
The code is provided as-is with no warranties.
6767

6868
## Commercial Support

‎packages/apps/README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### How to test packages local
2+
3+
```bash
4+
cd packages/core/installer
5+
make image-cozystack REGISTRY=YOUR_CUSTOM_REGISTRY
6+
make apply
7+
kubectl delete pod dashboard-redis-master-0 -n cozy-dashboard
8+
kubectl delete po -l app=source-controller -n cozy-fluxcd
9+
```

‎packages/apps/postgres/README.md‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,34 @@ PostgreSQL is currently the leading choice among relational databases, known for
66

77
This managed service is controlled by the CloudNativePG operator, ensuring efficient management and seamless operation.
88

9-
- Docs: https://cloudnative-pg.io/docs/
10-
- Github: https://github.com/cloudnative-pg/cloudnative-pg
9+
- Docs: <https://cloudnative-pg.io/docs/>
10+
- Github: <https://github.com/cloudnative-pg/cloudnative-pg>
1111

1212
## HowTos
1313

1414
### How to switch master/slave replica
1515

1616
See:
17-
- https://cloudnative-pg.io/documentation/1.15/rolling_update/#manual-updates-supervised
1817

19-
### How to restore backup:
18+
- <https://cloudnative-pg.io/documentation/1.15/rolling_update/#manual-updates-supervised>
19+
20+
### How to restore backup
2021

2122
find snapshot:
22-
```
23+
24+
```bash
2325
restic -r s3:s3.example.org/postgres-backups/database_name snapshots
2426
```
2527

2628
restore:
27-
```
29+
30+
```bash
2831
restic -r s3:s3.example.org/postgres-backups/database_name restore latest --target /tmp/
2932
```
3033

3134
more details:
32-
- https://itnext.io/restic-effective-backup-from-stdin-4bc1e8f083c1
35+
36+
- <https://itnext.io/restic-effective-backup-from-stdin-4bc1e8f083c1>
3337

3438
## Parameters
3539

@@ -64,5 +68,3 @@ more details:
6468
| `backup.s3AccessKey` | The access key for S3, used for authentication | `oobaiRus9pah8PhohL1ThaeTa4UVa7gu` |
6569
| `backup.s3SecretKey` | The secret key for S3, used for authentication | `ju3eum4dekeich9ahM1te8waeGai0oog` |
6670
| `backup.resticPassword` | The password for Restic backup encryption | `ChaXoveekoh6eigh4siesheeda2quai0` |
67-
68-

‎packages/apps/postgres/templates/init-script.yaml‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ stringData:
3434
init.sh: |
3535
#!/bin/bash
3636
set -e
37+
38+
until pg_isready ; do sleep 5; done
39+
3740
echo "== create users"
3841
{{- if .Values.users }}
3942
psql -v ON_ERROR_STOP=1 <<\EOT
@@ -60,7 +63,7 @@ stringData:
6063
DROP USER $user;
6164
EOT
6265
done
63-
66+
6467
echo "== create databases and roles"
6568
{{- if .Values.databases }}
6669
psql -v ON_ERROR_STOP=1 --echo-all <<\EOT
@@ -92,7 +95,7 @@ stringData:
9295
FOR schema_record IN SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN ('pg_catalog', 'information_schema') LOOP
9396
-- Changing Schema Ownership
9497
EXECUTE format('ALTER SCHEMA %I OWNER TO %I', schema_record.schema_name, '{{ $database }}_admin');
95-
98+
9699
-- Add rights for the admin role
97100
EXECUTE format('GRANT ALL ON SCHEMA %I TO %I', schema_record.schema_name, '{{ $database }}_admin');
98101
EXECUTE format('GRANT ALL ON ALL TABLES IN SCHEMA %I TO %I', schema_record.schema_name, '{{ $database }}_admin');
@@ -101,7 +104,7 @@ stringData:
101104
EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON TABLES TO %I', schema_record.schema_name, '{{ $database }}_admin');
102105
EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON SEQUENCES TO %I', schema_record.schema_name, '{{ $database }}_admin');
103106
EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON FUNCTIONS TO %I', schema_record.schema_name, '{{ $database }}_admin');
104-
107+
105108
-- Add rights for the readonly role
106109
EXECUTE format('GRANT USAGE ON SCHEMA %I TO %I', schema_record.schema_name, '{{ $database }}_readonly');
107110
EXECUTE format('GRANT SELECT ON ALL TABLES IN SCHEMA %I TO %I', schema_record.schema_name, '{{ $database }}_readonly');
@@ -119,9 +122,9 @@ stringData:
119122
CREATE OR REPLACE FUNCTION auto_grant_schema_privileges()
120123
RETURNS event_trigger LANGUAGE plpgsql AS $$
121124
DECLARE
122-
obj record;
125+
obj record;
123126
BEGIN
124-
FOR obj IN SELECT * FROM pg_event_trigger_ddl_commands() WHERE command_tag = 'CREATE SCHEMA' LOOP
127+
FOR obj IN SELECT * FROM pg_event_trigger_ddl_commands() WHERE command_tag = 'CREATE SCHEMA' LOOP
125128
EXECUTE format('ALTER SCHEMA %I OWNER TO %I', obj.object_identity, '{{ $database }}_admin');
126129
EXECUTE format('GRANT ALL ON SCHEMA %I TO %I', obj.object_identity, '{{ $database }}_admin');
127130
EXECUTE format('GRANT USAGE ON SCHEMA %I TO %I', obj.object_identity, '{{ $database }}_readonly');
@@ -146,7 +149,7 @@ stringData:
146149
EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT SELECT ON TABLES TO %I', obj.object_identity, '{{ $database }}_readonly');
147150
EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT USAGE ON SEQUENCES TO %I', obj.object_identity, '{{ $database }}_readonly');
148151
EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT EXECUTE ON FUNCTIONS TO %I', obj.object_identity, '{{ $database }}_readonly');
149-
END LOOP;
152+
END LOOP;
150153
END;
151154
$$;
152155

‎packages/core/installer/Makefile‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
NAME=installer
22
NAMESPACE=cozy-system
3+
YQ_VERSION=v4.35.1
4+
RED = \033[31m
5+
RESET = \033[0m
36

47
TALOS_VERSION=$(shell awk '/^version:/ {print $$2}' images/talos/profiles/installer.yaml)
58

@@ -17,22 +20,36 @@ diff:
1720
update:
1821
hack/gen-profiles.sh
1922

20-
image: image-cozystack image-talos image-matchbox
23+
image: check-yq-version image-cozystack image-talos image-matchbox
24+
25+
check-yq-version:
26+
@current_version=$$(yq -V | grep -oP 'v[0-9]+\.[0-9]+\.[0-9]+') ; \
27+
if [ -z "$$current_version" ]; then \
28+
echo "yq is not installed or version cannot be determined." ; \
29+
exit 1 ; \
30+
fi ; \
31+
echo "Current yq version: $$current_version" ; \
32+
if [ "$$(printf '%s\n' "$(YQ_VERSION)" "$$current_version" | sort -V | head -n1)" = "$(YQ_VERSION)" ]; then \
33+
echo "Greater than or equal to $(YQ_VERSION)" ; \
34+
else \
35+
echo "$(RED)ERROR: yq version less than $(YQ_VERSION)$(RESET)" ; \
36+
exit 1 ; \
37+
fi
2138

2239
image-cozystack:
2340
make -C ../../.. repos
2441
docker buildx build -f images/cozystack/Dockerfile ../../.. \
2542
--provenance false \
2643
--tag $(REGISTRY)/cozystack:$(call settag,$(TAG)) \
2744
--cache-from type=registry,ref=$(REGISTRY)/cozystack:latest \
28-
--platform linux/amd64,linux/arm64 \
45+
--platform linux/amd64 \
2946
--cache-to type=inline \
3047
--metadata-file images/cozystack.json \
3148
--push=$(PUSH) \
3249
--load=$(LOAD)
3350
IMAGE="$(REGISTRY)/cozystack:$(call settag,$(TAG))@$$(yq e '."containerimage.digest"' images/cozystack.json -o json -r)" \
3451
yq -i '.cozystack.image = strenv(IMAGE)' values.yaml
35-
rm -f images/cozystack.json
52+
3653

3754
image-talos:
3855
test -f ../../../_out/assets/installer-amd64.tar || make talos-installer
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"buildx.build.provenance": {
3+
"buildType": "https://mobyproject.org/buildkit@v1",
4+
"materials": [
5+
{
6+
"uri": "pkg:docker/[email protected]?platform=linux%2Famd64",
7+
"digest": {
8+
"sha256": "ae65dbf8749a7d4527648ccee1fa3deb6bfcae34cbc30fc67aa45c44dcaa90ee"
9+
}
10+
},
11+
{
12+
"uri": "pkg:docker/[email protected]?platform=linux%2Famd64",
13+
"digest": {
14+
"sha256": "f6392ffebb028fed5ffe743ddb9716e38402c978779edd66474bb5d05f5e65e4"
15+
}
16+
}
17+
],
18+
"invocation": {
19+
"configSource": {
20+
"entryPoint": "Dockerfile"
21+
},
22+
"parameters": {
23+
"frontend": "dockerfile.v0",
24+
"locals": [
25+
{
26+
"name": "context"
27+
},
28+
{
29+
"name": "dockerfile"
30+
}
31+
]
32+
},
33+
"environment": {
34+
"platform": "linux/amd64"
35+
}
36+
}
37+
},
38+
"buildx.build.ref": "default/default/0xfyd6oaq6jf2ad1uyltla63y",
39+
"containerimage.config.digest": "sha256:18de848878b8ae2fddaa05c199b7679b305d7666049e21c2e81a01a6e95bd05c",
40+
"containerimage.digest": "sha256:734e5cf818dbf886c165a49dbbd2776efc87adae046cf5f24f1d0ae98ea16dbe",
41+
"image.name": "docker.io/kklinch0/cozystack:latest"
42+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
cozystack:
2-
image: ghcr.io/aenix-io/cozystack/cozystack:v0.16.4@sha256:e2de79d1dd00a95a6876f6e4daf281eb27e8cc9d57fa2e9ea137192b544d38a7
2+
image: kklinch0/cozystack:latest@sha256:734e5cf818dbf886c165a49dbbd2776efc87adae046cf5f24f1d0ae98ea16dbe

0 commit comments

Comments
 (0)