Skip to content

Commit

Permalink
do not create public
Browse files Browse the repository at this point in the history
  • Loading branch information
romg67 committed Sep 11, 2024
1 parent 00243d3 commit 82168e0
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions pkg/controller/postgres/postgres_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,13 @@ func (r *ReconcilePostgres) Reconcile(request reconcile.Request) (_ reconcile.Re
continue
}

// Create schema
err = r.pg.CreateSchema(database, owner, schema, reqLogger)
if err != nil {
reqLogger.Error(err, fmt.Sprintf("Could not create schema %s", schema))
continue
if schema != "public" {
// Create schema
err = r.pg.CreateSchema(database, owner, schema, reqLogger)
if err != nil {
reqLogger.Error(err, fmt.Sprintf("Could not create schema %s", schema))
continue
}
}

// Set privileges on schema
Expand All @@ -238,13 +240,7 @@ func (r *ReconcilePostgres) Reconcile(request reconcile.Request) (_ reconcile.Re
reqLogger.Error(err, fmt.Sprintf("Could not give %s permissions for sequnces \"%s\"", writer, "USAGE"))
continue
}
// ownerCreateSchema := true
reqLogger.Info(fmt.Sprintf("schema is %s", schema))
if schema == "public" {
reqLogger.Info("schema is public, skipping creation")
// ownerCreateSchema = false
}
schemaPrivilegesOwner := postgres.PostgresSchemaPrivileges{database, owner, schema, readerPrivs, false}
schemaPrivilegesOwner := postgres.PostgresSchemaPrivileges{database, owner, schema, readerPrivs, true}
err = r.pg.SetSchemaPrivileges(schemaPrivilegesOwner, reqLogger)
if err != nil {
reqLogger.Error(err, fmt.Sprintf("Could not give %s permissions \"%s\"", writer, writerPrivs))
Expand Down

0 comments on commit 82168e0

Please sign in to comment.