From 93051763aa6d21bac80bb8177f929dfd55e65cf0 Mon Sep 17 00:00:00 2001 From: Ulrich Schreiner Date: Wed, 7 May 2025 15:55:07 +0200 Subject: [PATCH 1/2] zalando does not support RFC3339 --- api/v1/postgres_types.go | 4 +++- api/v1/postgres_types_test.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/v1/postgres_types.go b/api/v1/postgres_types.go index 328ef27a..b62008d6 100644 --- a/api/v1/postgres_types.go +++ b/api/v1/postgres_types.go @@ -102,6 +102,8 @@ const ( PostgresConfigReplicationUsername = "standby" PostgresConfigAuditorUsername = "auditor" PostgresConfigMonitoringUsername = "monitoring" + + ZALANDO_TIMESTAMP_FORMAT = "2006-01-02T15:04:05-07:00" ) var ( @@ -762,7 +764,7 @@ func (p *Postgres) ToUnstructuredZalandoPostgresql(z *zalando.Postgresql, c *cor // make sure there is always a value set. The operator will fall back to CLONE_WITH_BASEBACKUP, which assumes the source db's credentials are existing within the same namespace, which is not the case with the postgreslet. if p.Spec.PostgresRestore.Timestamp == "" { // e.g. 2021-12-07T15:28:00+01:00 - p.Spec.PostgresRestore.Timestamp = time.Now().Format(time.RFC3339) + p.Spec.PostgresRestore.Timestamp = time.Now().Format(ZALANDO_TIMESTAMP_FORMAT) } z.Spec.Clone = &zalando.CloneDescription{ diff --git a/api/v1/postgres_types_test.go b/api/v1/postgres_types_test.go index cc68c50e..98a7dc38 100644 --- a/api/v1/postgres_types_test.go +++ b/api/v1/postgres_types_test.go @@ -257,7 +257,7 @@ func TestPostgresRestoreTimestamp_ToUnstructuredZalandoPostgresql(t *testing.T) Description: "description", }, }, - want: time.Now().Format(time.RFC3339), // I know this is not perfect, let's just hope we always finish within the same second... + want: time.Now().Format(ZALANDO_TIMESTAMP_FORMAT), // I know this is not perfect, let's just hope we always finish within the same second... wantErr: false, }, { @@ -283,7 +283,7 @@ func TestPostgresRestoreTimestamp_ToUnstructuredZalandoPostgresql(t *testing.T) Description: "description", }, }, - want: time.Now().Format(time.RFC3339), // I know this is not perfect, let's just hope we always finish within the same second... + want: time.Now().Format(ZALANDO_TIMESTAMP_FORMAT), // I know this is not perfect, let's just hope we always finish within the same second... wantErr: false, }, { From fc3a9efb4a4311f77a5b6597f5cd11e8a6af550f Mon Sep 17 00:00:00 2001 From: Ulrich Schreiner Date: Wed, 7 May 2025 16:21:41 +0200 Subject: [PATCH 2/2] do not export this contant --- api/v1/postgres_types.go | 4 ++-- api/v1/postgres_types_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/v1/postgres_types.go b/api/v1/postgres_types.go index b62008d6..212a1c8c 100644 --- a/api/v1/postgres_types.go +++ b/api/v1/postgres_types.go @@ -103,7 +103,7 @@ const ( PostgresConfigAuditorUsername = "auditor" PostgresConfigMonitoringUsername = "monitoring" - ZALANDO_TIMESTAMP_FORMAT = "2006-01-02T15:04:05-07:00" + zalando_timestamp_format = "2006-01-02T15:04:05-07:00" ) var ( @@ -764,7 +764,7 @@ func (p *Postgres) ToUnstructuredZalandoPostgresql(z *zalando.Postgresql, c *cor // make sure there is always a value set. The operator will fall back to CLONE_WITH_BASEBACKUP, which assumes the source db's credentials are existing within the same namespace, which is not the case with the postgreslet. if p.Spec.PostgresRestore.Timestamp == "" { // e.g. 2021-12-07T15:28:00+01:00 - p.Spec.PostgresRestore.Timestamp = time.Now().Format(ZALANDO_TIMESTAMP_FORMAT) + p.Spec.PostgresRestore.Timestamp = time.Now().Format(zalando_timestamp_format) } z.Spec.Clone = &zalando.CloneDescription{ diff --git a/api/v1/postgres_types_test.go b/api/v1/postgres_types_test.go index 98a7dc38..ba3a92b3 100644 --- a/api/v1/postgres_types_test.go +++ b/api/v1/postgres_types_test.go @@ -257,7 +257,7 @@ func TestPostgresRestoreTimestamp_ToUnstructuredZalandoPostgresql(t *testing.T) Description: "description", }, }, - want: time.Now().Format(ZALANDO_TIMESTAMP_FORMAT), // I know this is not perfect, let's just hope we always finish within the same second... + want: time.Now().Format(zalando_timestamp_format), // I know this is not perfect, let's just hope we always finish within the same second... wantErr: false, }, { @@ -283,7 +283,7 @@ func TestPostgresRestoreTimestamp_ToUnstructuredZalandoPostgresql(t *testing.T) Description: "description", }, }, - want: time.Now().Format(ZALANDO_TIMESTAMP_FORMAT), // I know this is not perfect, let's just hope we always finish within the same second... + want: time.Now().Format(zalando_timestamp_format), // I know this is not perfect, let's just hope we always finish within the same second... wantErr: false, }, {