Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct the organisation name #108

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .flyctl/cmd/pg-failover/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"time"

"github.com/fly-examples/postgres-ha/pkg/flypg/stolon"
"github.com/fly-examples/postgres-ha/pkg/util"
"github.com/fly-apps/postgres-ha/pkg/flypg/stolon"
"github.com/fly-apps/postgres-ha/pkg/util"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion .flyctl/cmd/pg-restart/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os/exec"

"github.com/fly-examples/postgres-ha/pkg/util"
"github.com/fly-apps/postgres-ha/pkg/util"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions .flyctl/cmd/pg-role/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"net/http"
"strings"

"github.com/fly-examples/postgres-ha/pkg/privnet"
"github.com/fly-examples/postgres-ha/pkg/util"
"github.com/fly-apps/postgres-ha/pkg/privnet"
"github.com/fly-apps/postgres-ha/pkg/util"
)

func main() {
Expand Down
10 changes: 5 additions & 5 deletions .flyctl/cmd/pg-settings/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"os"
"strings"

"github.com/fly-examples/postgres-ha/pkg/flypg"
"github.com/fly-examples/postgres-ha/pkg/util"
"github.com/fly-apps/postgres-ha/pkg/flypg"
"github.com/fly-apps/postgres-ha/pkg/util"
)

