Some stuff for debugging
This commit is contained in:
parent
6b6a84977c
commit
31fb8b3b2a
|
@ -2,6 +2,7 @@ package io.gitlab.jfronny.woodpecker.include;
|
|||
|
||||
import com.amihaiemil.eoyaml.*;
|
||||
import io.gitlab.jfronny.commons.HttpUtils;
|
||||
import io.gitlab.jfronny.commons.log.Logger;
|
||||
import io.gitlab.jfronny.commons.serialize.Serializer;
|
||||
import io.gitlab.jfronny.commons.serialize.gson.api.v1.GsonHolders;
|
||||
import io.gitlab.jfronny.woodpecker.include.model.*;
|
||||
|
@ -12,9 +13,11 @@ import java.io.*;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class Main {
|
||||
public static final Logger LOG = Logger.forName("Woodpecker-Include");
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
if (args.length != 1) {
|
||||
System.err.println("Usage: woodpecker-include <port>");
|
||||
LOG.error("Usage: woodpecker-include <port>");
|
||||
return;
|
||||
}
|
||||
HTTPServer server = new HTTPServer(Integer.parseInt(args[0]));
|
||||
|
@ -34,6 +37,7 @@ public class Main {
|
|||
try (OutputStreamWriter writer = new OutputStreamWriter(resp.getBody())) {
|
||||
Serializer.getInstance().serialize(response, writer);
|
||||
}
|
||||
LOG.info("Processed includes for pipeline for " + request.repo.namespace + "/" + request.repo.name);
|
||||
return 0;
|
||||
} else return 204;
|
||||
} catch (UncheckedIOException e) {
|
||||
|
@ -41,6 +45,6 @@ public class Main {
|
|||
}
|
||||
}, "POST");
|
||||
server.start();
|
||||
System.out.println("Running Woodpecker-Include");
|
||||
LOG.info("Running Woodpecker-Include");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,4 +5,17 @@ import com.amihaiemil.eoyaml.YamlMapping;
|
|||
public class Pipeline {
|
||||
public String name;
|
||||
public YamlMapping data;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{\"name\":\"" + escape(name) + ",\"data\":\"" + escape(data.toString()) + '}';
|
||||
}
|
||||
|
||||
private static String escape(String text) {
|
||||
return text
|
||||
.replace("\\", "\\\\")
|
||||
.replace("\"", "\\\"")
|
||||
.replace("\r", "\\r")
|
||||
.replace("\n", "\\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,4 +11,17 @@ public class ResponseModel {
|
|||
public ResponseModel(List<Pipeline> configs) {
|
||||
this.configs = List.copyOf(configs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("{\"configs\":[");
|
||||
boolean first = false;
|
||||
for (Pipeline config : configs) {
|
||||
if (!first) sb.append(',');
|
||||
first = true;
|
||||
sb.append(config.toString());
|
||||
}
|
||||
sb.append("]}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue