aboutsummaryrefslogtreecommitdiff
path: root/app/jobs/govuk_guix/create_data_snapshot_job.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/jobs/govuk_guix/create_data_snapshot_job.rb')
-rw-r--r--app/jobs/govuk_guix/create_data_snapshot_job.rb23
1 files changed, 7 insertions, 16 deletions
diff --git a/app/jobs/govuk_guix/create_data_snapshot_job.rb b/app/jobs/govuk_guix/create_data_snapshot_job.rb
index 91f3904..d6345a0 100644
--- a/app/jobs/govuk_guix/create_data_snapshot_job.rb
+++ b/app/jobs/govuk_guix/create_data_snapshot_job.rb
@@ -24,20 +24,6 @@ class GovukGuix::CreateDataSnapshotJob < Que::Job
@retry_interval = 30
- def enqueue(options = {})
- backend_type = options[:backend_type]
- backend_id = options[:backend_id]
-
- remote_host = options[:run_remotely_on_host]
-
- if remote_host
- raise 'backend_type missing' unless backend_type
- raise 'backend_id missing' unless backend_id
- end
-
- super(options)
- end
-
def run(options = {})
data_snapshot_fields = {}
@@ -46,6 +32,8 @@ class GovukGuix::CreateDataSnapshotJob < Que::Job
if backend_type
backend = Backends.find_by_type_and_id(backend_type, backend_id)
data_snapshot_fields[:backend] = backend
+
+ remote_host = backend.build_remote_host
end
revision_id = options[:revision_id]
@@ -56,19 +44,22 @@ class GovukGuix::CreateDataSnapshotJob < Que::Job
end
data_snapshot_fields[:govuk_guix_revision] = revision
- remote_host = options[:run_remotely_on_host]
logger.info(self.class) do
'Creating new data snapshot'
end
if remote_host
+ # TODO: This doesn't use the private key specified by the
+ # backend, so it'll only work when the default SSH key has
+ # access to the remote host.
+
# Copy the revision to the remote host, to ensure it's available
# there
run_command(
'guix',
'copy',
- "--to=#{remote_host}",
+ "--to=#{remote_host.user_at_address}",
revision.store_path
)
end