From a6aaed1fcdb16a5c3020843aecdf1e26f68e0430 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 10 Apr 2020 23:41:50 +0200 Subject: [PATCH 1/9] Start changing structure --- src/config.cr | 11 +++- src/config/config.cr | 14 ----- src/config/deployment.cr | 16 ++--- src/config/local.cr | 49 ++++++++++----- src/config/remote.cr | 12 +++- src/deployment/docker_image_to_dokku_app.cr | 4 +- src/deployment/mysql_dump_to_dokku_mariadb.cr | 2 +- src/pushokku.cr | 62 +++++++++++-------- 8 files changed, 98 insertions(+), 72 deletions(-) delete mode 100644 src/config/config.cr diff --git a/src/config.cr b/src/config.cr index f11d5c9..63d2644 100644 --- a/src/config.cr +++ b/src/config.cr @@ -1,9 +1,14 @@ require "yaml" -require "./config/config" require "./config/local" require "./config/remote" require "./config/deployment" - - +class Config + YAML.mapping( + version: String, + locals: Array(LocalConfig), + remotes: Array(RemoteConfig), + deployments: Array(DeploymentConfig) + ) +end diff --git a/src/config/config.cr b/src/config/config.cr deleted file mode 100644 index c6856a0..0000000 --- a/src/config/config.cr +++ /dev/null @@ -1,14 +0,0 @@ - -require "yaml" -require "./local" -require "./remote" -require "./deployment" - -class Config - YAML.mapping( - version: String, - locals: Array(LocalConfig), - remotes: Array(RemoteConfig), - deployments: Array(DeploymentConfig) - ) -end diff --git a/src/config/deployment.cr b/src/config/deployment.cr index 23f0168..d353ef9 100644 --- a/src/config/deployment.cr +++ b/src/config/deployment.cr @@ -1,37 +1,37 @@ require "yaml" -class DokkuMariadbConfig +class DokkuMariadbDeploymentConfigSettings YAML.mapping( name: String, options: YAML::Any | Nil ) end -class DokkuAppConfig +class DokkuAppDeploymentConfigSettings YAML.mapping( name: String, options: YAML::Any | Nil ) end -class DeploymentMariadbConfig +class DokkuMariadbDeploymentConfig YAML.mapping( local: String, remote: String, - dokku_mariadb: DokkuMariadbConfig, + dokku_mariadb: DokkuMariadbDeploymentConfigSettings, ) end -class DeploymentAppConfig +class DokkuAppDeploymentConfig YAML.mapping( local: String, remote: String, - dokku_app: DokkuAppConfig, + dokku_app: DokkuAppDeploymentConfigSettings, ) end alias DeploymentConfig = - DeploymentMariadbConfig | - DeploymentAppConfig + DokkuMariadbDeploymentConfig | + DokkuAppDeploymentConfig diff --git a/src/config/local.cr b/src/config/local.cr index a5f4856..2a26615 100644 --- a/src/config/local.cr +++ b/src/config/local.cr @@ -1,32 +1,47 @@ require "yaml" -enum LocalType - DOCKER_IMAGE = 1 - MYSQL_DUMP = 2 - - def to_yaml(io) - to_s(io) - end -end - -class LocalFileConfig +class ScriptLocalConfigSettings YAML.mapping( - name: String, - type: LocalType, # enum ? path: String ) end -class LocalDockerConfig +class MysqlDumpLocalConfigSettings + YAML.mapping( + path: String + ) +end + +class DockerImageLocalConfigSettings + YAML.mapping( + name: String + ) +end + +class ScriptLocalConfig YAML.mapping( name: String, - type: LocalType, # enum ? - docker_image: String + script: ScriptLocalConfigSettings + ) +end + +class MysqlDumpLocalConfig + YAML.mapping( + name: String, + mysql_dump: MysqlDumpLocalConfigSettings + ) +end + +class DockerImageLocalConfig + YAML.mapping( + name: String, + docker_image: DockerImageLocalConfigSettings ) end alias LocalConfig = - LocalFileConfig | - LocalDockerConfig + DockerImageLocalConfig | + MysqlDumpLocalConfig | + ScriptLocalConfig diff --git a/src/config/remote.cr b/src/config/remote.cr index 8963a7e..477ed4f 100644 --- a/src/config/remote.cr +++ b/src/config/remote.cr @@ -1,11 +1,19 @@ require "yaml" -class RemoteConfig +class DokkuRemoteConfigSettings YAML.mapping( - name: String, user: String, host: String ) end +class DokkuRemoteConfig + YAML.mapping( + name: String, + dokku: DokkuRemoteConfigSettings + ) +end + +alias RemoteConfig = + DokkuRemoteConfig diff --git a/src/deployment/docker_image_to_dokku_app.cr b/src/deployment/docker_image_to_dokku_app.cr index 808d15c..e684437 100644 --- a/src/deployment/docker_image_to_dokku_app.cr +++ b/src/deployment/docker_image_to_dokku_app.cr @@ -1,8 +1,8 @@ require "colorize" -class DeploymentApp - def initialize(@local : LocalDockerConfig, @remote : RemoteConfig, @deployment : DeploymentAppConfig) +class DockerImageToDokkuAppDeployment + def initialize(@local : DockerImageLocalConfig, @remote : RemoteConfig, @deployment : DokkuAppDeploymentConfig) end def run diff --git a/src/deployment/mysql_dump_to_dokku_mariadb.cr b/src/deployment/mysql_dump_to_dokku_mariadb.cr index 4f6c775..60005f1 100644 --- a/src/deployment/mysql_dump_to_dokku_mariadb.cr +++ b/src/deployment/mysql_dump_to_dokku_mariadb.cr @@ -1,5 +1,5 @@ -class DeploymentMariadb +class MysqlDumpToDokkuMariadbDeployment def initialize(@local : LocalFileConfig, @remote : RemoteConfig, @deployment : DeploymentMariadbConfig) end diff --git a/src/pushokku.cr b/src/pushokku.cr index fd5eed4..18374cd 100644 --- a/src/pushokku.cr +++ b/src/pushokku.cr @@ -75,6 +75,42 @@ module Pushokku end + def self.handle_deployment(config : Config, deployment_config : DeploymentConfig) + local = config.locals.select { |l| l.name == deployment_config.local }.first + remote = config.remotes.select { |r| r.name == deployment_config.remote }.first + + if local.nil? + puts "Unknown local #{deployment_config.local}. Exiting." + exit 2 + end + + if remote.nil? + puts "Unknown remote #{deployment_config.remote}. Exiting." + exit 2 + end + + deployment = + case deployment_config + when DokkuAppDeploymentConfig then + DockerImageToDokkuAppDeployment.new( + local.as(DockerImageLocalConfig), + remote, + deployment_config.as(DokkuAppDeploymentConfig) + ) + when MysqlDumpToDokkuMariadbDeployment then + DeploymentMariadb.new( + local.as(MysqlDumpLocalConfig), + remote, + deployment_config.as(DokkuMariadbDeploymentConfig) + ) + when Nil + nil + end + + next if deployment.nil? + deployment.run + end + def self.run(args) app = Cli.new opts = app.parse_options(args) @@ -82,31 +118,7 @@ module Pushokku # env_config = App.get_config(config, opts["environment"]) config.deployments.each do |deployment_config| - local = config.locals.select { |l| l.name == deployment_config.local }.first - remote = config.remotes.select { |r| r.name == deployment_config.remote }.first - if local.nil? - puts "Unknown local #{deployment_config.local}. Exiting." - exit 2 - end - if remote.nil? - puts "Unknown remote #{deployment_config.remote}. Exiting." - exit 2 - end - - - deployment = - case deployment_config - when DeploymentAppConfig then - - DeploymentApp.new(local.as(LocalDockerConfig), remote, deployment_config.as(DeploymentAppConfig)) - when DeploymentMariadbConfig then - DeploymentMariadb.new(local.as(LocalFileConfig), remote, deployment_config.as(DeploymentMariadbConfig)) - when Nil - nil - end - - next if deployment.nil? - deployment.run + handle_deployment(config, deployment_config) end exit 2 From c8b11df19ecbed07b812c6db25ce26a0b1db1685 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 10 Apr 2020 23:42:06 +0200 Subject: [PATCH 2/9] Add sample config for v3 format --- doc/pushokku-v3.yml | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 doc/pushokku-v3.yml diff --git a/doc/pushokku-v3.yml b/doc/pushokku-v3.yml new file mode 100644 index 0000000..0078eee --- /dev/null +++ b/doc/pushokku-v3.yml @@ -0,0 +1,60 @@ +--- +version: "3" + +hosts: + - name: local + localhost: {} + + - name: testing + ssh: + user: debian + host: shiva-ratri.infra.boldcode.io + + +endpoints: + # Local endpoints + - name: local-wp-image + host: local + docker_image: + name: sans-a-site-v2-wordpress_wordpress + + - name: local-db-dump + host: local + mysql_dump: + path: database.sql + + - name: local-db-script + host: local + script: + path: .pushokku/post-update.sh + + # Remote endpoints + - name: remote-wp-app + host: testing + dokku_app: + name: customer-sans-a-site + + - name: remote-wp-db + host: testing + dokku_mariadb: + name: customer-sans-a-wpsandbox + + +filters: + - name: compress + cmd_in: gzip - + cmd_out: gunzip - + + +deployments: + - copy: + local: local-wp-image + remote: remote-wp-app + + - copy: + local: local-db-dump + remote: remote-wp-db + + - run: + local: local-db-script + remote: remote-wp-app From 8bd39f96a59474c0f5aa1f9b47c7390858f27214 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 10 Apr 2020 23:42:15 +0200 Subject: [PATCH 3/9] Add TODO file --- TODO.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 TODO.md diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..6880d49 --- /dev/null +++ b/TODO.md @@ -0,0 +1,9 @@ +cat database.sql.gz |ssh shiva-ratri.infra.boldcode.io 'docker exec -i customer-sans-a-site.web.1 sh -c "cat > adminer.sql.gz"' + +cat database.sql |ssh shiva-ratri.infra.boldcode.io 'dokku mariadb:import customer-sans-a-wpsandbox' + +# TODO + +* verify target app exist +* verify target database exist + From 1fab12c472c64ff97a91aff526a1efe647d33545 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Sat, 11 Apr 2020 00:10:20 +0200 Subject: [PATCH 4/9] Update configuration according to new format --- src/config.cr | 9 ++++---- src/config/deployment.cr | 33 +++++++-------------------- src/config/endpoint.cr | 29 ++++++++++++++++++++++++ src/config/host.cr | 0 src/config/local.cr | 46 ------------------------------------- src/config/settings.cr | 49 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 90 insertions(+), 76 deletions(-) create mode 100644 src/config/endpoint.cr create mode 100644 src/config/host.cr create mode 100644 src/config/settings.cr diff --git a/src/config.cr b/src/config.cr index 63d2644..b01aecc 100644 --- a/src/config.cr +++ b/src/config.cr @@ -1,14 +1,13 @@ require "yaml" -require "./config/local" -require "./config/remote" -require "./config/deployment" +require "./config/*.cr" class Config YAML.mapping( version: String, - locals: Array(LocalConfig), - remotes: Array(RemoteConfig), + hosts: Array(HostConfig), + endpoints: Array(EndpointConfig), + filters: Array(FilterConfig), deployments: Array(DeploymentConfig) ) end diff --git a/src/config/deployment.cr b/src/config/deployment.cr index d353ef9..6cdcabd 100644 --- a/src/config/deployment.cr +++ b/src/config/deployment.cr @@ -1,37 +1,20 @@ require "yaml" -class DokkuMariadbDeploymentConfigSettings +class RunDeploymentConfig YAML.mapping( - name: String, - options: YAML::Any | Nil + name: String?, + run: RunDeploymentConfigSettings ) end -class DokkuAppDeploymentConfigSettings +class TransferDeploymentConfig YAML.mapping( - name: String, - options: YAML::Any | Nil - ) -end - -class DokkuMariadbDeploymentConfig - YAML.mapping( - local: String, - remote: String, - dokku_mariadb: DokkuMariadbDeploymentConfigSettings, - ) -end - -class DokkuAppDeploymentConfig - YAML.mapping( - local: String, - remote: String, - dokku_app: DokkuAppDeploymentConfigSettings, + name: String?, + transfer: TransferDeploymentConfigSettings ) end alias DeploymentConfig = - DokkuMariadbDeploymentConfig | - DokkuAppDeploymentConfig - + TransferDeploymentConfig | + RunDeploymentConfig diff --git a/src/config/endpoint.cr b/src/config/endpoint.cr new file mode 100644 index 0000000..737fee7 --- /dev/null +++ b/src/config/endpoint.cr @@ -0,0 +1,29 @@ + +require "yaml" + +class ScriptEndpointConfig + YAML.mapping( + name: String, + script: ScriptEndpointConfigSettings + ) +end + +class MysqlDumpEndpointConfig + YAML.mapping( + name: String, + mysql_dump: MysqlDumpEndpointConfigSettings + ) +end + +class DockerImageEndpointConfig + YAML.mapping( + name: String, + docker_image: DockerImageEndpointConfigSettings + ) +end + +alias EndpointConfig = + DockerImageEndpointConfig | + MysqlDumpEndpointConfig | + ScriptEndpointConfig + diff --git a/src/config/host.cr b/src/config/host.cr new file mode 100644 index 0000000..e69de29 diff --git a/src/config/local.cr b/src/config/local.cr index 2a26615..8b13789 100644 --- a/src/config/local.cr +++ b/src/config/local.cr @@ -1,47 +1 @@ -require "yaml" - -class ScriptLocalConfigSettings - YAML.mapping( - path: String - ) -end - -class MysqlDumpLocalConfigSettings - YAML.mapping( - path: String - ) -end - -class DockerImageLocalConfigSettings - YAML.mapping( - name: String - ) -end - -class ScriptLocalConfig - YAML.mapping( - name: String, - script: ScriptLocalConfigSettings - ) -end - -class MysqlDumpLocalConfig - YAML.mapping( - name: String, - mysql_dump: MysqlDumpLocalConfigSettings - ) -end - -class DockerImageLocalConfig - YAML.mapping( - name: String, - docker_image: DockerImageLocalConfigSettings - ) -end - -alias LocalConfig = - DockerImageLocalConfig | - MysqlDumpLocalConfig | - ScriptLocalConfig - diff --git a/src/config/settings.cr b/src/config/settings.cr new file mode 100644 index 0000000..817d6ce --- /dev/null +++ b/src/config/settings.cr @@ -0,0 +1,49 @@ + +require "yaml" + +class ScriptLocalConfigSettings + YAML.mapping( + path: String + ) +end + +class MysqlDumpLocalConfigSettings + YAML.mapping( + path: String + ) +end + +class DockerImageLocalConfigSettings + YAML.mapping( + name: String + ) +end + +class DokkuMariadbDeploymentConfigSettings + YAML.mapping( + name: String, + options: YAML::Any | Nil + ) +end + +class DokkuAppDeploymentConfigSettings + YAML.mapping( + name: String, + options: YAML::Any | Nil + ) +end + +class TransferDeploymentConfigSettings + YAML.mapping( + from: EndpointConfig, + to: EndpointConfig, + filters: Array(FilterConfig)? + ) +end + +class RunDeploymentConfigSettings + YAML.mapping( + from: EndpointConfig, + to: EndpointConfig, + ) +end From 88cddabb51f97bb39ba07e79dcc44759942231d2 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Sat, 11 Apr 2020 00:10:35 +0200 Subject: [PATCH 5/9] Update sample config --- doc/pushokku-v3.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/pushokku-v3.yml b/doc/pushokku-v3.yml index 0078eee..8c0de12 100644 --- a/doc/pushokku-v3.yml +++ b/doc/pushokku-v3.yml @@ -47,11 +47,11 @@ filters: deployments: - - copy: + - transfer: local: local-wp-image remote: remote-wp-app - - copy: + - transfer: local: local-db-dump remote: remote-wp-db From 6d2e47c2443e09f1e3fc65ba81bde3c41bc8f8e1 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Sat, 11 Apr 2020 21:36:06 +0200 Subject: [PATCH 6/9] Finalize types for parsing v3 format --- src/config/deployment.cr | 1 + src/config/deployment_settings.cr | 17 +++++++++++ src/config/endpoint.cr | 25 +++++++++++++++- src/config/endpoint_settings.cr | 37 +++++++++++++++++++++++ src/config/filter.cr | 22 ++++++++++++++ src/config/filter_settings.cr | 9 ++++++ src/config/host.cr | 22 ++++++++++++++ src/config/host_settings.cr | 9 ++++++ src/config/local.cr | 1 - src/config/remote.cr | 19 ------------ src/config/settings.cr | 49 ------------------------------- 11 files changed, 141 insertions(+), 70 deletions(-) create mode 100644 src/config/deployment_settings.cr create mode 100644 src/config/endpoint_settings.cr create mode 100644 src/config/filter.cr create mode 100644 src/config/filter_settings.cr create mode 100644 src/config/host_settings.cr delete mode 100644 src/config/local.cr delete mode 100644 src/config/remote.cr delete mode 100644 src/config/settings.cr diff --git a/src/config/deployment.cr b/src/config/deployment.cr index 6cdcabd..469968b 100644 --- a/src/config/deployment.cr +++ b/src/config/deployment.cr @@ -1,5 +1,6 @@ require "yaml" +require "./deployment_settings" class RunDeploymentConfig YAML.mapping( diff --git a/src/config/deployment_settings.cr b/src/config/deployment_settings.cr new file mode 100644 index 0000000..82fdc46 --- /dev/null +++ b/src/config/deployment_settings.cr @@ -0,0 +1,17 @@ + +require "yaml" + +class TransferDeploymentConfigSettings + YAML.mapping( + src: String, + dest: String, + filters: Array(String)? + ) +end + +class RunDeploymentConfigSettings + YAML.mapping( + src: String, + dest: String, + ) +end diff --git a/src/config/endpoint.cr b/src/config/endpoint.cr index 737fee7..c7648a9 100644 --- a/src/config/endpoint.cr +++ b/src/config/endpoint.cr @@ -1,9 +1,28 @@ require "yaml" +require "./endpoint_settings" + + +class DokkuMariadbEndpointConfig + YAML.mapping( + name: String, + host: String, + dokku_mariadb: DokkuMariadbEndpointConfigSettings + ) +end + +class DokkuAppEndpointConfig + YAML.mapping( + name: String, + host: String, + dokku_app: DokkuAppEndpointConfigSettings + ) +end class ScriptEndpointConfig YAML.mapping( name: String, + host: String, script: ScriptEndpointConfigSettings ) end @@ -11,6 +30,7 @@ end class MysqlDumpEndpointConfig YAML.mapping( name: String, + host: String, mysql_dump: MysqlDumpEndpointConfigSettings ) end @@ -18,6 +38,7 @@ end class DockerImageEndpointConfig YAML.mapping( name: String, + host: String, docker_image: DockerImageEndpointConfigSettings ) end @@ -25,5 +46,7 @@ end alias EndpointConfig = DockerImageEndpointConfig | MysqlDumpEndpointConfig | - ScriptEndpointConfig + ScriptEndpointConfig | + DokkuAppEndpointConfig | + DokkuMariadbEndpointConfig diff --git a/src/config/endpoint_settings.cr b/src/config/endpoint_settings.cr new file mode 100644 index 0000000..27e4309 --- /dev/null +++ b/src/config/endpoint_settings.cr @@ -0,0 +1,37 @@ + +require "yaml" + +class DokkuMariadbEndpointConfigSettings + YAML.mapping( + name: String + ) +end + +class DokkuAppEndpointConfigSettings + YAML.mapping( + name: String + ) +end + +class DockerImageEndpointConfigSettings + YAML.mapping( + tag: { + type: String, + nilable: false, + default: "latest" + } + ) +end + +class MysqlDumpEndpointConfigSettings + YAML.mapping( + path: String + ) +end + +class ScriptEndpointConfigSettings + YAML.mapping( + path: String + ) +end + diff --git a/src/config/filter.cr b/src/config/filter.cr new file mode 100644 index 0000000..cb81622 --- /dev/null +++ b/src/config/filter.cr @@ -0,0 +1,22 @@ + +require "yaml" +require "./filter_settings" + + +class DualFilterConfig + YAML.mapping( + name: String, + dual: DualFilterConfigSettings + ) +end + +class MonoFilterConfig + YAML.mapping( + name: String, + cmd: String + ) +end + +alias FilterConfig = + MonoFilterConfig | + DualFilterConfig diff --git a/src/config/filter_settings.cr b/src/config/filter_settings.cr new file mode 100644 index 0000000..fc2be9d --- /dev/null +++ b/src/config/filter_settings.cr @@ -0,0 +1,9 @@ + +require "yaml" + +class DualFilterConfigSettings + YAML.mapping( + cmd_in: String, + cmd_out: String, + ) +end diff --git a/src/config/host.cr b/src/config/host.cr index e69de29..56de618 100644 --- a/src/config/host.cr +++ b/src/config/host.cr @@ -0,0 +1,22 @@ + +require "yaml" +require "./host_settings" + +class LocalHostConfig + YAML.mapping( + name: String, + localhost: Hash(String, YAML::Any) + ) +end + + +class SshHostConfig + YAML.mapping( + name: String, + ssh: SshHostConfigSettings + ) +end + +alias HostConfig = + LocalHostConfig | + SshHostConfig diff --git a/src/config/host_settings.cr b/src/config/host_settings.cr new file mode 100644 index 0000000..703fc9a --- /dev/null +++ b/src/config/host_settings.cr @@ -0,0 +1,9 @@ + +require "yaml" + +class SshHostConfigSettings + YAML.mapping( + user: String, + host: String + ) +end diff --git a/src/config/local.cr b/src/config/local.cr deleted file mode 100644 index 8b13789..0000000 --- a/src/config/local.cr +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/config/remote.cr b/src/config/remote.cr deleted file mode 100644 index 477ed4f..0000000 --- a/src/config/remote.cr +++ /dev/null @@ -1,19 +0,0 @@ - -require "yaml" - -class DokkuRemoteConfigSettings - YAML.mapping( - user: String, - host: String - ) -end - -class DokkuRemoteConfig - YAML.mapping( - name: String, - dokku: DokkuRemoteConfigSettings - ) -end - -alias RemoteConfig = - DokkuRemoteConfig diff --git a/src/config/settings.cr b/src/config/settings.cr deleted file mode 100644 index 817d6ce..0000000 --- a/src/config/settings.cr +++ /dev/null @@ -1,49 +0,0 @@ - -require "yaml" - -class ScriptLocalConfigSettings - YAML.mapping( - path: String - ) -end - -class MysqlDumpLocalConfigSettings - YAML.mapping( - path: String - ) -end - -class DockerImageLocalConfigSettings - YAML.mapping( - name: String - ) -end - -class DokkuMariadbDeploymentConfigSettings - YAML.mapping( - name: String, - options: YAML::Any | Nil - ) -end - -class DokkuAppDeploymentConfigSettings - YAML.mapping( - name: String, - options: YAML::Any | Nil - ) -end - -class TransferDeploymentConfigSettings - YAML.mapping( - from: EndpointConfig, - to: EndpointConfig, - filters: Array(FilterConfig)? - ) -end - -class RunDeploymentConfigSettings - YAML.mapping( - from: EndpointConfig, - to: EndpointConfig, - ) -end From e1e4379300486f47d01d2a516834c65a4f112dac Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Sat, 11 Apr 2020 21:39:33 +0200 Subject: [PATCH 7/9] Finalize v3 format (minor fixes) --- doc/pushokku-v3.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/pushokku-v3.yml b/doc/pushokku-v3.yml index 8c0de12..9087f1e 100644 --- a/doc/pushokku-v3.yml +++ b/doc/pushokku-v3.yml @@ -42,19 +42,20 @@ endpoints: filters: - name: compress - cmd_in: gzip - - cmd_out: gunzip - + dual: + cmd_in: gzip - + cmd_out: gunzip - deployments: - transfer: - local: local-wp-image - remote: remote-wp-app + src: local-wp-image + dest: remote-wp-app - transfer: - local: local-db-dump - remote: remote-wp-db + src: local-db-dump + dest: remote-wp-db - run: - local: local-db-script - remote: remote-wp-app + src: local-db-script + dest: remote-wp-app From f42ace98bb836a5fcbfe114245f7f34dd4f9b1a3 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Sat, 11 Apr 2020 21:53:37 +0200 Subject: [PATCH 8/9] Fix loading of config files --- src/config.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.cr b/src/config.cr index b01aecc..a95e580 100644 --- a/src/config.cr +++ b/src/config.cr @@ -1,6 +1,6 @@ require "yaml" -require "./config/*.cr" +require "./config/*" class Config YAML.mapping( From 6411f2b06eecb69c77185b277dd7f751637c3bfb Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Sat, 11 Apr 2020 21:53:45 +0200 Subject: [PATCH 9/9] Fix loading of configuration --- src/pushokku.cr | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/pushokku.cr b/src/pushokku.cr index 18374cd..c04a723 100644 --- a/src/pushokku.cr +++ b/src/pushokku.cr @@ -111,17 +111,38 @@ module Pushokku deployment.run end + + def self.find_filter(config, name) + matches = config.filters.select { |filter| filter.name == name } + if matches.size > 1 + raise "Multiple filters have the same name (unicity)" + end + return matches.first + end + + def self.validate_config!(config) + pp config + #config.deployments.each do |deployment_config| + # handle_deployment(config, deployment_config) + #end + end + + def self.apply_config!(config) + config.deployments.each do |deployment_config| + # handle_deployment(config, deployment_config) + end + end + def self.run(args) app = Cli.new opts = app.parse_options(args) config = app.load_config(opts["config_file"]) # env_config = App.get_config(config, opts["environment"]) - config.deployments.each do |deployment_config| - handle_deployment(config, deployment_config) - end + validate_config!(config) + apply_config!(config) - exit 2 + exit 0 end end end