Skip to content

Commit

Permalink
Merge pull request #82 from irfanhakim-as/postgres-agent-fix
Browse files Browse the repository at this point in the history
Postgres-Agent: Fix special characters
  • Loading branch information
irfanhakim-as authored Jun 30, 2024
2 parents 579e1d2 + a824804 commit 19f403d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion mika/postgres-agent/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: postgres-agent
description: Easily create or delete a database and user pair in a remote PostgreSQL instance.
type: application
version: 0.3.0
version: 0.3.1
appVersion: "16.3.0-debian-12-r12"
keywords:
- "postgresql"
Expand Down
22 changes: 11 additions & 11 deletions mika/postgres-agent/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ spec:
args:
- -c
- >-
psql -h $(DB_HOST) -U $(ROOT_USER) -d {{ $rootDB }} <<EOF
psql -h $(DB_HOST) -U $(ROOT_USER) -d {{ $rootDB | quote }} <<EOF
{{- range $databases }}
{{- if .create }}
CREATE USER {{ .user }} WITH ENCRYPTED PASSWORD '{{ .password }}';
CREATE DATABASE {{ .name }};
GRANT ALL ON DATABASE {{ .name }} TO {{ .user }};
ALTER DATABASE {{ .name }} OWNER TO {{ .user }};
GRANT USAGE, CREATE ON SCHEMA PUBLIC TO {{ .user }};
CREATE USER {{ .user | quote }} WITH ENCRYPTED PASSWORD '{{ .password }}';
CREATE DATABASE {{ .name | quote }};
GRANT ALL ON DATABASE {{ .name | quote }} TO {{ .user | quote }};
ALTER DATABASE {{ .name | quote }} OWNER TO {{ .user | quote }};
GRANT USAGE, CREATE ON SCHEMA PUBLIC TO {{ .user | quote }};
{{- else if .drop }}
DROP DATABASE IF EXISTS {{ .name }};
REVOKE ALL ON SCHEMA PUBLIC FROM {{ .user }};
DROP USER IF EXISTS {{ .user }};
DROP DATABASE IF EXISTS {{ .name | quote }};
REVOKE ALL ON SCHEMA PUBLIC FROM {{ .user | quote }};
DROP USER IF EXISTS {{ .user | quote }};
{{- end }}
{{- if and .custom .custom_command }}
\connect {{ .name }};
\connect {{ .name | quote }};
{{- .custom_command | replace "$.name" .name | replace "$.user" .user | replace "$.password" .password | nindent 16 }}
\connect {{ $rootDB }};
\connect {{ $rootDB | quote }};
{{- end }}
{{- end }}
EOF
Expand Down

0 comments on commit 19f403d

Please sign in to comment.