Closed priyanka212 closed 7 months ago
@priyanka212 - that surely is a complex Condition which it not very normal. I have few suggestions/recommendations
1) You can include an ignore argument in the apigeelint command so that it ignores any warnings and errors from a particular rule(s)
apigeelint -s apiproxy -e CC003,CC004 -f html.js
That will ignore these rule checks. Keep in mind that this will completely ignore those rules so if you want to lint them, you wont be able to by including them in the main args. Am not aware of your pipeline code, if you have a shared library that is used by all your proxies, then adding the ignore argument will ignore the checks for all the proxies you use with that pipeline. So keep that in mind as well
2) The other option is to remove the above condition and probably move that to a JavaScript policy, say something like
var paths = ["/tst/test-get", "/get-tst-codes", "/zip/tst", "/tst-zips", "/tst-metadata"]
var pathSuffix = context.getVariable("proxy.pathsuffix")
var bool = false;
for (var path of paths){
if(pathSuffix.includes(path))
bool = true;
}
context.setVariable("bool", bool)
Execute the above JS condition before the actual policy and then in your actual Condition, just have
<Condition>bool = true AND request.verb !=POST</Condition>
PS: The above JS code is not tested, just typed a logic I thought. Please test them if you plan to use it
Let me know your thoughts.
Thanks for response, its helpful.
These conditions are required to be reused in every proxy - 200+ proxies. In that case I will require to use JS policy in all the proxies which is performance heavy. I believe that is not good design.
For deployment pipeline you are correct, we have single pipeline for all proxy and would not want to skip this lint for all the proxies.
Do we have any other way?
I dont agree that its going to be performance heavy. Apigee will require same time (theoretically) to execute the condition too since you are using Regex. I would suggest making the change and run some tests to see if the latency is same or increased.
The other option I can think is to execute apigeelint with the ignore flags for the proxies that has similar conditions in your pipeline.
Besides these, I dont see another option. Since its not plugin related, I will close this issue
Ok Thanks.
Hi,
I have written a condition for path suffix in tag in conditional flows. It had 4-5 conditions with OR & AND operators. Like below:
(!(proxy.pathsuffix JavaRegex "(^/test/tst-get$)|(^/get-test-codes$)|(^/zip/test$)|(^/tst-zips$)|(^/tst-metadata$)"))
OR
I am getting warnings for too many terms in condition & too many characters. (CC003 & CC004)
How should I avoid this warning. What are the recommendations?
I will need to use those conditions to be able to raise fault correctly, at the same time my CI/CD pipeline shows warnings & makes my build amber.
please suggest