open-nomad/jobspec/test-fixtures
Derek Strickland 80b6f27efd
api: remove mapstructure tags fromPort struct (#12916)
This PR solves a defect in the deserialization of api.Port structs when returning structs from theEventStream.

Previously, the api.Port struct's fields were decorated with both mapstructure and hcl tags to support the network.port stanza's use of the keyword static when posting a static port value. This works fine when posting a job and when retrieving any struct that has an embedded api.Port instance as long as the value is deserialized using JSON decoding. The EventStream, however, uses mapstructure to decode event payloads in the api package. mapstructure expects an underlying field named static which does not exist. The result was that the Port.Value field would always be set to 0.

Upon further inspection, a few things became apparent.

The struct already has hcl tags that support the indirection during job submission.
Serialization/deserialization with both the json and hcl packages produce the desired result.
The use of of the mapstructure tags provided no value as the Port struct contains only fields with primitive types.
This PR:

Removes the mapstructure tags from the api.Port structs
Updates the job parsing logic to use hcl instead of mapstructure when decoding Port instances.
Closes #11044

Co-authored-by: DerekStrickland <dstrickland@hashicorp.com>
Co-authored-by: Piotr Kazmierczak <470696+pkazmierczak@users.noreply.github.com>
2022-11-08 11:26:28 +01:00
..
artifacts.hcl
bad-artifact.hcl
bad-ports.hcl
basic.hcl
basic_wrong_key.hcl
consul-namespace.hcl
csi-plugin.hcl
default-job.hcl
distinctHosts-constraint.hcl
distinctProperty-constraint.hcl
incorrect-service-def.hcl
job-with-kill-signal.hcl
migrate-job.hcl
multi-network.hcl
multi-resource.hcl
multi-vault.hcl
multiregion.hcl
overlapping-ports.hcl
parameterized_job.hcl
parse-ports.hcl
periodic-cron.hcl
regexp-constraint.hcl
reschedule-job-unlimited.hcl
reschedule-job.hcl
resources-cores.hcl
service-check-bad-header-2.hcl
service-check-bad-header.hcl
service-check-driver-address.hcl
service-check-initial-status.hcl
service-check-pass-fail.hcl
service-check-restart.hcl
service-enable-tag-override.hcl
service-meta.hcl
service-provider.hcl
service-tagged-address.hcl
set-contains-constraint.hcl
specify-job.hcl
task-nested-config.hcl
task-scaling-policy-invalid-resource.hcl
task-scaling-policy-invalid-type.hcl
task-scaling-policy-missing-name.hcl
task-scaling-policy-multi-cpu.hcl
task-scaling-policy-multi-name.hcl
task-scaling-policy.hcl
tg-network-with-hostname.hcl
tg-network.hcl
tg-scaling-policy-invalid-type.hcl
tg-scaling-policy-minimal.hcl
tg-scaling-policy-missing-max.hcl
tg-scaling-policy-multi-policy.hcl
tg-scaling-policy-with-label.hcl
tg-scaling-policy.hcl
tg-service-check-expose.hcl
tg-service-check.hcl
tg-service-connect-gateway-ingress.hcl
tg-service-connect-gateway-mesh.hcl
tg-service-connect-gateway-terminating.hcl
tg-service-connect-local-service.hcl
tg-service-connect-native.hcl
tg-service-connect-proxy.hcl
tg-service-connect-resources.hcl
tg-service-connect-sidecar_disablecheck.hcl
tg-service-connect-sidecar_task-name.hcl
tg-service-enable-tag-override.hcl
tg-service-proxy-expose.hcl
vault_inheritance.hcl
version-constraint.hcl