Skip to content

Commit

Permalink
nacos changelog context
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce.wu committed Sep 12, 2024
1 parent ea00e77 commit f8616f4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ protected Map<String, Object> run() throws Exception {
step.getToolUrl(), step.getDatabaseId(), step.getCommand(), step.getArgs()));

logger.log("Liquibase run command return code: %s", resp.getRetcode());
if (StringUtils.isNotBlank(resp.getStdout())) {
logger.log("Liquibase run command stdout:\n%s", resp.getStdout());
}
if (StringUtils.isNotBlank(resp.getStderr())) {
logger.log("Liquibase run command stderr:\n%s", resp.getStderr());
}
if (StringUtils.isNotBlank(resp.getStdout())) {
logger.log("Liquibase run command stdout:\n%s", resp.getStdout());
}
if (!resp.isSuccess()) {
throw new ConfigOpsException("Execute liquibase run command unsuccessful");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ protected Map<String, Object> run() throws Exception {
changelogRootPath.act(new RemoteExecutionCallable(step.getToolUrl(), step.getDatabaseId()));

logger.log("Liquibase update return code: %s", resp.getRetcode());
if (StringUtils.isNotBlank(resp.getStdout())) {
logger.log("Liquibase update stdout:\n%s", resp.getStdout());
}
if (StringUtils.isNotBlank(resp.getStderr())) {
logger.log("Liquibase update stderr:\n%s", resp.getStderr());
}
if (StringUtils.isNotBlank(resp.getStdout())) {
logger.log("Liquibase update stdout:\n%s", resp.getStdout());
}
if (!resp.isSuccess()) {
throw new ConfigOpsException("Execute liquibase update unsuccessful");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ public class NacosGetChangeSetReq implements Serializable {
private String changeLogFile;

private Integer count;

private String contexts;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class NacosChangeSetGetStep extends Step implements Serializable {

private Integer count;

private String contexts;

@DataBoundConstructor
public NacosChangeSetGetStep(String nacosId, String toolUrl, String changeLogFile) {
this.nacosId = nacosId;
Expand All @@ -59,6 +61,11 @@ public void setCount(Integer count) {
this.count = count;
}

@DataBoundSetter
public void setContexts(String contexts) {
this.contexts = contexts;
}

@Override
public StepExecution start(StepContext context) throws Exception {
return new StepExecutionImpl(context, this);
Expand Down Expand Up @@ -87,8 +94,8 @@ protected NacosGetChangeSetResp run() throws Exception {
if (!changeLog.exists()) {
throw new IllegalArgumentException("Change log file not found");
}
NacosGetChangeSetResp resp =
changeLog.act(new RemoteCallable(step.getToolUrl(), step.getNacosId(), step.getCount()));
NacosGetChangeSetResp resp = changeLog.act(
new RemoteCallable(step.getToolUrl(), step.getNacosId(), step.getCount(), step.getContexts()));
logger.log("Get ChangeSet from file: %s", step.getChangeLogFile());
if (CollectionUtils.isNotEmpty(resp.getChanges())) {
for (NacosConfigDTO nc : resp.getChanges()) {
Expand All @@ -107,13 +114,14 @@ private static class RemoteCallable extends MasterToSlaveFileCallable<NacosGetCh
private static final long serialVersionUID = -5550176413772105947L;
private final String toolUrl;
private final String nacosId;

private final Integer count;
private final String contexts;

private RemoteCallable(String toolUrl, String nacosId, Integer count) {
private RemoteCallable(String toolUrl, String nacosId, Integer count, String contexts) {
this.toolUrl = toolUrl;
this.nacosId = nacosId;
this.count = count;
this.contexts = contexts;
}

@Override
Expand All @@ -122,6 +130,7 @@ public NacosGetChangeSetResp invoke(File f, VirtualChannel channel) throws IOExc
NacosGetChangeSetReq nacosGetChangeSetReq = new NacosGetChangeSetReq()
.setNacosId(nacosId)
.setChangeLogFile(f.getAbsolutePath())
.setContexts(contexts)
.setCount(count);
return client.getChangeSet(nacosGetChangeSetReq);
}
Expand Down

0 comments on commit f8616f4

Please sign in to comment.