Class: VersionManagementPolicy

Inherits:
AppPolicy show all
Defined in:
lib/models/version_management_policy.rb

Overview

Holds a version management policy for an app

Constant Summary collapse

NONE =

Constants

'none'
MINIMUM =
'min'
STRICT =
'strict'
CUSTOM =
'custom'
OPTIONS =
[NONE, MINIMUM, CUSTOM, STRICT].freeze

Instance Method Summary collapse

Instance Method Details

#enforce_policy(agent) ⇒ Object

return the version management policy



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/models/version_management_policy.rb', line 31

def enforce_policy(agent)
  policy = super.merge(enforce_active_version: false)
  if policy_enabled?(agent)
    build = app_active_build(agent)
    unless valid_version?(agent, build)
      policy[:enforce_active_version] = true
      policy[:version_management] = { active_version: { platform: build.platform,
                                                        environment: build.environment,
                                                        file_url: build.cdn_file_url,
                                                        version: build.version },
                                      message: message,
                                      allowed_ignores: allowed_ignores }
    end
  end
  policy
rescue StandardError => error
  App47Logger.log_warn('VersionManagementPolicy#enforce_policy', error)
  # Return the default set of policies
  { enforce_active_version: false }
end