Allow for a separate API model per variant #588
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull #578 added support for build variants to support different features and
use cases, starting with aws-k8s and aws-dev. These variants use different
software, and therefore need different configuration. This change allows for
having a different API model (and default values) per variant.
The model was moved to workspaces/models. This crate actually contains the
model for each variant in separate subdirectories. Cargo's
build.rs
is usedto symlink in the proper source code before build.
The "proper" source code is chosen using the VARIANT environment variable. The
build system passes this through using the value of BUILDSYS_VARIANT, which is
set in the top-level Makefile.toml and can be overridden on the command-line.
For local cargo builds, the developer must set the VARIANT environment
variable; we don't currently want to choose a default model.
To start out, the aws-k8s and aws-dev models (and related default values) are
copies, with aws-dev having the Kubernetes-related values removed. The next
step is to figure out an appropriate method for sharing structure; until then,
we'll need to duplicate most changes.
Implementation notes:
SettingsResponse
structure, and update the related methods in apiserver, because it no longer owns theSettings
structure and so can't define traits on it. No change in behavior.Testing done:
All unit tests in
workspaces/
pass (for both aws-k8s and aws-dev variants).First, I built with the default
BUILDSYS_VARIANT
, resulting in an aws-k8s build, and launched it as an AMI.systemctl status
showedrunning
, it joined my Kubernetes cluster, and I launched a pod OK.Then I changed
BUILDSYS_VARIANT=aws-dev
, built, and launched it as an AMI.systemctl status
showedrunning
. I saw that I had the aws-dev variant's tooling, like ps, and no kubelet. I was able todocker run busybox
and see it download the image. It won't actually run yet, because we need to change the models so that containerd configuration is written out; it's currently undersettings.kubernetes
even though it's not k8s-specific. That will be a separate PR.