Skip to content

Commit

Permalink
Provide fallback for GovukAdminTemplate.environment_label
Browse files Browse the repository at this point in the history
It turns out that the GOVUK_ENVIRONMENT_NAME env var is not defined and
the Rails env is not development or test during the GH action job which
builds the image for deployment. This means that GovukEnvironment.name
is nil and we see the following exception [1]:

    NoMethodError: undefined method `titleize' for nil:NilClass

I considered setting GOVUK_ENVIRONMENT_NAME in the GH action, but there
didn't seem to be any precendent for doing that.

I also considered providing a fallback within the implementation of
GovukEnvironment.name. However, I thought that might have other
undesirable consequences.

So I've implemented the fallback in
config/initializers/govuk_admin_template.rb which is a bit ugly, but
hopefully it won't be too long before we get rid of GovukAdminTemplate
altogether!

[1]: https://github.com/alphagov/signon/actions/runs/5940071624/job/16107859623#step:7:609
  • Loading branch information
floehopper committed Aug 22, 2023
1 parent dc6e39f commit bad7b54
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion config/initializers/govuk_admin_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
c.disable_google_analytics = false
end

GovukAdminTemplate.environment_label = GovukEnvironment.name.titleize
GovukAdminTemplate.environment_label = (GovukEnvironment.name || "development").titleize
GovukAdminTemplate.environment_style = GovukEnvironment.production? ? "production" : "preview"

0 comments on commit bad7b54

Please sign in to comment.