aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-06-23 09:26:52 +0100
committerChristopher Baines <mail@cbaines.net>2018-06-23 12:58:05 +0100
commit0736fd5ab32eeb57de52fb6d581d16c2824b2fc2 (patch)
tree6ed6e54772a6e23a047942e8be7d1ff114949f3d
parentb6c1930ffe65afbbccf1252ca084a932d19c2d64 (diff)
downloadgovuk-mini-environment-admin-0736fd5ab32eeb57de52fb6d581d16c2824b2fc2.tar
govuk-mini-environment-admin-0736fd5ab32eeb57de52fb6d581d16c2824b2fc2.tar.gz
Add a Guix module
Which contains an available_locally? function.
-rw-r--r--app/controllers/govuk_guix/data_snapshots_controller.rb25
-rw-r--r--app/controllers/govuk_guix/revisions_controller.rb2
-rw-r--r--app/services/govuk_guix/build_mini_environment.rb2
-rw-r--r--lib/guix.rb25
4 files changed, 52 insertions, 2 deletions
diff --git a/app/controllers/govuk_guix/data_snapshots_controller.rb b/app/controllers/govuk_guix/data_snapshots_controller.rb
new file mode 100644
index 0000000..95bee66
--- /dev/null
+++ b/app/controllers/govuk_guix/data_snapshots_controller.rb
@@ -0,0 +1,25 @@
+# GOV.UK Mini Environment Admin
+# Copyright © 2018 Christopher Baines <mail@cbaines.net>
+#
+# This file is part of the GOV.UK Mini Environment Admin.
+#
+# The GOV.UK Mini Environment Admin is free software: you can
+# redistribute it and/or modify it under the terms of the GNU Affero
+# General Public License as published by the Free Software Foundation,
+# either version 3 of the License, or (at your option) any later
+# version.
+#
+# The GOV.UK Mini Environment Admin is distributed in the hope that it
+# will be useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with the GOV.UK Mini Environment Admin. If not, see
+# <http://www.gnu.org/licenses/>.
+
+class GovukGuix::DataSnapshotsController < ApplicationController
+ def show
+ @data_snapshot = GovukGuix::DataSnapshot.find(params['id'])
+ end
+end
diff --git a/app/controllers/govuk_guix/revisions_controller.rb b/app/controllers/govuk_guix/revisions_controller.rb
index f7c7f56..838bdae 100644
--- a/app/controllers/govuk_guix/revisions_controller.rb
+++ b/app/controllers/govuk_guix/revisions_controller.rb
@@ -27,7 +27,7 @@ class GovukGuix::RevisionsController < ApplicationController
revision = params.require('revision')
# Attempt to check if this can be performed locally
- if File.exist? '/var/guix/daemon-socket/socket'
+ if Guix.available_locally?
options = {}
else
# Assume that the AWS backend is in use
diff --git a/app/services/govuk_guix/build_mini_environment.rb b/app/services/govuk_guix/build_mini_environment.rb
index 6de6b81..9bce8b5 100644
--- a/app/services/govuk_guix/build_mini_environment.rb
+++ b/app/services/govuk_guix/build_mini_environment.rb
@@ -36,7 +36,7 @@ module GovukGuix::BuildMiniEnvironment
remote_host = options[:run_remotely_on_host]
- if remote_host && File.exist?('/var/guix/daemon-socket/socket')
+ if remote_host && Guix.available_locally?
# Copy the revision to the remote host, to ensure it's available
# there
run_command(
diff --git a/lib/guix.rb b/lib/guix.rb
new file mode 100644
index 0000000..a9cc7b0
--- /dev/null
+++ b/lib/guix.rb
@@ -0,0 +1,25 @@
+# GOV.UK Mini Environment Admin
+# Copyright © 2018 Christopher Baines <mail@cbaines.net>
+#
+# This file is part of the GOV.UK Mini Environment Admin.
+#
+# The GOV.UK Mini Environment Admin is free software: you can
+# redistribute it and/or modify it under the terms of the GNU Affero
+# General Public License as published by the Free Software Foundation,
+# either version 3 of the License, or (at your option) any later
+# version.
+#
+# The GOV.UK Mini Environment Admin is distributed in the hope that it
+# will be useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with the GOV.UK Mini Environment Admin. If not, see
+# <http://www.gnu.org/licenses/>.
+
+module Guix
+ def self.available_locally?
+ File.exist?('/var/guix/daemon-socket/socket')
+ end
+end