func main() {
Expand Down Expand Up @@ -38,9 +38,9 @@ func main() {

sValues := "'" + strings.Join(sList, "', '") + "'"

sql := fmt.Sprintf(`select
name, setting, vartype, min_val, max_val, enumvals, context, unit, short_desc, pending_restart
FROM pg_settings WHERE name IN (%s);
sql := fmt.Sprintf(`select
name, setting, vartype, min_val, max_val, enumvals, context, unit, short_desc, pending_restart
FROM pg_settings WHERE name IN (%s);
`, sValues)

rows, err := conn.Query(context.Background(), sql)
Expand Down
4 changes: 2 additions & 2 deletions .flyctl/cmd/stolonctl-run/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"encoding/base64"

"github.com/fly-examples/postgres-ha/pkg/flypg/stolon"
"github.com/fly-examples/postgres-ha/pkg/util"
"github.com/fly-apps/postgres-ha/pkg/flypg/stolon"
"github.com/fly-apps/postgres-ha/pkg/util"
"github.com/google/shlex"
)

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG VERSION=custom
FROM golang:1.16 as flyutil
ARG VERSION

WORKDIR /go/src/github.com/fly-examples/postgres-ha
WORKDIR /go/src/github.com/fly-apps/postgres-ha
COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/flyadmin ./cmd/flyadmin
Expand All @@ -23,7 +23,7 @@ FROM flyio/stolon:327008e as stolon
FROM wrouesnel/postgres_exporter:latest AS postgres_exporter

FROM postgres:${PG_VERSION}
ARG VERSION
ARG VERSION
ARG POSTGIS_MAJOR=3
ARG WALG_VERSION=2.0.0

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile-timescaledb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG VERSION=custom
FROM golang:1.16 as flyutil
ARG VERSION

WORKDIR /go/src/github.com/fly-examples/postgres-ha
WORKDIR /go/src/github.com/fly-apps/postgres-ha
COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/flyadmin ./cmd/flyadmin
Expand All @@ -23,7 +23,7 @@ FROM flyio/stolon:327008e as stolon
FROM wrouesnel/postgres_exporter:latest AS postgres_exporter

FROM postgres:${PG_VERSION}
ARG VERSION
ARG VERSION
ARG POSTGIS_MAJOR=3
ARG WALG_VERSION=2.0.0

Expand Down
8 changes: 4 additions & 4 deletions cmd/start/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
"syscall"
"time"

"github.com/fly-examples/postgres-ha/pkg/flypg"
"github.com/fly-examples/postgres-ha/pkg/flypg/admin"
"github.com/fly-examples/postgres-ha/pkg/flyunlock"
"github.com/fly-examples/postgres-ha/pkg/supervisor"
"github.com/fly-apps/postgres-ha/pkg/flypg"
"github.com/fly-apps/postgres-ha/pkg/flypg/admin"
"github.com/fly-apps/postgres-ha/pkg/flyunlock"
"github.com/fly-apps/postgres-ha/pkg/supervisor"
"github.com/jackc/pgx/v4"
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/fly-examples/postgres-ha
module github.com/fly-apps/postgres-ha

go 1.16

Expand Down
13 changes: 7 additions & 6 deletions pkg/commands/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ package commands
import (
"encoding/json"
"fmt"
"github.com/fly-examples/postgres-ha/pkg/flypg"
"github.com/pkg/errors"
"io"
"net/http"
"os/exec"
"time"

"github.com/fly-examples/postgres-ha/pkg/flypg/admin"
"github.com/fly-examples/postgres-ha/pkg/flypg/stolon"
"github.com/fly-examples/postgres-ha/pkg/render"
"github.com/fly-examples/postgres-ha/pkg/util"
"github.com/fly-apps/postgres-ha/pkg/flypg"
"github.com/pkg/errors"

"github.com/fly-apps/postgres-ha/pkg/flypg/admin"
"github.com/fly-apps/postgres-ha/pkg/flypg/stolon"
"github.com/fly-apps/postgres-ha/pkg/render"
"github.com/fly-apps/postgres-ha/pkg/util"
)

func handleFailoverTrigger(w http.ResponseWriter, r *http.Request) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/commands/dbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"encoding/json"
"net/http"

"github.com/fly-examples/postgres-ha/pkg/flypg/admin"
"github.com/fly-examples/postgres-ha/pkg/render"
"github.com/fly-apps/postgres-ha/pkg/flypg/admin"
"github.com/fly-apps/postgres-ha/pkg/render"
"github.com/go-chi/chi/v5"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/commands/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"net/http"

"github.com/fly-examples/postgres-ha/pkg/flypg"
"github.com/fly-examples/postgres-ha/pkg/flypg/stolon"
"github.com/fly-apps/postgres-ha/pkg/flypg"
"github.com/fly-apps/postgres-ha/pkg/flypg/stolon"
"github.com/go-chi/chi/v5"
"github.com/jackc/pgx/v4"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/commands/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"encoding/json"
"net/http"

"github.com/fly-examples/postgres-ha/pkg/flypg/admin"
"github.com/fly-examples/postgres-ha/pkg/render"
"github.com/fly-apps/postgres-ha/pkg/flypg/admin"
"github.com/fly-apps/postgres-ha/pkg/render"
"github.com/go-chi/chi/v5"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/flycheck/pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"strings"
"time"

"github.com/fly-examples/postgres-ha/pkg/flypg"
"github.com/fly-examples/postgres-ha/pkg/privnet"
"github.com/fly-apps/postgres-ha/pkg/flypg"
"github.com/fly-apps/postgres-ha/pkg/privnet"
"github.com/pkg/errors"
chk "github.com/superfly/fly-checks/check"

Expand Down
5 changes: 3 additions & 2 deletions pkg/flycheck/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package flycheck
import (
"context"
"fmt"

chk "github.com/superfly/fly-checks/check"

"github.com/fly-examples/postgres-ha/pkg/flypg"
"github.com/fly-examples/postgres-ha/pkg/flypg/admin"
"github.com/fly-apps/postgres-ha/pkg/flypg"
"github.com/fly-apps/postgres-ha/pkg/flypg/admin"
"github.com/pkg/errors"
)

Expand Down
51 changes: 26 additions & 25 deletions pkg/flypg/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"context"
"crypto/md5"
"fmt"
"github.com/pkg/errors"
"os"
"strings"

"github.com/fly-examples/postgres-ha/pkg/flypg"
"github.com/pkg/errors"

"github.com/fly-apps/postgres-ha/pkg/flypg"
"github.com/jackc/pgx/v4"
)

Expand Down Expand Up @@ -60,8 +61,8 @@ func ChangePassword(ctx context.Context, pg *pgx.Conn, username, password string
func ListDatabases(ctx context.Context, pg *pgx.Conn) ([]DbInfo, error) {
sql := `
SELECT d.datname,
(SELECT array_agg(u.usename::text order by u.usename)
from pg_user u
(SELECT array_agg(u.usename::text order by u.usename)
from pg_user u
where has_database_privilege(u.usename, d.datname, 'CONNECT')) as allowed_users
from pg_database d where d.datistemplate = false
order by d.datname;
Expand Down Expand Up @@ -119,10 +120,10 @@ func ListUsers(ctx context.Context, pg *pgx.Conn) ([]UserInfo, error) {
from pg_database d
WHERE datistemplate = false
AND has_database_privilege(u.usename, d.datname, 'CONNECT')
) as
) as
allowed_databases
from
pg_user u join pg_authid a on u.usesysid = a.oid
from
pg_user u join pg_authid a on u.usesysid = a.oid
order by u.usename
`

Expand All @@ -147,20 +148,20 @@ func ListUsers(ctx context.Context, pg *pgx.Conn) ([]UserInfo, error) {

func FindUser(ctx context.Context, pg *pgx.Conn, username string) (*UserInfo, error) {
sql := `
select
select
u.usename,
usesuper as superuser,
userepl as repluser,
a.rolpassword as passwordhash,
(
SELECT
SELECT
array_agg(d.datname::text order by d.datname)
from pg_database d
WHERE datistemplate = false AND has_database_privilege(u.usename, d.datname, 'CONNECT')
) AS
) AS
allowed_databases
FROM
pg_user u join pg_authid a on u.usesysid = a.oid
FROM
pg_user u join pg_authid a on u.usesysid = a.oid
WHERE u.usename='%s';`

sql = fmt.Sprintf(sql, username)
Expand Down Expand Up @@ -211,9 +212,9 @@ func DeleteDatabase(ctx context.Context, pg *pgx.Conn, name string) error {

func FindDatabase(ctx context.Context, pg *pgx.Conn, name string) (*DbInfo, error) {
sql := `
SELECT
datname,
(SELECT array_agg(u.usename::text order by u.usename) FROM pg_user u WHERE has_database_privilege(u.usename, d.datname, 'CONNECT')) as allowed_users
SELECT
datname,
(SELECT array_agg(u.usename::text order by u.usename) FROM pg_user u WHERE has_database_privilege(u.usename, d.datname, 'CONNECT')) as allowed_users
FROM pg_database d WHERE d.datname='%s';
`

Expand Down Expand Up @@ -315,16 +316,16 @@ func ResolveSettings(ctx context.Context, pg *pgx.Conn, list []string) (*flypg.S

sql := fmt.Sprintf(`
SELECT
name,
setting,
vartype,
min_val,
max_val,
enumvals,
context,
unit,
short_desc,
pending_restart
name,
setting,
vartype,
min_val,
max_val,
enumvals,
context,
unit,
short_desc,
pending_restart
FROM pg_settings WHERE name IN (%s);`, sValues)

rows, err := pg.Query(ctx, sql)
Expand Down
2 changes: 1 addition & 1 deletion pkg/flypg/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strconv"
"strings"

"github.com/fly-examples/postgres-ha/pkg/privnet"
"github.com/fly-apps/postgres-ha/pkg/privnet"
"github.com/jackc/pgx/v4"
"github.com/pkg/errors"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/flypg/stolon.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os/exec"
"strings"

"github.com/fly-examples/postgres-ha/pkg/flypg/stolon"
"github.com/fly-apps/postgres-ha/pkg/flypg/stolon"
"github.com/pkg/errors"
)

Expand Down
6 changes: 3 additions & 3 deletions pkg/flyunlock/unlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"strings"
"time"

"github.com/fly-examples/postgres-ha/pkg/flypg/admin"
"github.com/fly-examples/postgres-ha/pkg/privnet"
"github.com/fly-examples/postgres-ha/pkg/supervisor"
"github.com/fly-apps/postgres-ha/pkg/flypg/admin"
"github.com/fly-apps/postgres-ha/pkg/privnet"
"github.com/fly-apps/postgres-ha/pkg/supervisor"
"github.com/jackc/pgx/v4"
"github.com/pkg/errors"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"net/http"

"github.com/fly-examples/postgres-ha/pkg/commands"
"github.com/fly-examples/postgres-ha/pkg/flycheck"
"github.com/fly-apps/postgres-ha/pkg/commands"
"github.com/fly-apps/postgres-ha/pkg/flycheck"
"github.com/go-chi/chi/v5"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"syscall"
"time"

"github.com/fly-examples/postgres-ha/pkg/server"
"github.com/fly-apps/postgres-ha/pkg/server"
"github.com/google/shlex"
"golang.org/x/sync/errgroup"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"path/filepath"

"github.com/fly-examples/postgres-ha/pkg/flypg"
"github.com/fly-apps/postgres-ha/pkg/flypg"
)

func BuildEnv() ([]string, error) {
Expand Down