Azure / apiops

APIOps applies the concepts of GitOps and DevOps to API deployment. By using practices from these two methodologies, APIOps can enable everyone involved in the lifecycle of API design, development, and deployment with self-service and automated tools to ensure the quality of the specifications and APIs that they’re building.
https://azure.github.io/apiops
MIT License
328 stars 192 forks source link

When extracting just an api via the config.yaml file, the global policy xml file is extracted as well and shouldn't be. #586

Open karlrissland opened 4 months ago

karlrissland commented 4 months ago

Release version

v6.0.0-alpha.1.0.8

Describe the bug

My config.yaml is set to only extract an api as follows;

` apiNames:

Expected behavior

I expect only the API specification, the API apim config, the api policy, and the api operation policies to be extracted. In this use case, the developer should only be able to work with the api and it's specific policies.

Actual behavior

Unfortunately, the global policy is also extracted along with the api and it's policies.

Reproduction Steps

Setup an config.yaml file to extract just one api, run the extractor, not that the api and it's policies are extracted and the global policy is also extracted.

github-actions[bot] commented 4 months ago
  Thank you for opening this issue! Please be patient while we will look into it and get back to you as this is an open source project. In the meantime make sure you take a look at the [closed issues](https://github.com/Azure/apiops/issues?q=is%3Aissue+is%3Aclosed) in case your question has already been answered. Don't forget to provide any additional information if needed (e.g. scrubbed logs, detailed feature requests,etc.).
  Whenever it's feasible, please don't hesitate to send a Pull Request (PR) our way. We'd greatly appreciate it, and we'll gladly assess and incorporate your changes.
rubenaster commented 3 months ago

And what's even worse is that without this policy.xml file the publisher wants to delete the current policy - fortunately in our case this raises a 403 - but that's the least sensible behavior I would expect when I only define a single extracted API.

waelkdouh commented 3 months ago

Will take a look and get back to you.

guythetechie commented 3 months ago

API filters only affect items related to specific APIs. Service-level policies sit above APIs and aren't impacted by API filters. Just like product-level policies wouldn't be affected by API filters; if you only extract ApiA, the policy for productB would still be extracted.

If you want to specifically exclude service-level policies, your best bet would be to add a .gitignore entry for rootpath/policy.xml.

waelkdouh commented 3 months ago

And what's even worse is that without this policy.xml file the publisher wants to delete the current policy - fortunately in our case this raises a 403 - but that's the least sensible behavior I would expect when I only define a single extracted API.

Please post here a format of the configuration file that you think would make sense if we were to expand support filtering global level artifacts.

rubenaster commented 3 months ago

And what's even worse is that without this policy.xml file the publisher wants to delete the current policy - fortunately in our case this raises a 403 - but that's the least sensible behavior I would expect when I only define a single extracted API.

Update: My bad, I had a combination of removing the policy.xml from the last commit and using the last_commit setting, so it made sense. I currently have a FileRemove task that cleans up specific files, but I'll provide an idea for a configuration.