From 502c924653c89e96c5b370cf281da59e3a2b3759 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 24 May 2018 19:00:47 +0100 Subject: Show the available services for each revision --- app/jobs/govuk_guix/fetch_revision_job.rb | 14 +++++++- app/views/govuk_guix/revisions/show.html.erb | 39 +++++++++++++++++++++- ...dd_available_services_to_govuk_guix_revision.rb | 5 +++ db/structure.sql | 6 ++-- 4 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20180523062426_add_available_services_to_govuk_guix_revision.rb diff --git a/app/jobs/govuk_guix/fetch_revision_job.rb b/app/jobs/govuk_guix/fetch_revision_job.rb index 76e16bd..c2c3c17 100644 --- a/app/jobs/govuk_guix/fetch_revision_job.rb +++ b/app/jobs/govuk_guix/fetch_revision_job.rb @@ -47,7 +47,8 @@ class GovukGuix::FetchRevisionJob < GovukGuix::Job GovukGuix::Revision.create( commit_hash: sha, - store_path: store_path + store_path: store_path, + available_services: available_services(store_path) ) end @@ -61,6 +62,17 @@ class GovukGuix::FetchRevisionJob < GovukGuix::Job end end + def available_services(store_path) + command_output = run_command( + "#{store_path}/bin/govuk", + "system", + "available-services", + "--json" + ) + + JSON.parse(command_output.join) + end + def repository_directory 'tmp/cache/govuk-guix' end diff --git a/app/views/govuk_guix/revisions/show.html.erb b/app/views/govuk_guix/revisions/show.html.erb index 96e3588..fe42dd7 100644 --- a/app/views/govuk_guix/revisions/show.html.erb +++ b/app/views/govuk_guix/revisions/show.html.erb @@ -26,7 +26,6 @@ License along with the GOV.UK Mini Environment Admin. If not, see Back to Setup -

Revision: <%= @revision.commit_hash %>

@@ -54,3 +53,41 @@ License along with the GOV.UK Mini Environment Admin. If not, see <% else %>

There are no mini environments using this revision

<% end %> + +

Available Services

+ +<% (@revision.available_services || []).each do |group| %> +

<%= group["name"] %>

+

<%= group["description"] %>

+ + + + + + + + + + + <% group["services"].each do |service| %> + + + + + + <% package = service["package"] %> + + + <% end %> + +
NameDescriptionPackage
+ <%= service["name"] %> + + <%= service["description"] %> + + "> + <%= package["version"] %> + + ">[homepage] +
+<% end %> diff --git a/db/migrate/20180523062426_add_available_services_to_govuk_guix_revision.rb b/db/migrate/20180523062426_add_available_services_to_govuk_guix_revision.rb new file mode 100644 index 0000000..328a9ed --- /dev/null +++ b/db/migrate/20180523062426_add_available_services_to_govuk_guix_revision.rb @@ -0,0 +1,5 @@ +class AddAvailableServicesToGovukGuixRevision < ActiveRecord::Migration[5.1] + def change + add_column :govuk_guix_revisions, :available_services, :json + end +end diff --git a/db/structure.sql b/db/structure.sql index 0d56576..12c19cf 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -79,7 +79,8 @@ CREATE TABLE public.govuk_guix_revisions ( store_path character varying, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, - archived boolean DEFAULT false NOT NULL + archived boolean DEFAULT false NOT NULL, + available_services json ); @@ -501,6 +502,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20180406124443'), ('20180410192329'), ('20180410192412'), -('20180417195307'); +('20180417195307'), +('20180523062426'); -- cgit v1.2.3