Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add api types crate & update apiclient errors #4040

Closed

Conversation

sumukhballal
Copy link
Contributor

@sumukhballal sumukhballal commented Jun 7, 2024

Issue number:

Closes #3949

Description of changes:

  1. 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.
  2. Updated the apiclient side errors to match what was there before Remove APIClient dependency on the Settings model #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:

  • Built an AMI (aws-ecs-1)
  • 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.

sources/api/api-types/Cargo.toml Outdated Show resolved Hide resolved
sources/api/apiclient/test.json Outdated Show resolved Hide resolved
sources/api/api-types/src/exec.rs Outdated Show resolved Hide resolved
sources/api/apiclient/src/lib.rs Show resolved Hide resolved
sources/api/apiclient/src/main.rs Outdated Show resolved Hide resolved
sources/api/apiclient/src/set.rs Outdated Show resolved Hide resolved
@sumukhballal
Copy link
Contributor Author

Added changes to take care of feedback.

@sumukhballal sumukhballal marked this pull request as ready for review June 19, 2024 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ootb: apiclient needs to be model agnostic
3 participants