kubeshop / vscode-monokle

An extension for Visual Studio Code to validate your Kubernetes configuration
https://marketplace.visualstudio.com/items?itemName=kubeshop.monokle
MIT License
6 stars 0 forks source link

The 'overwriteRemotePolicyUrl' configuration is not working #47

Closed f1ames closed 9 months ago

f1ames commented 10 months ago

I just took a quick peek into how Api URL overwriting is implemented here, in context of admission controller, and based on the code I see it won't work.

There is const with default URL defined (pointing to dev instance):

https://github.com/kubeshop/vscode-monokle/blob/924c8b68e9b6d31a51cda2924e3509f5ed7d7eb7/src/constants.ts#L9

And then there is global getter using it and overwrite config:

https://github.com/kubeshop/vscode-monokle/blob/924c8b68e9b6d31a51cda2924e3509f5ed7d7eb7/src/utils/globals.ts#L30-L32

The problem is (and the fact that it works now well, querying production Monokle Cloud) is that it is not propagated, and extension uses default synchronizer:

https://github.com/kubeshop/vscode-monokle/blob/924c8b68e9b6d31a51cda2924e3509f5ed7d7eb7/src/utils/synchronization.ts#L24-L25

Which in turn has it's own defaults (pointing to production instance), through ApiHandler util:


To fix this, remoteUrl getter should just return overwrites:

get remotePolicyUrl() { 
  return process.env.MONOKLE_TEST_SERVER_URL ?? this.overwriteRemotePolicyUrl; 
} 

and pass a result to synchronizer initialization (to ApiHandler instance) - if empty string is passed it will still use default production API, if overwrite (or test env var) is used it will use this new URL.

f1ames commented 9 months ago

This needs to be reworked to origin similarly as done in CLI in https://github.com/kubeshop/monokle-cli/issues/23.