-
Notifications
You must be signed in to change notification settings - Fork 524
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 conditional compilation to early-boot-config #1288
Conversation
⏫ Fix the conflicts with the base branch |
The above force push should address outstanding comments. The tl;dr is: "removed any odd conditional compilation in error handling." After multiple offline conversations I think there's a much better solution in place for error handling here. The @tjkirch brought up the valid point that we should probably separate "platform" from "data provider", and let the platform (AWS, VMWare, etc) choose the provider (local file, IMDS, etc.). I'll open an issue separately; it shouldn't block this PR. |
^ Address @etungsten 's comment |
Yes, I agree that is fine. The wrapper that I wrote basically amounts to implementing |
// Build a list of user data files that exist | ||
let mut user_data_files = Self::USER_DATA_FILENAMES | ||
.iter() | ||
.map(|filename| Path::new(Self::CD_ROM_MOUNT).join(filename)) | ||
.filter(|file| file.exists()); | ||
|
||
// If no files exist, return | ||
let user_data_file = match user_data_files.next() { | ||
Some(file) => file, | ||
None => return Ok(None), | ||
}; | ||
|
||
// There should only be 1 file, if more exist something is wonky | ||
ensure!( | ||
user_data_files.next().is_none(), | ||
error::UserDataFileCount { | ||
location: Self::CD_ROM_MOUNT | ||
} | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: for me, all three of these comments are about "what" which is pretty obvious. A "why" comment could be helpful for building a list of the files, since it's not obvious why there wouldn't be a canonical file name.
This change adds a simple solution for conditionally compiling early-boot-config based on the current variant. As part of the change, local file handling (which was previously broken) is split into its own trait implementation and only compiled into the program for "aws-dev" variants. We also add the ability to read a mounted cdrom for user data.
^ Addressed @bcressey 's comments |
Issue number:
Related to #1218
Description of changes:
This change adds a simple solution for conditionally compiling
early-boot-config based on the current variant. As part of the change,
local file handling (which was previously broken) is split into its own
trait implementation and only compiled into the program for "aws-dev"
variants. We also add the ability to read a mounted cdrom for user
data.
Most of the code in
main.rs
has been moved to modules, but the logic is still very largely the same.A separate PR will contain the relevant mount units to correctly mount a CD-ROM.
Testing done:
aws-dev
) locally to test the cd-rom user data capability. Bothxml
anduser-data
files worked as expected.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.