Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

麻烦问下,有什么办法能同时读到多个环境同一个配置的值吗? #5133

Open
adgai opened this issue Apr 27, 2024 · 3 comments

Comments

@adgai
Copy link

adgai commented Apr 27, 2024

清晰简洁地描述这个问题是什么。即,当碰到xxx时,总是感觉很麻烦

我们目前项目中获取配置是使用 configService.get(key),这样的形式,需要看到key 对应的value 只能到 portal 中看,我想开发一个插件展示各个环境的值,所以想同时获取到多个环境的值。

Copy link

dosubot bot commented Apr 27, 2024

To simultaneously fetch and display configuration values for a specific key across multiple environments, you can develop a plugin by following these steps:

  1. Integrate with Apollo: Use Apollo client APIs to fetch configuration data for the desired key across the environments you're interested in. This involves making API calls similar to ConfigService.find_items() for each environment.

  2. Develop the User Interface: Create a UI where users can select a configuration key and multiple environments. You can take inspiration from the diff.html file, utilizing elements like the cluster selector and display format options.

  3. Fetch and Display Configurations: Implement functionality to fetch the configuration values upon form submission and display them in a user-friendly format. Adapt the table structure from diff.html for displaying the values across environments.

  4. Code Example for Fetching Configurations:

    function fetchConfigForKey(appId, envs, clusterName, namespaceName, key) {
        let promises = envs.map(env => 
            ConfigService.find_items(appId, env, clusterName, namespaceName)
            .then(items => items.find(item => item.key === key))
        );
        return Promise.all(promises);
    }
  5. Optimize User Experience: Include features like filtering, sorting, a refresh button, and possibly a search functionality to enhance the plugin's usability.

Ensure your plugin has comprehensive error handling, considers performance optimization through caching, and enforces security measures to protect sensitive configurations. This approach builds on the functionality seen in the Apollo portal's DiffConfigController.js and diff.html, extending it to focus on your specific requirement of displaying configuration keys across multiple environments.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

@nobodyiam
Copy link
Member

可以接入 Open API

@adgai
Copy link
Author

adgai commented Apr 27, 2024

open api 如果获取一个没配的key 会404,在获取生产环境的key的值时不太合适

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants