Added API-Types crate as discussed here. It uses common structs which are used by apiclient and apiserver. The main intention was to remove the models crate from its dependencies.
Updated the apiclient side errors to match what was there before #3987
Note: A deserialization error that was there previously when running the apply subcommand does not exist anymore. The server side returns a Deserialization error which is a bit different (it is return from actix::json). The approach of changing the error to suit what we had before seemed too complex given we dont do any client side deserialization during apply. I did not see any places where apply was used, so the risk of not having it is limited.
Now:
bash-5.2# apiclient apply <<EOF
> [settings]
> asdfasdf = "foo"
> EOF
Failed to apply settings: Json deserialize error: unknown field `asdfasdf`, expected one of `aws`, `boot`, `bootstrap-containers`, `cloudformation`, `container-registry`, `dns`, `host-containers`, `kernel`, `metrics`, `motd`, `network`, `ntp`, `oci-hooks`, `pki`, `updates` at line 1 column 11
Bfore:
bash-5.1# apiclient apply <<EOF
> [settings]
> asdfasdf = "foo"
> EOF
Failed to apply settings: Failed to deserialize settings from '-' into this variant's model: unknown field `asdfasdf`, expected one of `motd`, `kubernetes`, `updates`, `host-containers`, `bootstrap-containers`, `ntp`, `network`, `kernel`, `boot`, `aws`, `metrics`, `pki`, `container-registry`, `oci-defaults`, `oci-hooks`, `cloudformation`, `dns`, `container-runtime`, `autoscaling`
Testing done:
[x] Built an AMI (aws-ecs-1)
[x] Spun an instance & able to set & apply fine. Reboot works fine.
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.
Issue number:
Closes #3949
Description of changes:
models
crate from its dependencies.Note: A deserialization error that was there previously when running the
apply
subcommand does not exist anymore. The server side returns a Deserialization error which is a bit different (it is return from actix::json). The approach of changing the error to suit what we had before seemed too complex given we dont do any client side deserialization during apply. I did not see any places whereapply
was used, so the risk of not having it is limited.Now:
Bfore:
Testing done:
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.