Skip to content
This repository was archived by the owner on Dec 29, 2025. It is now read-only.

Make pg_flo commands take mandatory flags from environment variablesΒ #72

@AbhinavKoul

Description

@AbhinavKoul

Currently, pg_flo commands need the required parameters to be passed in the command even if the environment variables are set for it.

We need to be able to get those from the environment if it is already set.

Current

It throws an error

Error: required flag(s) "group", "nats-url", "source-dbname", "source-host", "source-password", "source-user", "target-dbname", "target-host", "target-password", "target-user" not set
Usage:
  pg_flo worker postgres [flags]
Flags:
  -h, --help                          help for postgres
      --source-dbname string          Source PostgreSQL database name (env: PG_FLO_SOURCE_DBNAME)
      --source-host string            Source PostgreSQL host (env: PG_FLO_SOURCE_HOST)
      --source-password string        Source PostgreSQL password (env: PG_FLO_SOURCE_PASSWORD)
      --source-port int               Source PostgreSQL port (env: PG_FLO_SOURCE_PORT) (default 5432)
required flag(s) "group", "nats-url", "source-dbname", "source-host", "source-password", "source-user", "target-dbname", "target-host", "target-password", "target-user" not set
      --source-user string            Source PostgreSQL user (env: PG_FLO_SOURCE_USER)
      --target-dbname string          Target PostgreSQL database name (env: PG_FLO_TARGET_DBNAME)
      --target-disable-foreign-keys   Disable foreign key constraints on target (env: PG_FLO_TARGET_DISABLE_FOREIGN_KEYS)
      --target-host string            Target PostgreSQL host (env: PG_FLO_TARGET_HOST)
      --target-password string        Target PostgreSQL password (env: PG_FLO_TARGET_PASSWORD)
      --target-port int               Target PostgreSQL port (env: PG_FLO_TARGET_PORT) (default 5432)
      --target-sync-schema            Sync schema to target (env: PG_FLO_TARGET_SYNC_SCHEMA)
      --target-user string            Target PostgreSQL user (env: PG_FLO_TARGET_USER)
Global Flags:
      --batch-size int          Batch size for processing messages (env: PG_FLO_BATCH_SIZE) (default 1000)
      --config string           config file (default is $HOME/.pg_flo.yaml)
      --group string            Group name for worker (env: PG_FLO_GROUP)
      --nats-url string         NATS server URL (env: PG_FLO_NATS_URL)
      --routing-config string   Path to routing configuration file (env: PG_FLO_ROUTING_CONFIG)
      --rules-config string     Path to rules configuration file (env: PG_FLO_RULES_CONFIG)

Similarly for replicator

Error: required flag(s) "dbname", "group", "host", "nats-url", "password", "port", "user" not set
Error marking flag group as required: no such flag -group
Error marking flag nats-url as required: no such flag -nats-url
Usage:
  pg_flo replicator [flags]
Flags:
      --copy                             Enable copy mode without streaming
      --copy-and-stream                  Enable copy and stream mode
      --dbname string                    PostgreSQL database name (env: PG_FLO_DBNAME)
      --group string                     Group name for replication (env: PG_FLO_GROUP)
  -h, --help                             help for replicator
      --host string                      PostgreSQL host (env: PG_FLO_HOST)
      --max-copy-workers-per-table int   Maximum number of copy workers per table (env: PG_FLO_MAX_COPY_WORKERS_PER_TABLE) (default 4)
required flag(s) "dbname", "group", "host", "nats-url", "password", "port", "user" not set
      --nats-url string                  NATS server URL (env: PG_FLO_NATS_URL)
      --password string                  PostgreSQL password (env: PG_FLO_PASSWORD)
      --port int                         PostgreSQL port (env: PG_FLO_PORT) (default 5432)
      --schema string                    PostgreSQL schema (env: PG_FLO_SCHEMA) (default "public")
      --stream                           Enable stream mode (default if no mode specified)
      --tables strings                   Tables to replicate (env: PG_FLO_TABLES)
      --track-ddl                        Enable tracking of DDL changes (env: PG_FLO_TRACK_DDL)
      --user string                      PostgreSQL user (env: PG_FLO_USER)
Global Flags:
      --config string   config file (default is $HOME/.pg_flo.yaml)

FYI: For non-mandatory params, it does pick it up from the env variables specified.

Expected

Should take these required params from the env specified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions