Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions sdk/src/main/java/org/zstack/sdk/GetDevToolTestStatusAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package org.zstack.sdk;

import java.util.HashMap;
import java.util.Map;
import org.zstack.sdk.*;

public class GetDevToolTestStatusAction extends AbstractAction {

private static final HashMap<String, Parameter> parameterMap = new HashMap<>();

private static final HashMap<String, Parameter> nonAPIParameterMap = new HashMap<>();

public static class Result {
public ErrorCode error;
public org.zstack.sdk.GetDevToolTestStatusResult value;

public Result throwExceptionIfError() {
if (error != null) {
throw new ApiException(
String.format("error[code: %s, description: %s, details: %s, globalErrorCode: %s]", error.code, error.description, error.details, error.globalErrorCode)
);
}

return this;
}
}

@Param(required = false, nonempty = false, nullElements = false, emptyString = true, noTrim = false, maxLength = 255)
public java.lang.String resourceUuid;

@Param(required = false)
public java.util.List systemTags;

@Param(required = false)
public java.util.List userTags;

@Param(required = false)
public String sessionId;

@Param(required = false)
public String accessKeyId;

@Param(required = false)
public String accessKeySecret;

@Param(required = false)
public String requestIp;


private Result makeResult(ApiResult res) {
Result ret = new Result();
if (res.error != null) {
ret.error = res.error;
return ret;
}

org.zstack.sdk.GetDevToolTestStatusResult value = res.getResult(org.zstack.sdk.GetDevToolTestStatusResult.class);
ret.value = value == null ? new org.zstack.sdk.GetDevToolTestStatusResult() : value;

return ret;
}

public Result call() {
ApiResult res = ZSClient.call(this);
return makeResult(res);
}

public void call(final Completion<Result> completion) {
ZSClient.call(this, new InternalCompletion() {
@Override
public void complete(ApiResult res) {
completion.complete(makeResult(res));
}
});
}

protected Map<String, Parameter> getParameterMap() {
return parameterMap;
}

protected Map<String, Parameter> getNonAPIParameterMap() {
return nonAPIParameterMap;
}

protected RestInfo getRestInfo() {
RestInfo info = new RestInfo();
info.httpMethod = "GET";
info.path = "/dev-tool-test/status";
info.needSession = true;
info.needPoll = false;
info.parameterName = "params";
return info;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.zstack.sdk;

public class GetDevToolTestStatusResult {
}
28 changes: 28 additions & 0 deletions testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -56955,4 +56955,32 @@ abstract class ApiHelper {
}




def getDevToolTestStatus(@DelegatesTo(strategy = Closure.OWNER_FIRST, value = org.zstack.sdk.GetDevToolTestStatusAction.class) Closure c) {
def a = new org.zstack.sdk.GetDevToolTestStatusAction()
a.sessionId = Test.currentEnvSpec?.session?.uuid
c.resolveStrategy = Closure.OWNER_FIRST
c.delegate = a
c()



if (System.getProperty("apipath") != null) {
if (a.apiId == null) {
a.apiId = Platform.uuid
}

def tracker = new ApiPathTracker(a.apiId)
def out = errorOut(a.call())
def path = tracker.getApiPath()
if (!path.isEmpty()) {
Test.apiPaths[a.class.name] = path.join(" --->\n")
}

return out
} else {
return errorOut(a.call())
}
}
}
1 change: 1 addition & 0 deletions zstack-dev-tool/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dependency-reduced-pom.xml
17 changes: 17 additions & 0 deletions zstack-dev-tool/dev-tool
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# ZStack Dev Tool - static code generation checker
# Usage: ./dev-tool check|generate|scan [globalconfig|all]

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
JAR="$SCRIPT_DIR/target/dev-tool.jar"

if [ ! -f "$JAR" ]; then
echo "Building dev-tool..."
cd "$SCRIPT_DIR" && mvn package -DskipTests -q
if [ $? -ne 0 ]; then
echo "ERROR: Build failed"
exit 1
fi
fi

cd "$SCRIPT_DIR/.." && java -jar "$JAR" "$@"
69 changes: 69 additions & 0 deletions zstack-dev-tool/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.zstack</groupId>
<artifactId>zstack-dev-tool</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>zstack-dev-tool</name>
<description>Static code generation tool for ZStack CI checks</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<javaparser.version>3.25.8</javaparser.version>
</properties>

<dependencies>
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>${javaparser.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.1</version>
<executions>
<execution>
<phase>package</phase>
<goals><goal>shade</goal></goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.zstack.devtool.DevTool</mainClass>
</transformer>
</transformers>
<finalName>dev-tool</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading