Skip to content

Commit

Permalink
Load avo-advanced in k8s deployment (#5151)
Browse files Browse the repository at this point in the history
* Load avo-advanced in k8s deployment

Signed-off-by: Samuel Giddins <[email protected]>

* Move avo license check to authenticate, which is after the license has been set

It is not yet set when computing context

Signed-off-by: Samuel Giddins <[email protected]>

---------

Signed-off-by: Samuel Giddins <[email protected]>
  • Loading branch information
segiddins authored Oct 21, 2024
1 parent 03721c4 commit ae5136d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions config/deploy/web.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ spec:
value: "<%= environment %>"
- name: ENV
value: "<%= environment %>"
- name: RAILS_GROUPS
value: "avo"
- name: WEB_CONCURRENCY
value: "<%= environment == 'production' ? 8 : 2 %>"
- name: RAILS_MAX_THREADS
Expand Down
11 changes: 7 additions & 4 deletions config/initializers/avo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@
## == Set the context ==
config.set_context do
# Return a context object that gets evaluated in Avo::ApplicationController

if !Rails.env.local? && !(Avo.license.valid? && Avo.license.advanced?)
raise "Avo::Pro is missing in #{Rails.env}. RAILS_GROUPS=#{ENV['RAILS_GROUPS'].inspect} Avo.license=#{Avo.license.inspect}"
end
end

## == Authentication ==
config.current_user_method = :admin_user
config.authenticate_with do
if !Rails.env.local? && !(Avo.license.valid? && Avo.license.advanced?)
raise "Avo::Pro is missing in #{Rails.env}." \
"\nRails.groups=#{Rails.groups.inspect}" \
"\nAvo.license=#{Avo.license.inspect}" \
"\nAvo.configuration.license=#{Avo.configuration.license.inspect}"
end

redirect_to '/' unless _current_user&.valid?
Current.user = begin
User.security_user
Expand Down

0 comments on commit ae5136d

Please sign in to comment.