Update requirements system to allow increment rollout of requirement changes
Problem
Currently our requirements system is single constant that allows for config of the requirements of a product. This is a problem when we want to rollout changes to environments incrementally (for testing or controlled release), as any change will go to all environments.
Proposal
- Change the requirements definition to be a method instead of a constant, so that conditional configuration based on feature flags can be applied.
- Refactor the requirements system to accept a purchase object instead of a raw hash so that we can validated based on all the purchase args more easily.
For example, a simple implementation of this might look like:
def self.check(purchase)
requirements = case purchase.plan_type
when :gitlab_credits
gitlab_credits_requirements(purchase)
else
Failure()
end
requirements.filter_map { |requirement| requirement.unmet? & requirement.error_message }
end
def self.gitlab_credits_requirements(purchase)
requirements = []
requirements << ActiveSubscription.new(subscription: purchase.subscription) if feature_flag_disabled?
requirements << NewRatePlan.new(product_rate_plan_charge: purchase.product_rate_plan_charge, subscription: purchase.subscription)
# ...
requirements
end
Edited by Josianne Hyson