[Feature Toggles] I can't figure out how recording...
# pactflow-ama
j
[Feature Toggles] I can't figure out how recording deployments on envs and Can I Deploy work with feature toggles? The use case I have trouble with is when: 1. consumer has a pact towards provider checking 20 APIs and is on prod 2. Consumer adds 21st interaction with same provider and wants to deploy to prod but with a feature disabled by the feature toggle for this single new API. 3. therefore on prod this api will never be called, but the whole rest of other APIs in pact should be validated. 4. Consumer in main branch already satisfies the contract but is not on prod yet How to 1. deploy the consumer to prod
m
Have you tried using Pending and WIP Pacts?
m
1. consumer has a pact towards provider checking 20 APIs and is on prod
I assume you mean interactions here? different API interactions for a single provider?
1. Consumer adds 21st interaction with same provider and wants to deploy to prod but with a feature disabled by the feature toggle for this single new API.
Is the toggle on the consumer or provider? Based on (3) i’m assuming it’s a consumer toggle
j
yes, consumer toggle
Pending and WIP require either 1. date until they're WIP, and actually this is not a WIP but interactions are on prod, but unused, and I want to enable them with a feature toggle, not a date 2. pending is what is tricky, because interaction is successfully verified by provider, but not deployed to prod.
So how are consumer toggles handled by Pact in Can I Deploy?
m
(sorry, I last track of this thread) Pact doesn’t have the concept of a toggle. It’s either an interaction in the contract or it’s not. The current recommendation is to use tags to maintain the various toggles you need, and use additional
can-i-deploy
checks to check a feature toggle before launching it. (assuming you have read/seen this: https://docs.pact.io/pact_broker/tags#using-tags-with-feature-toggles-instead-of-feature-branches ?)
So effectively, if the consumer has the feature but it’s toggled off, it needs to be a separately versioned contract (and therefore, deployable application). Ditto a version of the consumer with it toggled on. So in your case, you need to remove the toggled feature from the consumer that is to be deployed, because it’s not enabled but Pact has no way of knowing this
j
Can Recod Release be used somehow for feature toggles? I mean I can record deployment code and contract to env, but wait with releasing it (it is turned off) and recording the release when enabling Feature Flag