Skip to content
Merged
Show file tree
Hide file tree
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
29 changes: 29 additions & 0 deletions cmd/command_Post.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,35 @@ func commandRunPost(cmd *cobra.Command, command SchemaCommand) {
}
commandRunSsh(cmd, command, body, publicKey)
os.Exit(exitCodeUnexpected)
} else if command.Run.SimpleJsonServerResponse {
if format == "json" {
fmt.Println(string(body))
os.Exit(0)
} else {
var response map[string]string
if err := json.Unmarshal(body, &response); err != nil {
fmt.Println(string(body))
fmt.Println("Failed to parse server response")
os.Exit(exitCodeInvalidResponse)
} else if format == "yaml" {
var d []byte
d, err = yaml.Marshal(&response)
if err != nil {
fmt.Println(string(body))
fmt.Println("Invalid response from server")
os.Exit(exitCodeInvalidResponse)
} else {
fmt.Println(string(d))
os.Exit(0)
}
} else {
message, hasMessage := response["message"]
if hasMessage {
fmt.Println(message)
os.Exit(0)
}
}
}
} else {
var commandIds []string;
if err := json.Unmarshal(body, &commandIds); err != nil {
Expand Down
7 changes: 7 additions & 0 deletions cmd/command_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type SchemaCommandRun struct {
Lists []SchemaCommandList `json:"lists"`
ServerMethod string `json:"serverMethod"`
ParseStatisticsResponse bool `json:"ParseStatisticsResponse"`
SimpleJsonServerResponse bool `json:"SimpleJsonServerResponse"`
}

type SchemaCommandCliPreRunHook struct {
Expand Down Expand Up @@ -104,7 +105,13 @@ type Schema struct {
SchemaGeneratedAt time.Time `json:"schema_generated_at"`
}

func getSupportsParam() string {
// comma-separated list of cloudcli-server functionality this cli version supports
return "SimpleJsonServerResponse"
}

func downloadSchema(schemaFile string, schemaUrl string) Schema {
schemaUrl = fmt.Sprintf("%s?supports=%s", schemaUrl, getSupportsParam())
var schema_ Schema
if dryrun || debug {
if debug {
Expand Down