Skip to content

Commit 4a0fb0c

Browse files
authored
feat(postgresdatabase): add option to specify collaction during creation (#370)
* feat(postgresdatabase): add option to specify collation during creation * feat(postgresdatabase): use new api package to ensure postgres collation function
1 parent 3262d42 commit 4a0fb0c

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

create/postgresdatabase.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type postgresDatabaseCmd struct {
2020
Location meta.LocationName `placeholder:"${postgresdatabase_location_default}" help:"Where the PostgreSQL database is created. Available locations are: ${postgresdatabase_location_options}"`
2121
PostgresDatabaseVersion storage.PostgresVersion `placeholder:"${postgresdatabase_version_default}" help:"Release version with which the PostgreSQL database is created. Available versions: ${postgresdatabase_versions}"`
2222
BackupSchedule storage.DatabaseBackupScheduleCalendar `placeholder:"${postgresdatabase_backupschedule_default}" help:"Backup schedule for the PostgreSQL database. Available schedules: ${postgresdatabase_backupschedule_options}"`
23+
Collation storage.PostgresDatabaseCollation `placeholder:"${postgresdatabase_collation_default}" help:"Collation for the PostgreSQL database. Defaults to ${postgresdatabase_collation_default}."`
2324
}
2425

2526
func (cmd *postgresDatabaseCmd) Run(ctx context.Context, client *api.Client) error {
@@ -77,6 +78,7 @@ func (cmd *postgresDatabaseCmd) newPostgresDatabase(namespace string) *storage.P
7778
Location: cmd.Location,
7879
Version: cmd.PostgresDatabaseVersion,
7980
BackupSchedule: cmd.BackupSchedule,
81+
Collation: cmd.Collation,
8082
},
8183
},
8284
}
@@ -94,6 +96,7 @@ func PostgresDatabaseKongVars() kong.Vars {
9496
result["postgresdatabase_versions"] = strings.Join(stringSlice(storage.PostgresDatabaseVersions), ", ")
9597
result["postgresdatabase_backupschedule_default"] = string(storage.DatabaseBackupScheduleCalendarDaily)
9698
result["postgresdatabase_backupschedule_options"] = strings.Join(stringSlice(storage.DatabaseBackupScheduleCalendars), ", ")
99+
result["postgresdatabase_collation_default"] = string(storage.PostgresDatabaseCollationDefault)
97100

98101
return result
99102
}

create/postgresdatabase_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ func TestPostgresDatabase(t *testing.T) {
4646
create: postgresDatabaseCmd{PostgresDatabaseVersion: storage.PostgresDatabaseVersionDefault},
4747
want: storage.PostgresDatabaseParameters{Version: storage.PostgresDatabaseVersionDefault},
4848
},
49+
{
50+
name: "collation",
51+
create: postgresDatabaseCmd{Collation: storage.PostgresDatabaseCollationDefault},
52+
want: storage.PostgresDatabaseParameters{Collation: storage.PostgresDatabaseCollationDefault},
53+
},
4954
}
5055
for _, tt := range tests {
5156
t.Run(tt.name, func(t *testing.T) {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ require (
2626
github.com/mattn/go-isatty v0.0.20
2727
github.com/moby/moby v28.5.2+incompatible
2828
github.com/moby/term v0.5.2
29-
github.com/ninech/apis v0.0.0-20260316095939-ab01e6b90a08
29+
github.com/ninech/apis v0.0.0-20260323072937-a0eae39a8cad
3030
github.com/posener/complete v1.2.3
3131
github.com/prometheus/common v0.67.5
3232
github.com/stretchr/testify v1.11.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+
596596
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
597597
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=
598598
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
599-
github.com/ninech/apis v0.0.0-20260316095939-ab01e6b90a08 h1:07+khA9+YETBBGmZKZJvRfk4KJY+ujY0Rzyip6yggzI=
600-
github.com/ninech/apis v0.0.0-20260316095939-ab01e6b90a08/go.mod h1:CywI3hJ18Q6NdyiSj17ONbGSCexCu8YPyFm5UQyrvmw=
599+
github.com/ninech/apis v0.0.0-20260323072937-a0eae39a8cad h1:16z1fl4Sb9eRqV589fm5GMgbJj3pE34S3X7A0Al06Wo=
600+
github.com/ninech/apis v0.0.0-20260323072937-a0eae39a8cad/go.mod h1:CywI3hJ18Q6NdyiSj17ONbGSCexCu8YPyFm5UQyrvmw=
601601
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
602602
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
603603
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=

0 commit comments

Comments
 (0)