mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
structs: fix compatibility between api and nomad/structs proxy definitions
The field names within the structs representing the Connect proxy definition were not the same (nomad/structs/ vs api/), causing the values to be lost in translation for the 'nomad job inspect' command. Since the field names already shipped in v0.11.0 we cannot simply fix the names. Instead, use the json struct tag on the structs/ structs to remap the name to match the publicly expose api/ package on json encoding. This means existing jobs from v0.11.0 will continue to work, and the JSON API for job submission will remain backwards compatible.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
* [ ] Add structs/fields to `nomad/structs` package
|
||||
* Validation happens in this package and must be implemented
|
||||
* Implement other methods and tests from `api/` package
|
||||
* Note that analogous struct field names should match with `api/` package
|
||||
* [ ] Add conversion between `api/` and `nomad/structs` in `command/agent/job_endpoint.go`
|
||||
* [ ] Add check for job diff in `nomad/structs/diff.go`
|
||||
* Note that fields must be listed in alphabetical order in `FieldDiff` slices in `nomad/structs/diff_test.go`
|
||||
|
||||
@@ -889,7 +889,9 @@ type ConsulProxy struct {
|
||||
|
||||
// Expose configures the consul proxy.expose stanza to "open up" endpoints
|
||||
// used by task-group level service checks using HTTP or gRPC protocols.
|
||||
Expose *ConsulExposeConfig
|
||||
//
|
||||
// Use json tag to match with field name in api/
|
||||
Expose *ConsulExposeConfig `json:"ExposeConfig"`
|
||||
|
||||
// Config is a proxy configuration. It is opaque to Nomad and passed
|
||||
// directly to Consul.
|
||||
@@ -905,7 +907,7 @@ func (p *ConsulProxy) Copy() *ConsulProxy {
|
||||
newP := &ConsulProxy{
|
||||
LocalServiceAddress: p.LocalServiceAddress,
|
||||
LocalServicePort: p.LocalServicePort,
|
||||
Expose: p.Expose,
|
||||
Expose: p.Expose.Copy(),
|
||||
}
|
||||
|
||||
if n := len(p.Upstreams); n > 0 {
|
||||
@@ -1009,7 +1011,8 @@ func (u *ConsulUpstream) Equals(o *ConsulUpstream) bool {
|
||||
|
||||
// ExposeConfig represents a Consul Connect expose jobspec stanza.
|
||||
type ConsulExposeConfig struct {
|
||||
Paths []ConsulExposePath
|
||||
// Use json tag to match with field name in api/
|
||||
Paths []ConsulExposePath `json:"Path"`
|
||||
}
|
||||
|
||||
type ConsulExposePath struct {
|
||||
|
||||
Reference in New Issue
Block a user