Skip to content

Commit

Permalink
add by default public
Browse files Browse the repository at this point in the history
  • Loading branch information
romg67 committed Sep 9, 2024
1 parent f8a5cbe commit a4eff60
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Publish Container Image
on:
push:
branches:
- 'main'
- '*'
tags:
- '*'
workflow_dispatch:
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/postgres/postgres_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (r *ReconcilePostgres) Reconcile(request reconcile.Request) (_ reconcile.Re
readerPrivs = "SELECT"
writerPrivs = "SELECT,INSERT,DELETE,UPDATE"
)
for _, schema := range instance.Spec.Schemas {
for _, schema := range append(instance.Spec.Schemas, "public") {
// Schema was previously created
if utils.ListContains(instance.Status.Schemas, schema) {
continue
Expand All @@ -226,14 +226,14 @@ func (r *ReconcilePostgres) Reconcile(request reconcile.Request) (_ reconcile.Re
reqLogger.Error(err, fmt.Sprintf("Could not give %s permissions \"%s\"", reader, readerPrivs))
continue
}
reqLogger.Info("about to give writer %s permissions", writer)
schemaPrivilegesWriter := postgres.PostgresSchemaPrivileges{database, owner, writer, schema, writerPrivs, true}
reqLogger.Info(fmt.Sprintf("about to give writer %s permissions", writer))
schemaPrivilegesWriter := postgres.PostgresSchemaPrivileges{database, owner, writer, schema, writerPrivs, false}
err = r.pg.SetSchemaPrivileges(schemaPrivilegesWriter, reqLogger)
if err != nil {
reqLogger.Error(err, fmt.Sprintf("Could not give %s permissions \"%s\"", writer, writerPrivs))
continue
}
sequncesPrivilegesWriter := postgres.PostgresSequncesPrivileges{database, owner, writer, schema, writerPrivs}
sequncesPrivilegesWriter := postgres.PostgresSequncesPrivileges{database, owner, writer, schema, "USAGE"}
err = r.pg.SetSequncesPrivileges(sequncesPrivilegesWriter, reqLogger)
if err != nil {
reqLogger.Error(err, fmt.Sprintf("Could not give %s permissions for sequnces \"%s\"", writer, writerPrivs))
Expand Down
4 changes: 2 additions & 2 deletions pkg/postgres/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ func (c *pg) SetSchemaPrivileges(schemaPrivileges PostgresSchemaPrivileges, logg
if err != nil {
return err
}
logger.Info("about to give permissions of %s to %s", schemaPrivileges.Privs, schemaPrivileges.Role)
logger.Info(fmt.Sprintf("about to give permissions of %s to %s", schemaPrivileges.Privs, schemaPrivileges.Role))
// Grant role privs on existing tables in schema
_, err = tmpDb.Exec(fmt.Sprintf(GRANT_ALL_TABLES, schemaPrivileges.Privs, schemaPrivileges.Schema, schemaPrivileges.Role))
if err != nil {
return err
}
logger.Info("about to give default permissions of %s to %s", schemaPrivileges.Privs, schemaPrivileges.Role)
logger.Info(fmt.Sprintf("about to give default permissions of %s to %s", schemaPrivileges.Privs, schemaPrivileges.Role))
// Grant role privs on future tables in schema
_, err = tmpDb.Exec(fmt.Sprintf(DEFAULT_PRIVS_SCHEMA, schemaPrivileges.Creator, schemaPrivileges.Schema, schemaPrivileges.Privs, schemaPrivileges.Role))
if err != nil {
Expand Down

0 comments on commit a4eff60

Please sign in to comment.