command/agent: add Canonicalize option to parse args

This commit is contained in:
Nick Ethier 2018-04-12 14:46:15 -04:00
parent 31da01856a
commit de4176606d
No known key found for this signature in database
GPG Key ID: 07C1A3ECED90D24A
2 changed files with 8 additions and 0 deletions

View File

@ -36,8 +36,13 @@ type Jobs struct {
client *Client
}
// JobsParseRequest is used for arguments of the /vi/jobs/parse endpoint
type JobsParseRequest struct {
//JobHCL is an hcl jobspec
JobHCL string
//Canonicalize is a flag as to if the server should return default values
//for unset fields
Canonicalize bool
}
// Jobs returns a handle on the jobs endpoints.

View File

@ -565,6 +565,9 @@ func (s *HTTPServer) JobsParseRequest(resp http.ResponseWriter, req *http.Reques
return nil, CodedError(400, err.Error())
}
if args.Canonicalize {
jobStruct.Canonicalize()
}
return jobStruct, nil
}