diff --git a/appbuilder/__init__.py b/appbuilder/__init__.py index f273cbfd2..ef550f369 100644 --- a/appbuilder/__init__.py +++ b/appbuilder/__init__.py @@ -15,6 +15,7 @@ __version__ = '0.9.0' +import os import sys import copy import pydantic @@ -41,6 +42,7 @@ def check_version(self): class SDKReportConfig(pydantic.BaseModel): appbuilder_sdk_version: str = __version__ appbuilder_sdk_language: str = "python" + appbuilder_sdk_platform: str = os.environ.get("APPBUILDER_SDK_PLATFORM", "unknown") # report information diff --git a/appbuilder/utils/bce_deploy.py b/appbuilder/utils/bce_deploy.py index e9e2731be..37cad8136 100644 --- a/appbuilder/utils/bce_deploy.py +++ b/appbuilder/utils/bce_deploy.py @@ -113,8 +113,8 @@ def build_user_data(self): f"rm {self.tar_file_name}\\n" + \ f"chmod a+x {self.run_script_name}\\n" + \ "yum install -y docker\\n" + \ - "docker pull registry.baidubce.com/appbuilder/appbuilder-sdk-devel:0.8.0\\n" + \ - f"docker run -itd --net=host -v /root/test:{workspace} --name appbuilder-sdk registry.baidubce.com/appbuilder/appbuilder-sdk-devel:0.8.0 {workspace}/{self.run_script_name}" + "docker pull registry.baidubce.com/appbuilder/appbuilder-sdk-cloud:0.9.0\\n" + \ + f"docker run -itd --net=host -v /root/test:{workspace} --name appbuilder-sdk registry.baidubce.com/appbuilder/appbuilder-sdk-cloud:0.9.0 {workspace}/{self.run_script_name}" return user_data diff --git a/go/appbuilder/config.go b/go/appbuilder/config.go index 35d90a5dd..e75ee0887 100644 --- a/go/appbuilder/config.go +++ b/go/appbuilder/config.go @@ -132,8 +132,12 @@ func (t *SDKConfig) AuthHeaderV2() http.Header { func (t *SDKConfig) authHeader() http.Header { header := make(http.Header) + platform := os.Getenv("APPBUILDER_SDK_PLATFORM") + if platform == "" { + platform = "unknown" + } header.Set("X-Appbuilder-Origin", "appbuilder_sdk") - header.Set("X-Appbuilder-Sdk-Config", "{\"appbuilder_sdk_version\":\"0.8.0\",\"appbuilder_sdk_language\":\"go\"}") + header.Set("X-Appbuilder-Sdk-Config", "{\"appbuilder_sdk_version\":\"0.9.0\",\"appbuilder_sdk_language\":\"go\",\"appbuilder_sdk_platfrom\":\""+platform+"\"}") header.Set("X-Appbuilder-Request-Id", uuid.New().String()) return header } diff --git a/java/src/main/java/com/baidubce/appbuilder/base/utils/http/HttpClient.java b/java/src/main/java/com/baidubce/appbuilder/base/utils/http/HttpClient.java index af5622dec..485284171 100644 --- a/java/src/main/java/com/baidubce/appbuilder/base/utils/http/HttpClient.java +++ b/java/src/main/java/com/baidubce/appbuilder/base/utils/http/HttpClient.java @@ -102,8 +102,11 @@ public ClassicHttpRequest createPostRequest(String url, HttpEntity entity) { HttpPost httpPost = new HttpPost(requestURL); httpPost.setHeader("X-Appbuilder-Authorization", this.SecretKey); httpPost.setHeader("X-Appbuilder-Origin", "appbuilder_sdk"); + String platform = System.getenv("APPBUILDER_SDK_PLATFORM") != null ? System.getenv("APPBUILDER_SDK_PLATFORM") + : "unknown"; httpPost.setHeader("X-Appbuilder-Sdk-Config", - "{\"appbuilder_sdk_version\":\"0.8.0\",\"appbuilder_sdk_language\":\"java\"}"); + "{\"appbuilder_sdk_version\":\"0.9.0\",\"appbuilder_sdk_language\":\"java\",\"appbuilder_sdk_platform\":\"" + + platform + "\"}"); httpPost.setHeader("X-Appbuilder-Request-Id", java.util.UUID.randomUUID().toString()); httpPost.setEntity(entity); String headers = "headers: \n"; @@ -128,8 +131,10 @@ public ClassicHttpRequest createPostRequestV2(String url, HttpEntity entity) { HttpPost httpPost = new HttpPost(requestURL); httpPost.setHeader("Authorization", this.SecretKey); httpPost.setHeader("X-Appbuilder-Origin", "appbuilder_sdk"); + String platform = System.getenv("APPBUILDER_SDK_PLATFORM") != null ? System.getenv("APPBUILDER_SDK_PLATFORM") + : "unknown"; httpPost.setHeader("X-Appbuilder-Sdk-Config", - "{\"appbuilder_sdk_version\":\"0.8.0\",\"appbuilder_sdk_language\":\"java\"}"); + "{\"appbuilder_sdk_version\":\"0.9.0\",\"appbuilder_sdk_language\":\"java\",\"appbuilder_sdk_platform\":\"" + platform + "\"}"); httpPost.setHeader("X-Appbuilder-Request-Id", java.util.UUID.randomUUID().toString()); httpPost.setEntity(entity); String headers = "headers: \n"; @@ -147,8 +152,11 @@ public ClassicHttpRequest createGetRequestV2(String url, Map map HttpGet httpGet = new HttpGet(requestURL); httpGet.setHeader("Authorization", this.SecretKey); httpGet.setHeader("X-Appbuilder-Origin", "appbuilder_sdk"); + String platform = System.getenv("APPBUILDER_SDK_PLATFORM") != null ? System.getenv("APPBUILDER_SDK_PLATFORM") + : "unknown"; httpGet.setHeader("X-Appbuilder-Sdk-Config", - "{\"appbuilder_sdk_version\":\"0.8.0\",\"appbuilder_sdk_language\":\"java\"}"); + "{\"appbuilder_sdk_version\":\"0.9.0\",\"appbuilder_sdk_language\":\"java\",\"appbuilder_sdk_platform\":\"" + + platform + "\"}"); httpGet.setHeader("X-Appbuilder-Request-Id", java.util.UUID.randomUUID().toString()); String headers = "headers: \n"; for (Header header : httpGet.getHeaders()) { @@ -165,8 +173,11 @@ public ClassicHttpRequest createDeleteRequestV2(String url, Map HttpDelete httpDelete = new HttpDelete(requestURL); httpDelete.setHeader("Authorization", this.SecretKey); httpDelete.setHeader("X-Appbuilder-Origin", "appbuilder_sdk"); + String platform = System.getenv("APPBUILDER_SDK_PLATFORM") != null ? System.getenv("APPBUILDER_SDK_PLATFORM") + : "unknown"; httpDelete.setHeader("X-Appbuilder-Sdk-Config", - "{\"appbuilder_sdk_version\":\"0.8.0\",\"appbuilder_sdk_language\":\"java\"}"); + "{\"appbuilder_sdk_version\":\"0.9.0\",\"appbuilder_sdk_language\":\"java\",\"appbuilder_sdk_platform\":\"" + + platform + "\"}"); httpDelete.setHeader("X-Appbuilder-Request-Id", java.util.UUID.randomUUID().toString()); String headers = "headers: \n"; for (Header header : httpDelete.getHeaders()) {