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

Implement image spec #25

Merged
merged 9 commits into from Aug 20, 2021
Merged

Implement image spec #25

merged 9 commits into from Aug 20, 2021

Conversation

Furisto
Copy link
Member

@Furisto Furisto commented Aug 19, 2021

Solves #10. Another PR with additional tests will follow.

@codecov-commenter
Copy link

Codecov Report

Merging #25 (8cf7e46) into main (1b42768) will decrease coverage by 0.84%.
The diff coverage is 16.56%.

@@            Coverage Diff             @@
##             main      #25      +/-   ##
==========================================
- Coverage   20.31%   19.46%   -0.85%     
==========================================
  Files           7       11       +4     
  Lines         699      863     +164     
  Branches      371      463      +92     
==========================================
+ Hits          142      168      +26     
- Misses        274      354      +80     
- Partials      283      341      +58     

Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, I just have a few nits.

Comment on lines 4 to 5
use serde::ser::SerializeMap;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, unfortunately merge_imports is still an unstable feature of rustfmt:

Suggested change
use serde::ser::SerializeMap;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde::{Deserialize, Deserializer, Serialize, Serializer, ser::SerializeMap};

);

impl ImageConfiguration {
pub fn load<P: AsRef<Path>>(path: P) -> Result<ImageConfiguration> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a doc comment.

/// a filesystem diff. It is set to true if this history item
/// doesn't correspond to an actual layer in the rootfs section
#[serde(skip_serializing_if = "Option::is_none")]
empty_layer: Option<bool>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
empty_layer: Option<bool>,
#[cfg_attr(feature = "builder", getset(get_copy = "pub"))]
empty_layer: Option<bool>,

feature = "builder",
derive(derive_builder::Builder, getset::Getters),
builder(default, pattern = "owned", setter(into, strip_option)),
getset(get = "pub")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getset(get = "pub")

#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[cfg_attr(
feature = "builder",
derive(derive_builder::Builder, getset::Getters),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
derive(derive_builder::Builder, getset::Getters),
derive(derive_builder::Builder, getset::CopyGetters, getset::Getters),

feature = "builder",
derive(derive_builder::Builder, getset::Getters),
builder(default, pattern = "owned", setter(into, strip_option)),
getset(get = "pub")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this

Suggested change
getset(get = "pub")

feature = "builder",
derive(derive_builder::Builder, getset::Getters),
builder(pattern = "owned", setter(into, strip_option)),
getset(get = "pub")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getset(get = "pub")

#[serde(rename_all = "camelCase")]
#[cfg_attr(
feature = "builder",
derive(derive_builder::Builder, getset::Getters),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
derive(derive_builder::Builder, getset::Getters),
derive(derive_builder::Builder, getset::CopyGetters, getset::Getters),

#[serde(rename_all = "camelCase")]
#[cfg_attr(
feature = "builder",
derive(derive_builder::Builder, getset::Getters),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
derive(derive_builder::Builder, getset::Getters),
derive(derive_builder::Builder, getset::CopyGetters, getset::Getters),

@@ -0,0 +1,52 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about putting those files into the official test directory, like: test/data?

@Furisto
Copy link
Member Author

Furisto commented Aug 20, 2021

@saschagrunert PTAL
I included your suggestions and also formatted the comments to have a uniform width of 80 characters.
Does intellisense work with the generated getters for you? I tried enabling the required feature in the settings of rust-analyzer and even created a second project and added this crate as a dependency but it does not get picked up. Cargo expand confirms that everything has been generated as expected and I can use them and it compiles fine, but it does not show up in intellisense. This happens for both runtime and image.

@saschagrunert saschagrunert merged commit a3a9eb1 into containers:main Aug 20, 2021
@saschagrunert
Copy link
Member

Thanks! Rustfmt allows 100chars but having 80 does not hurt. I’m using vim with YouCompleteMe and the rust analyzer. This works pretty well from my experience, unfortunately I don’t know how it behaves with intellisense.

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.

None yet

3 participants