Skip to content

Commit

Permalink
增加APPBUILDER_SDK_PLATFORM参数 (#387)
Browse files Browse the repository at this point in the history
* 增加APPBUILDER_SDK_PLATFORM参数

* update image

* update

* Update bcc_deploy.py

* resolve conflicts

* Update bcc_deploy.py

* 公有云部署使用文档 (#386)

* 公有云部署使用文档

* compress image

* update

* update

* update

* update

* update image

* update

* Update bcc_deploy.py

* resolve conflicts

* Update bcc_deploy.py

* rebase master
  • Loading branch information
userpj authored Jun 28, 2024
1 parent 4f2c8c8 commit c64a757
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
2 changes: 2 additions & 0 deletions appbuilder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

__version__ = '0.9.0'

import os
import sys
import copy
import pydantic
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions appbuilder/utils/bce_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion go/appbuilder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand All @@ -147,8 +152,11 @@ public ClassicHttpRequest createGetRequestV2(String url, Map<String, Object> 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()) {
Expand All @@ -165,8 +173,11 @@ public ClassicHttpRequest createDeleteRequestV2(String url, Map<String, Object>
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()) {
Expand Down

0 comments on commit c64a757

Please sign in to comment.