forked from containers/bootc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
381 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
//! The definition for host system state. | ||
|
||
use kube::CustomResource; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
fn default_transport() -> String { | ||
"registry".into() | ||
} | ||
|
||
/// Representation of a bootc host system | ||
#[derive( | ||
CustomResource, Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone, JsonSchema, | ||
)] | ||
#[kube( | ||
group = "org.containers.bootc", | ||
version = "v1alpha1", | ||
kind = "BootcHost", | ||
struct = "Host", | ||
namespaced, | ||
status = "HostStatus", | ||
derive = "PartialEq", | ||
derive = "Default" | ||
)] | ||
pub struct HostDef {} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema)] | ||
/// An image signature | ||
pub enum ImageSignature { | ||
/// Fetches will use the named ostree remote for signature verification of the ostree commit. | ||
OstreeRemote(String), | ||
/// Fetches will defer to the `containers-policy.json`, but we make a best effort to reject `default: insecureAcceptAnything` policy. | ||
ContainerPolicy, | ||
/// No signature verification will be performed | ||
Insecure, | ||
} | ||
|
||
/// A container image reference with attached transport and signature verification | ||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema)] | ||
pub struct ImageReference { | ||
/// The container image reference | ||
pub image: String, | ||
/// The container image transport | ||
#[serde(default = "default_transport")] | ||
pub transport: String, | ||
/// Disable signature verification | ||
pub signature: ImageSignature, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema)] | ||
/// Specification for host system | ||
pub struct HostSpec { | ||
/// The host image | ||
pub image: ImageReference, | ||
// TODO enable this | ||
// pub retain_rollback: bool, | ||
} | ||
|
||
/// The status of the booted image | ||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema)] | ||
pub struct ImageStatus { | ||
/// The currently booted image | ||
pub image: ImageReference, | ||
/// The digest of the fetched image (e.g. sha256:a0...); | ||
pub image_digest: String, | ||
} | ||
|
||
/// A bootable entry | ||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema)] | ||
pub struct BootEntryOstree { | ||
/// The ostree commit checksum | ||
pub checksum: String, | ||
pub deploy_serial: u32, | ||
} | ||
|
||
/// A bootable entry | ||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema)] | ||
pub struct BootEntry { | ||
/// The image reference | ||
pub image: Option<ImageStatus>, | ||
/// Whether this boot entry supports changes via bootc | ||
pub compatible: bool, | ||
/// Whether this entry will be subject to garbage collection | ||
pub pinned: bool, | ||
/// If this boot entry is ostree based, the corresponding state | ||
pub ostree: Option<BootEntryOstree>, | ||
} | ||
|
||
/// The status of the host system | ||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema)] | ||
pub struct HostStatus { | ||
/// The staged image for the next boot | ||
pub staged: Option<BootEntry>, | ||
/// The booted image; this will be unset if the host is not bootc compatible. | ||
pub booted: Option<BootEntry>, | ||
/// The previously booted image | ||
pub rollback: Option<BootEntry>, | ||
|
||
/// Whether or not the current system state is an ostree-based container | ||
pub is_container: bool, | ||
} |
Oops, something went wrong.