Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Args field in Checks for Consul > 1.0 #172

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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