Skip to content

Commit

Permalink
Support Args field in Checks for Consul > 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandrserbin committed Nov 12, 2018
1 parent 942215c commit 1382aee
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/main/java/com/ecwid/consul/v1/agent/model/NewService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.gson.annotations.SerializedName;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

Expand All @@ -13,6 +14,11 @@ public class NewService {

public static class Check {

/**
* Should only be used for Consul after 1.0
* For newer versions, {@link #args} should be used instead of script
*/
@Deprecated
@SerializedName("Script")
private String script;

Expand All @@ -22,6 +28,12 @@ public static class Check {
@SerializedName("Shell")
private String shell;

/**
* Should be used for consul before 1.0
*/
@SerializedName("Args")
private String[] args;

@SerializedName("Interval")
private String interval;

Expand Down Expand Up @@ -52,10 +64,20 @@ public static class Check {
@SerializedName("Status")
private String status;

/**
* Should only be used for Consul before 1.0
* For newer versions, {@link #getArgs()} should be used instead of script
*/
@Deprecated
public String getScript() {
return script;
}

/**
* Should only be used for Consul after 1.0
* For newer versions, {@link #setArgs(String)} should be used instead of script
*/
@Deprecated
public void setScript(String script) {
this.script = script;
}
Expand All @@ -76,6 +98,14 @@ public void setShell(String shell) {
this.shell = shell;
}

public String[] getArgs() {
return args;
}

public void setArgs(String script) {
this.args = script.split(" ");
}

public String getInterval() {
return interval;
}
Expand Down Expand Up @@ -160,6 +190,7 @@ public void setStatus(String status) {
public String toString() {
return "Check{" +
"script='" + script + '\'' +
", args='" + Arrays.deepToString(args) + '\'' +
", interval='" + interval + '\'' +
", ttl='" + ttl + '\'' +
", http='" + http + '\'' +
Expand Down

0 comments on commit 1382aee

Please sign in to comment.