Skip to content

Commit

Permalink
chore: support read-only api-db connections
Browse files Browse the repository at this point in the history
  • Loading branch information
tobybellwood authored May 16, 2024
1 parent 12cf95e commit 4dfd4f1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ The deployment requires:
| `KEYCLOAK_CLIENT_SECRET` | Client secret of `lagoon-opensearch-sync` Keycloak client. | |
| `OPENSEARCH_ADMIN_PASSWORD` | Password for the Opensearch `admin` user. | |

3. Command `/lagoon-opensearch-sync`.
3. If you are utilising a read-only connection to the api-db, either via a read-replica, or dedicated account:

| Name | Description | Example |
| --- | --- | --- |
| `API_DB_RO_ADDRESS` | Internal service name of an API DB read-only replica. | `lagoon-core-api-db` |
| `API_DB_RO_USERNAME` | Read-only user for the API DB. | |
| `API_DB_RO_PASSWORD` | Password for the read-only user for the API DB. | |

4. Command `/lagoon-opensearch-sync`.

## Advanced usage

Expand Down
6 changes: 3 additions & 3 deletions cmd/lagoon-opensearch-sync/dump-projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (

// DumpProjectsCmd represents the `dump-projects` command.
type DumpProjectsCmd struct {
APIDBAddress string `kong:"required,env='API_DB_ADDRESS',help='Lagoon API DB Address (host[:port])'"`
APIDBAddress string `kong:"required,env='API_DB_RO_ADDRESS,API_DB_ADDRESS',help='Lagoon API DB Address (host[:port])'"`
APIDBDatabase string `kong:"default='infrastructure',env='API_DB_DATABASE',help='Lagoon API DB Database Name'"`
APIDBPassword string `kong:"required,env='API_DB_PASSWORD',help='Lagoon API DB Password'"`
APIDBUsername string `kong:"default='api',env='API_DB_USERNAME',help='Lagoon API DB Username'"`
APIDBPassword string `kong:"required,env='API_DB_RO_PASSWORD,API_DB_PASSWORD',help='Lagoon API DB Password'"`
APIDBUsername string `kong:"default='api',env='API_DB_RO_USERNAME,API_DB_USERNAME',help='Lagoon API DB Username'"`
}

// Run the dump-projects command.
Expand Down
6 changes: 3 additions & 3 deletions cmd/lagoon-opensearch-sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ type SyncCmd struct {
Objects []string `kong:"enum='tenants,roles,rolesmapping,indexpatterns,indextemplates',default='tenants,roles,rolesmapping,indexpatterns,indextemplates',help='Opensearch objects which will be synchronized'"`
LegacyIndexPatternDelimiter bool `kong:"default='false',help='Use the legacy -* index pattern delimiter instead of -_-*'"`
// lagoon DB client fields
APIDBAddress string `kong:"required,env='API_DB_ADDRESS',help='Lagoon API DB Address (host[:port])'"`
APIDBAddress string `kong:"required,env='API_DB_RO_ADDRESS,API_DB_ADDRESS',help='Lagoon API DB Address (host[:port])'"`
APIDBDatabase string `kong:"default='infrastructure',env='API_DB_DATABASE',help='Lagoon API DB Database Name'"`
APIDBPassword string `kong:"required,env='API_DB_PASSWORD',help='Lagoon API DB Password'"`
APIDBUsername string `kong:"default='api',env='API_DB_USERNAME',help='Lagoon API DB Username'"`
APIDBPassword string `kong:"required,env='API_DB_RO_PASSWORD,API_DB_PASSWORD',help='Lagoon API DB Password'"`
APIDBUsername string `kong:"default='api',env='API_DB_RO_USERNAME,API_DB_USERNAME',help='Lagoon API DB Username'"`
// keycloak client fields
KeycloakClientID string `kong:"default='lagoon-opensearch-sync',env='KEYCLOAK_CLIENT_ID',help='Keycloak OAuth2 Client ID'"`
KeycloakClientSecret string `kong:"required,env='KEYCLOAK_CLIENT_SECRET',help='Keycloak OAuth2 Client Secret'"`
Expand Down

0 comments on commit 4dfd4f1

Please sign in to comment.