Skip to content

Commit 6bfbe15

Browse files
Support Args field in Checks for Consul > 1.0
1 parent 942215c commit 6bfbe15

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/main/java/com/ecwid/consul/v1/agent/model/NewService.java

+31
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.google.gson.annotations.SerializedName;
44

5+
import java.util.Arrays;
56
import java.util.List;
67
import java.util.Map;
78

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

1415
public static class Check {
1516

17+
/**
18+
* Should only be used for Consul after 1.0
19+
* For newer versions, {@link #args} should be used instead of script
20+
*/
21+
@Deprecated
1622
@SerializedName("Script")
1723
private String script;
1824

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

31+
/**
32+
* Should be used for consul before 1.0
33+
*/
34+
@SerializedName("Args")
35+
private String[] args;
36+
2537
@SerializedName("Interval")
2638
private String interval;
2739

@@ -52,10 +64,20 @@ public static class Check {
5264
@SerializedName("Status")
5365
private String status;
5466

67+
/**
68+
* Should only be used for Consul < 1.0
69+
* For newer versions, {@link #getArgs()} should be used instead of script
70+
*/
71+
@Deprecated
5572
public String getScript() {
5673
return script;
5774
}
5875

76+
/**
77+
* Should only be used for Consul < 1.0
78+
* For newer versions, {@link #setArgs(String)} should be used instead of script
79+
*/
80+
@Deprecated
5981
public void setScript(String script) {
6082
this.script = script;
6183
}
@@ -76,6 +98,14 @@ public void setShell(String shell) {
7698
this.shell = shell;
7799
}
78100

101+
public String[] getArgs() {
102+
return args;
103+
}
104+
105+
public void setArgs(String script) {
106+
this.args = script.split(" ");
107+
}
108+
79109
public String getInterval() {
80110
return interval;
81111
}
@@ -160,6 +190,7 @@ public void setStatus(String status) {
160190
public String toString() {
161191
return "Check{" +
162192
"script='" + script + '\'' +
193+
", args='" + Arrays.deepToString(args) + '\'' +
163194
", interval='" + interval + '\'' +
164195
", ttl='" + ttl + '\'' +
165196
", http='" + http + '\'' +

0 commit comments

Comments
 (0)