You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/08/04 08:06:02 UTC

[GitHub] [servicecomb-java-chassis] GuoYL123 opened a new pull request #1909: [SCB-2057] set the AppId, ServiceName, Version information by reading…

GuoYL123 opened a new pull request #1909:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1909


   … the environment variable
   
   (cherry picked from commit 9f6c57220fa48cd2f53324124ae0271b5ddae16f)
   
   Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
    - [ ] Each commit in the pull request should have a meaningful subject line and body.
    - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue.
    - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [ ] Run `mvn clean install -Pit` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   ---
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] GuoYL123 commented on a change in pull request #1909: [SCB-2057] set the AppId, ServiceName, Version information by reading…

Posted by GitBox <gi...@apache.org>.
GuoYL123 commented on a change in pull request #1909:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1909#discussion_r465547787



##########
File path: foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/api/registry/MicroserviceFactory.java
##########
@@ -49,14 +54,33 @@ public Microservice create(MicroserviceDefinition microserviceDefinition) {
 
   private Microservice createMicroserviceFromDefinition(Configuration configuration) {
     Microservice microservice = new Microservice();
-    microservice.setServiceName(configuration.getString(CONFIG_QUALIFIED_MICROSERVICE_NAME_KEY,
-        DEFAULT_MICROSERVICE_NAME));
-    microservice.setAppId(configuration.getString(CONFIG_APPLICATION_ID_KEY, DefinitionConst.DEFAULT_APPLICATION_ID));
-    String version = configuration.getString(CONFIG_QUALIFIED_MICROSERVICE_VERSION_KEY,
-        DefinitionConst.DEFAULT_MICROSERVICE_VERSION);
-    // just check version format
-    new Version(version);
-    microservice.setVersion(version);
+
+    EnvironmentConfiguration envConfig = new EnvironmentConfiguration();
+    if (!StringUtils.isEmpty(envConfig.getString(APP_MAPPING)) &&
+        !StringUtils.isEmpty(envConfig.getString(envConfig.getString(APP_MAPPING)))) {
+      microservice.setAppId(envConfig.getString(envConfig.getString(APP_MAPPING)));
+    } else {
+      microservice.setAppId(configuration
+          .getString(CONFIG_APPLICATION_ID_KEY, DefinitionConst.DEFAULT_APPLICATION_ID));
+    }
+    if (!StringUtils.isEmpty(envConfig.getString(SERVICE_MAPPING)) &&
+        !StringUtils.isEmpty(envConfig.getString(envConfig.getString(SERVICE_MAPPING)))) {
+      microservice.setServiceName(envConfig.getString(envConfig.getString(SERVICE_MAPPING)));
+    } else {
+      microservice.setServiceName(configuration.getString(CONFIG_QUALIFIED_MICROSERVICE_NAME_KEY,
+          DEFAULT_MICROSERVICE_NAME));
+    }
+    if (!StringUtils.isEmpty(envConfig.getString(VERSION_MAPPING)) &&
+        !StringUtils.isEmpty(envConfig.getString(envConfig.getString(VERSION_MAPPING)))) {
+      microservice.setVersion(envConfig.getString(envConfig.getString(VERSION_MAPPING)));
+    } else {
+      // just check version format
+      String version = configuration.getString(CONFIG_QUALIFIED_MICROSERVICE_VERSION_KEY,
+          DefinitionConst.DEFAULT_MICROSERVICE_VERSION);
+      new Version(version);

Review comment:
       done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] coveralls commented on pull request #1909: [SCB-2057] set the AppId, ServiceName, Version information by reading…

Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #1909:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1909#issuecomment-668494106


   
   [![Coverage Status](https://coveralls.io/builds/32524768/badge)](https://coveralls.io/builds/32524768)
   
   Coverage decreased (-0.01%) to 86.259% when pulling **a038981fd2ec2b9ff88bb1692bbfd9039b2d8486 on GuoYL123:mmaster** into **ad9516dfad410a4162a7180336306200f410c0c1 on apache:master**.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1909: [SCB-2057] set the AppId, ServiceName, Version information by reading…

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #1909:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1909#discussion_r465413381



##########
File path: foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/api/registry/MicroserviceFactory.java
##########
@@ -49,14 +54,33 @@ public Microservice create(MicroserviceDefinition microserviceDefinition) {
 
   private Microservice createMicroserviceFromDefinition(Configuration configuration) {
     Microservice microservice = new Microservice();
-    microservice.setServiceName(configuration.getString(CONFIG_QUALIFIED_MICROSERVICE_NAME_KEY,
-        DEFAULT_MICROSERVICE_NAME));
-    microservice.setAppId(configuration.getString(CONFIG_APPLICATION_ID_KEY, DefinitionConst.DEFAULT_APPLICATION_ID));
-    String version = configuration.getString(CONFIG_QUALIFIED_MICROSERVICE_VERSION_KEY,
-        DefinitionConst.DEFAULT_MICROSERVICE_VERSION);
-    // just check version format
-    new Version(version);
-    microservice.setVersion(version);
+
+    EnvironmentConfiguration envConfig = new EnvironmentConfiguration();
+    if (!StringUtils.isEmpty(envConfig.getString(APP_MAPPING)) &&
+        !StringUtils.isEmpty(envConfig.getString(envConfig.getString(APP_MAPPING)))) {
+      microservice.setAppId(envConfig.getString(envConfig.getString(APP_MAPPING)));
+    } else {
+      microservice.setAppId(configuration
+          .getString(CONFIG_APPLICATION_ID_KEY, DefinitionConst.DEFAULT_APPLICATION_ID));
+    }
+    if (!StringUtils.isEmpty(envConfig.getString(SERVICE_MAPPING)) &&
+        !StringUtils.isEmpty(envConfig.getString(envConfig.getString(SERVICE_MAPPING)))) {
+      microservice.setServiceName(envConfig.getString(envConfig.getString(SERVICE_MAPPING)));
+    } else {
+      microservice.setServiceName(configuration.getString(CONFIG_QUALIFIED_MICROSERVICE_NAME_KEY,
+          DEFAULT_MICROSERVICE_NAME));
+    }
+    if (!StringUtils.isEmpty(envConfig.getString(VERSION_MAPPING)) &&
+        !StringUtils.isEmpty(envConfig.getString(envConfig.getString(VERSION_MAPPING)))) {
+      microservice.setVersion(envConfig.getString(envConfig.getString(VERSION_MAPPING)));
+    } else {
+      // just check version format
+      String version = configuration.getString(CONFIG_QUALIFIED_MICROSERVICE_VERSION_KEY,
+          DefinitionConst.DEFAULT_MICROSERVICE_VERSION);
+      new Version(version);

Review comment:
       version check can be done in setter, or easily missed checking when setting. e.g. for environment, this check is missed. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 merged pull request #1909: [SCB-2057] set the AppId, ServiceName, Version information by reading…

Posted by GitBox <gi...@apache.org>.
liubao68 merged pull request #1909:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1909


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] coveralls edited a comment on pull request #1909: [SCB-2057] set the AppId, ServiceName, Version information by reading…

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #1909:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1909#issuecomment-668494106


   
   [![Coverage Status](https://coveralls.io/builds/32576871/badge)](https://coveralls.io/builds/32576871)
   
   Coverage decreased (-0.009%) to 86.293% when pulling **4586e3a14383b06a5b16e7a9004d2387a4847a13 on GuoYL123:mmaster** into **cb47f4c31fee7468ef5d8cfe0aed2d53a73d08cd on apache:master**.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] GuoYL123 commented on a change in pull request #1909: [SCB-2057] set the AppId, ServiceName, Version information by reading…

Posted by GitBox <gi...@apache.org>.
GuoYL123 commented on a change in pull request #1909:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1909#discussion_r466216473



##########
File path: foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/api/registry/MicroserviceFactory.java
##########
@@ -49,14 +54,33 @@ public Microservice create(MicroserviceDefinition microserviceDefinition) {
 
   private Microservice createMicroserviceFromDefinition(Configuration configuration) {
     Microservice microservice = new Microservice();
-    microservice.setServiceName(configuration.getString(CONFIG_QUALIFIED_MICROSERVICE_NAME_KEY,
-        DEFAULT_MICROSERVICE_NAME));
-    microservice.setAppId(configuration.getString(CONFIG_APPLICATION_ID_KEY, DefinitionConst.DEFAULT_APPLICATION_ID));
-    String version = configuration.getString(CONFIG_QUALIFIED_MICROSERVICE_VERSION_KEY,
-        DefinitionConst.DEFAULT_MICROSERVICE_VERSION);
-    // just check version format
-    new Version(version);
-    microservice.setVersion(version);
+
+    EnvironmentConfiguration envConfig = new EnvironmentConfiguration();
+    if (!StringUtils.isEmpty(envConfig.getString(APP_MAPPING)) &&
+        !StringUtils.isEmpty(envConfig.getString(envConfig.getString(APP_MAPPING)))) {
+      microservice.setAppId(envConfig.getString(envConfig.getString(APP_MAPPING)));
+    } else {
+      microservice.setAppId(configuration
+          .getString(CONFIG_APPLICATION_ID_KEY, DefinitionConst.DEFAULT_APPLICATION_ID));
+    }
+    if (!StringUtils.isEmpty(envConfig.getString(SERVICE_MAPPING)) &&
+        !StringUtils.isEmpty(envConfig.getString(envConfig.getString(SERVICE_MAPPING)))) {
+      microservice.setServiceName(envConfig.getString(envConfig.getString(SERVICE_MAPPING)));
+    } else {
+      microservice.setServiceName(configuration.getString(CONFIG_QUALIFIED_MICROSERVICE_NAME_KEY,
+          DEFAULT_MICROSERVICE_NAME));
+    }
+    if (!StringUtils.isEmpty(envConfig.getString(VERSION_MAPPING)) &&
+        !StringUtils.isEmpty(envConfig.getString(envConfig.getString(VERSION_MAPPING)))) {
+      microservice.setVersion(envConfig.getString(envConfig.getString(VERSION_MAPPING)));
+    } else {
+      // just check version format
+      String version = configuration.getString(CONFIG_QUALIFIED_MICROSERVICE_VERSION_KEY,
+          DefinitionConst.DEFAULT_MICROSERVICE_VERSION);
+      new Version(version);

Review comment:
       in setter will cause jackson parse failed




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org