Skip to content

Commit

Permalink
Pre-req bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Clifford committed Jan 11, 2021
1 parent b490deb commit 42dde2d
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 110 deletions.
176 changes: 88 additions & 88 deletions .lagoon.yml
Original file line number Diff line number Diff line change
@@ -1,91 +1,91 @@
docker-compose-yaml: docker-compose.yml

source-environment-defaults:
postgres:
config:
hostname: "$POSTGRES_HOST"
username: "$POSTGRES_USERNAME"
password: "$POSTGRES_PASSWORD"
port: "5432"
database: "$POSTGRES_DATABASE"
mariadb:
config:
hostname: "$MARIADB_HOST"
username: "$MARIADB_USERNAME"
password: "$MARIADB_PASSWORD"
port: "$MARIADB_PORT"
database: "$MARIADB_DATABASE"
files:
config:
sync-directory: "/app/web/sites/default/files"
drupalconfig:
config:
syncpath: "./config/sync"
# source-environment-defaults:
# postgres:
# config:
# hostname: "$POSTGRES_HOST"
# username: "$POSTGRES_USERNAME"
# password: "$POSTGRES_PASSWORD"
# port: "5432"
# database: "$POSTGRES_DATABASE"
# mariadb:
# config:
# hostname: "$MARIADB_HOST"
# username: "$MARIADB_USERNAME"
# password: "$MARIADB_PASSWORD"
# port: "$MARIADB_PORT"
# database: "$MARIADB_DATABASE"
# files:
# config:
# sync-directory: "/app/web/sites/default/files"
# drupalconfig:
# config:
# syncpath: "./config/sync"

