apolloconfig / apollo

Apollo is a reliable configuration management system suitable for microservice configuration management scenarios.
https://www.apolloconfig.com
Apache License 2.0
28.94k stars 10.19k forks source link

use apollo openapi create properties file, can not create explanatory note #5095

Closed pengbiaobeyond closed 2 months ago

pengbiaobeyond commented 4 months ago

use apollo openapi create properties file, can not create explanatory note 使用apollo的openapi创建properties配置文件,不能创建注释 image zhe这里的备注只存放在库里,并不是文件中的注释信息

dosubot[bot] commented 4 months ago

🤖

嘿,@pengbiaobeyond!很高兴再次见到你,希望你一切都好!

根据我对Apollo的理解,Apollo的OpenAPI在创建properties配置文件时,不支持在文件中创建注释。这是因为Apollo的设计理念是将配置中心视为一个数据库,而不是一个文件系统。因此,所有的配置项(包括注释)都存储在数据库中,而不是文件中。

在Apollo中,你可以为每个配置项添加注释,这些注释将存储在数据库中,而不是properties文件中。当你通过Apollo的OpenAPI获取配置时,你可以获取到这些注释,但是它们不会出现在properties文件中。

如果你需要在properties文件中添加注释,你可能需要在获取配置后,自行将注释添加到文件中。但请注意,这可能会使得配置的管理变得更加复杂,因为你需要同时管理数据库中的注释和文件中的注释。

希望这个解答能帮助到你。如果你有更多的问题,欢迎继续提问。

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. If you want to continue the conversation, start your reply with @dosu-bot.
pengbiaobeyond commented 4 months ago

Hope to receive a manual reply

pengbiaobeyond commented 4 months ago

希望老师帮忙确认下,是否是上边的解释,否则机器人回复心里没底

BlackBear2003 commented 4 months ago

是存在数据库里的,ui上的文本里面也是通过读数据库来渲染的 🤔️

pengbiaobeyond commented 4 months ago

ui上的文本里边的注释在数据库中item表中的数据是key、value字段的值是空,comment字段的值是注释; 但是通过openApi,只能创建key、value有值,comment是key和value的备注,不是注释,ui无法渲染

pengbiaobeyond commented 4 months ago

如果存在注释的话,注释和key、value在item表里是两条数据

pengbiaobeyond commented 4 months ago

但是openApi只能创建一条数据

pengbiaobeyond commented 4 months ago

无法渲染注释

pengbiaobeyond commented 4 months ago

只有下图的红框的数据才可以渲染成注释,第一条数据是第二条数据的注释

pengbiaobeyond commented 4 months ago
1708430375997
pengbiaobeyond commented 4 months ago

但是openApi创建的properties配置是这样的,所以无法渲染

1708430483805
BlackBear2003 commented 4 months ago

找了下代码,确实是这样

             function parsePropertiesText(namespace) {
                var result = "";
                var itemCnt = 0;
                namespace.items.forEach(function (item) {
                    //deleted key
                    if (item.isDeleted) {
                        return;
                    }
                    if (item.item.key) {
                        //use string \n to display as new line
                        var itemValue = item.item.value.replace(/\n/g, "\\n");

                        result +=
                            item.item.key + " = " + itemValue + "\n";
                    } else {
                        result += item.item.comment + "\n";
                    }
                    itemCnt++;
                });

                namespace.itemCnt = itemCnt;
                return result;
            }
pengbiaobeyond commented 4 months ago

所以说openApi目前是无法支持给properties配置文件添加注释的对吧

BlackBear2003 commented 4 months ago

表格里面可以看到,但是文本里面好像是渲染不出来

pengbiaobeyond commented 4 months ago

恩恩,就是数据库表里可以看到,只是无法渲染到页面上对吧

BlackBear2003 commented 4 months ago

可以等明天maintainer大佬来给个准确的回复 😳

pengbiaobeyond commented 4 months ago

好的,辛苦您明天帮我问下,谢谢

pengbiaobeyond commented 4 months ago

麻烦大佬今天帮忙看下

pengbiaobeyond commented 4 months ago

辛苦老师帮忙看下,拜托

BlackBear2003 commented 4 months ago

我认为你的想法是对的,但我并不是官方人员,没法给你准确的回复 😂

nobodyiam commented 4 months ago

properties 文件的注释是在内容里面的,如

# comment 1
key1 = value1
# comment 2
key2 = value2

通过文本模式可以看到,不过请注意这个注释在表格模式是看不到的(设计如此) image

pengbiaobeyond commented 4 months ago

我明白,但是通过openapi去添加properties配置文件中的内容时,是无法添加注释的

pengbiaobeyond commented 4 months ago

您上边的截图其实在数据库item表中是四条数据,但是openApi无法创建注释数据, image

nobodyiam commented 4 months ago

如果是单个配置的话是可以的,下面是我的测试代码和结果

  @Test
  public void testCreate() {
    OpenItemDTO itemDTO = new OpenItemDTO();
    itemDTO.setKey("testKey");
    itemDTO.setValue("testValue");
    itemDTO.setComment("测试注释");
    itemDTO.setDataChangeCreatedBy(operator);

    OpenItemDTO result = client.createItem(appId, env, null, null, itemDTO);

    System.out.println(result);
  }

image

pengbiaobeyond commented 4 months ago

好的,明白了,谢谢

stale[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

stale[bot] commented 2 months ago

This issue has been automatically closed because it has not had activity in the last 7 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". Thank you for your contributions.