support publish to coderepo

This commit is contained in:
CaiHQ 2023-04-20 11:48:22 +08:00
parent 3408787a7b
commit c64678f5df
5 changed files with 74 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
deployconfig.json
publishconf.json
.DS_Store
/build/
/testinput/

View File

@ -5,7 +5,7 @@ plugins {
id 'signing'
}
group "org.bdware.bdcontract"
version "0.7.1"
version "0.7.2"
sourceCompatibility = 1.8
repositories {
mavenCentral()
@ -20,6 +20,8 @@ dependencies {
implementation 'org.bouncycastle:bcprov-jdk15on:1.69'
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
implementation 'org.apache.httpcomponents:httpmime:4.5.13'
implementation 'org.bdware.doip:bdosclient:0.0.2'
// implementation 'org.bdware.doip:doip-audit-tool:1.2.4'
testImplementation 'junit:junit:4.13.2'
}

7
publishconf.json Normal file
View File

@ -0,0 +1,7 @@
{
"routerURI": "tcp://127.0.0.1:21041",
"codeRepoId": "bdtest/CodeRepository",
"ypkPath": "/Users/huaqiancai/BDWare/bdware-address/node-storage/build/node-storage-0.0.1.ypk",
"publicKey": "04180354fdb6507f8ab98ccfbe165ce11da74ba733f81af86ad6d32216b32cf4f797c559d50ceeefbf4c760c3483840471c67471b90acdffb388cd7d496d9a1610",
"privateKey": "1d4196947f59532db6f8f4055e58474a48db8f30b476ae3edc66406464521b3b"
}

View File

@ -0,0 +1,54 @@
package org.bdware.ypkdeploy;
import com.google.gson.JsonObject;
import org.bdware.bdosclient.CodeRepoClient;
import org.bdware.doip.audit.EndpointConfig;
import org.bdware.doip.audit.client.AuditIrpClient;
import org.bdware.doip.audit.config.FileStorage;
import org.bdware.doip.codec.doipMessage.DoipMessage;
import org.zz.gmhelper.SM2KeyPair;
import java.util.concurrent.atomic.AtomicInteger;
public class CodeRepoTool {
static class Config {
}
public static void publish(String publishConfig) throws Exception {
FileStorage storage = new FileStorage(publishConfig);
EndpointConfig endpointConfig = storage.loadAsEndpointConfig();
AuditIrpClient irpClient = new AuditIrpClient(endpointConfig);
JsonObject arg = storage.load();
CodeRepoClient client = new CodeRepoClient(arg.get("codeRepoId").getAsString(), irpClient, SM2KeyPair.fromJson(arg.toString()));
String ypkPath = arg.get("ypkPath").getAsString();
AtomicInteger result = new AtomicInteger(0);
client.createAndUpload(ypkPath, new CodeRepoClient.ProgressCallback() {
@Override
public void onStart(String doId) {
System.out.println("[CodeRepoTool] onStart:" + doId);
}
@Override
public void onProgress(String doId, int currentChunk, int totalChunk) {
System.out.println("[CodeRepoTool] " + doId + " progress: " + currentChunk + "/" + totalChunk);
}
@Override
public void onFinish(String doId) {
System.out.println("[CodeRepoTool] onFinish:" + doId);
result.incrementAndGet();
}
@Override
public void onError(String message, DoipMessage msg) {
System.out.println("[CodeRepoTool] error:" + message);
System.out.println("[CodeRepoTool] doipMsg:" + msg.body.getDataAsJsonString());
result.incrementAndGet();
}
});
for (; result.get() == 0; ) {
Thread.yield();
}
}
}

View File

@ -0,0 +1,9 @@
import org.bdware.ypkdeploy.CodeRepoTool;
import org.junit.Test;
public class CodeRepoToolTest {
@Test
public void run() throws Exception {
CodeRepoTool.publish("./publishconf.json");
}
}