lagoon-sync:
postgres:
config:
hostname: "$POSTGRES_HOST"
username: "$POSTGRES_USERNAME"
password: "$POSTGRES_PASSWORD"
port: "5432"
database: "$POSTGRES_DATABASE"
exclude-table:
- cachewhatever
- someothertable
exclude-table-data:
- cache_data
- cache_menu
local:
config:
hostname: "drupal"
username: "drupal"
password: "drupal"
port: "3306"
database: "drupal"
mongodb:
config:
hostname: "$HOSTNAME"
port: "$MONGODB_SERVICE_PORT"
database: "local"
local:
config:
hostname: "$HOSTNAME"
port: "27017"
database: "local"
mariadb:
config:
hostname: "$MARIADB_HOST"
username: "$MARIADB_USERNAME"
password: "$MARIADB_PASSWORD"
port: "$MARIADB_PORT"
database: "$MARIADB_DATABASE"
ignore-table:
- cachewhatever
- someothertable
ignore-table-data:
- cache_data
- cache_menu
local:
config:
hostname: "drupal"
username: "drupal"
password: "drupal"
port: "3306"
database: "drupal"
files:
config:
sync-directory: "/app/storage"
exclude:
- "app"
- "framework"
local:
config:
sync-directory: "/tmp/storageout"
drupalconfig:
config:
syncpath: "./config/sync"
local:
overrides:
config:
syncpath: "./config/sync"
# lagoon-sync:
# postgres:
# config:
# hostname: "$POSTGRES_HOST"
# username: "$POSTGRES_USERNAME"
# password: "$POSTGRES_PASSWORD"
# port: "5432"
# database: "$POSTGRES_DATABASE"
# exclude-table:
# - cachewhatever
# - someothertable
# exclude-table-data:
# - cache_data
# - cache_menu
# local:
# config:
# hostname: "drupal"
# username: "drupal"
# password: "drupal"
# port: "3306"
# database: "drupal"
# mongodb:
# config:
# hostname: "$HOSTNAME"
# port: "$MONGODB_SERVICE_PORT"
# database: "local"
# local:
# config:
# hostname: "$HOSTNAME"
# port: "27017"
# database: "local"
# mariadb:
# config:
# hostname: "$MARIADB_HOST"
# username: "$MARIADB_USERNAME"
# password: "$MARIADB_PASSWORD"
# port: "$MARIADB_PORT"
# database: "$MARIADB_DATABASE"
# ignore-table:
# - cachewhatever
# - someothertable
# ignore-table-data:
# - cache_data
# - cache_menu
# local:
# config:
# hostname: "drupal"
# username: "drupal"
# password: "drupal"
# port: "3306"
# database: "drupal"
# files:
# config:
# sync-directory: "/app/storage"
# exclude:
# - "app"
# - "framework"
# local:
# config:
# sync-directory: "/tmp/storageout"
# drupalconfig:
# config:
# syncpath: "./config/sync"
# local:
# overrides:
# config:
# syncpath: "./config/sync"
17 changes: 7 additions & 10 deletions synchers/mariadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ type BaseMariaDbSync struct {
func (mariaConfig *BaseMariaDbSync) setDefaults() {
// If no values from config files, set some expected defaults
if mariaConfig.DbHostname == "" {
mariaConfig.DbHostname = "$MARIADB_HOST"
mariaConfig.DbHostname = "$DB_HOST"
}
if mariaConfig.DbUsername == "" {
mariaConfig.DbUsername = "$MARIADB_USERNAME"
mariaConfig.DbUsername = "$DB_USERNAME"
}
if mariaConfig.DbPassword == "" {
mariaConfig.DbPassword = "$MARIADB_PASSWORD"
mariaConfig.DbPassword = "$DB_PASSWORD"
}
if mariaConfig.DbPort == "" {
mariaConfig.DbPort = "$MARIADB_PORT"
mariaConfig.DbPort = "$DB_PORT"
}
if mariaConfig.DbDatabase == "" {
mariaConfig.DbDatabase = "$MARIADB_DATABASE"
mariaConfig.DbDatabase = "$DB_DATABASE"
}
if mariaConfig.IgnoreTable == nil {
mariaConfig.IgnoreTable = []string{}
Expand Down Expand Up @@ -68,10 +68,7 @@ func (m MariadbSyncPlugin) UnmarshallYaml(root SyncherConfigRoot) (Syncer, error

pluginIDLagoonSync := root.LagoonSync[m.GetPluginId()]
pluginIDEnvDefaults := root.EnvironmentDefaults[m.GetPluginId()]
if pluginIDLagoonSync == nil {
pluginIDLagoonSync = "mariadb"
}
if pluginIDEnvDefaults == nil {
if pluginIDLagoonSync == nil || pluginIDEnvDefaults == nil {
pluginIDEnvDefaults = "mariadb"
}

Expand Down Expand Up @@ -99,7 +96,7 @@ func (root MariadbSyncRoot) PrepareSyncer() (Syncer, error) {
}

func (root MariadbSyncRoot) GetPrerequisiteCommand(environment Environment, command string) SyncCommand {
lagoonSyncBin := "$(which ./lagoon-sync || which /tmp/lagoon-sync* || which lagoon-sync)"
lagoonSyncBin := "lagoon_sync=$(which ./lagoon-sync* || which /tmp/lagoon-sync || false) && $lagoon_sync"

return SyncCommand{
command: fmt.Sprintf("{{ .bin }} {{ .command }} || true"),
Expand Down
7 changes: 2 additions & 5 deletions synchers/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ func (m MongoDbSyncPlugin) UnmarshallYaml(root SyncherConfigRoot) (Syncer, error

pluginIDLagoonSync := root.LagoonSync[m.GetPluginId()]
pluginIDEnvDefaults := root.EnvironmentDefaults[m.GetPluginId()]
if pluginIDLagoonSync == nil {
pluginIDLagoonSync = "mongodb"
}
if pluginIDEnvDefaults == nil {
if pluginIDLagoonSync == nil || pluginIDEnvDefaults == nil {
pluginIDEnvDefaults = "mongodb"
}

Expand All @@ -82,7 +79,7 @@ func (root MongoDbSyncRoot) PrepareSyncer() (Syncer, error) {
}

func (root MongoDbSyncRoot) GetPrerequisiteCommand(environment Environment, command string) SyncCommand {
lagoonSyncBin := "$(which ./lagoon-sync || which /tmp/lagoon-sync* || which lagoon-sync)"
lagoonSyncBin := "lagoon_sync=$(which ./lagoon-sync* || which /tmp/lagoon-sync || false) && $lagoon_sync"

return SyncCommand{
command: fmt.Sprintf("{{ .bin }} {{ .command }} || true"),
Expand Down
7 changes: 2 additions & 5 deletions synchers/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ func (m PostgresSyncPlugin) UnmarshallYaml(syncerConfigRoot SyncherConfigRoot) (

pluginIDLagoonSync := syncerConfigRoot.LagoonSync[m.GetPluginId()]
pluginIDEnvDefaults := syncerConfigRoot.EnvironmentDefaults[m.GetPluginId()]
if pluginIDLagoonSync == nil {
pluginIDLagoonSync = "postgres"
}
if pluginIDEnvDefaults == nil {
if pluginIDLagoonSync == nil || pluginIDEnvDefaults == nil {
pluginIDEnvDefaults = "postgres"
}

Expand All @@ -89,7 +86,7 @@ func (root PostgresSyncRoot) PrepareSyncer() (Syncer, error) {
}

func (root PostgresSyncRoot) GetPrerequisiteCommand(environment Environment, command string) SyncCommand {
lagoonSyncBin := "which lagoon-sync"
lagoonSyncBin := "lagoon_sync=$(which ./lagoon-sync* || which /tmp/lagoon-sync || false) && $lagoon_sync"

return SyncCommand{
command: fmt.Sprintf("{{ .bin }} {{ .command }}"),
Expand Down
4 changes: 2 additions & 2 deletions synchers/syncutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func RunPrerequisiteCommand(environment Environment, syncer Syncer, dryRun bool,
err, configResponseJson, errstring := Shellout(execString)
if err != nil {
fmt.Println(errstring)
return "", err
// return "", err
}

data := &PreRequisiteResponse{}
Expand All @@ -107,7 +107,7 @@ func RunPrerequisiteCommand(environment Environment, syncer Syncer, dryRun bool,
log.Printf("Config response: %v", configResponseJson)
configRespSuccessful = true
} else {
log.Printf("%v-----\nWarning: Check if lagoon-sync is available on %s\n-----", configResponseJson, environment.EnvironmentName)
log.Printf("%v\n-----\nWarning: lagoon-sync is not available on %s\n-----", configResponseJson, environment.EnvironmentName)
configRespSuccessful = false
}

Expand Down

0 comments on commit 42dde2d

Please sign in to comment.