mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
only validate mounts for inject if eos >=0.3.1.1 (#1686)
only validate mounts for inject if `>=0.3.1.1`
This commit is contained in:
@@ -57,9 +57,14 @@ pub struct Action {
|
|||||||
}
|
}
|
||||||
impl Action {
|
impl Action {
|
||||||
#[instrument]
|
#[instrument]
|
||||||
pub fn validate(&self, volumes: &Volumes, image_ids: &BTreeSet<ImageId>) -> Result<(), Error> {
|
pub fn validate(
|
||||||
|
&self,
|
||||||
|
eos_version: &Version,
|
||||||
|
volumes: &Volumes,
|
||||||
|
image_ids: &BTreeSet<ImageId>,
|
||||||
|
) -> Result<(), Error> {
|
||||||
self.implementation
|
self.implementation
|
||||||
.validate(volumes, image_ids, true)
|
.validate(eos_version, volumes, image_ids, true)
|
||||||
.with_ctx(|_| {
|
.with_ctx(|_| {
|
||||||
(
|
(
|
||||||
crate::ErrorKind::ValidateS9pk,
|
crate::ErrorKind::ValidateS9pk,
|
||||||
|
|||||||
@@ -69,12 +69,17 @@ pub struct BackupActions {
|
|||||||
pub restore: PackageProcedure,
|
pub restore: PackageProcedure,
|
||||||
}
|
}
|
||||||
impl BackupActions {
|
impl BackupActions {
|
||||||
pub fn validate(&self, volumes: &Volumes, image_ids: &BTreeSet<ImageId>) -> Result<(), Error> {
|
pub fn validate(
|
||||||
|
&self,
|
||||||
|
eos_version: &Version,
|
||||||
|
volumes: &Volumes,
|
||||||
|
image_ids: &BTreeSet<ImageId>,
|
||||||
|
) -> Result<(), Error> {
|
||||||
self.create
|
self.create
|
||||||
.validate(volumes, image_ids, false)
|
.validate(eos_version, volumes, image_ids, false)
|
||||||
.with_ctx(|_| (crate::ErrorKind::ValidateS9pk, "Backup Create"))?;
|
.with_ctx(|_| (crate::ErrorKind::ValidateS9pk, "Backup Create"))?;
|
||||||
self.restore
|
self.restore
|
||||||
.validate(volumes, image_ids, false)
|
.validate(eos_version, volumes, image_ids, false)
|
||||||
.with_ctx(|_| (crate::ErrorKind::ValidateS9pk, "Backup Restore"))?;
|
.with_ctx(|_| (crate::ErrorKind::ValidateS9pk, "Backup Restore"))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,12 +31,17 @@ pub struct ConfigActions {
|
|||||||
}
|
}
|
||||||
impl ConfigActions {
|
impl ConfigActions {
|
||||||
#[instrument]
|
#[instrument]
|
||||||
pub fn validate(&self, volumes: &Volumes, image_ids: &BTreeSet<ImageId>) -> Result<(), Error> {
|
pub fn validate(
|
||||||
|
&self,
|
||||||
|
eos_version: &Version,
|
||||||
|
volumes: &Volumes,
|
||||||
|
image_ids: &BTreeSet<ImageId>,
|
||||||
|
) -> Result<(), Error> {
|
||||||
self.get
|
self.get
|
||||||
.validate(volumes, image_ids, true)
|
.validate(eos_version, volumes, image_ids, true)
|
||||||
.with_ctx(|_| (crate::ErrorKind::ValidateS9pk, "Config Get"))?;
|
.with_ctx(|_| (crate::ErrorKind::ValidateS9pk, "Config Get"))?;
|
||||||
self.set
|
self.set
|
||||||
.validate(volumes, image_ids, true)
|
.validate(eos_version, volumes, image_ids, true)
|
||||||
.with_ctx(|_| (crate::ErrorKind::ValidateS9pk, "Config Set"))?;
|
.with_ctx(|_| (crate::ErrorKind::ValidateS9pk, "Config Set"))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ use crate::shutdown::Shutdown;
|
|||||||
use crate::status::{MainStatus, Status};
|
use crate::status::{MainStatus, Status};
|
||||||
use crate::util::io::from_yaml_async_reader;
|
use crate::util::io::from_yaml_async_reader;
|
||||||
use crate::util::{AsyncFileExt, Invoke};
|
use crate::util::{AsyncFileExt, Invoke};
|
||||||
use crate::{volume, Error, ErrorKind, ResultExt};
|
use crate::{Error, ErrorKind, ResultExt};
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize)]
|
#[derive(Debug, Default, Deserialize)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ use tokio::process::Command;
|
|||||||
use crate::context::rpc::RpcContextConfig;
|
use crate::context::rpc::RpcContextConfig;
|
||||||
use crate::db::model::ServerStatus;
|
use crate::db::model::ServerStatus;
|
||||||
use crate::install::PKG_DOCKER_DIR;
|
use crate::install::PKG_DOCKER_DIR;
|
||||||
use crate::sound::SHUTDOWN;
|
|
||||||
use crate::util::Invoke;
|
use crate::util::Invoke;
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
|
||||||
|
|||||||
@@ -25,22 +25,31 @@ pub struct Migrations {
|
|||||||
}
|
}
|
||||||
impl Migrations {
|
impl Migrations {
|
||||||
#[instrument]
|
#[instrument]
|
||||||
pub fn validate(&self, volumes: &Volumes, image_ids: &BTreeSet<ImageId>) -> Result<(), Error> {
|
pub fn validate(
|
||||||
|
&self,
|
||||||
|
eos_version: &Version,
|
||||||
|
volumes: &Volumes,
|
||||||
|
image_ids: &BTreeSet<ImageId>,
|
||||||
|
) -> Result<(), Error> {
|
||||||
for (version, migration) in &self.from {
|
for (version, migration) in &self.from {
|
||||||
migration.validate(volumes, image_ids, true).with_ctx(|_| {
|
migration
|
||||||
(
|
.validate(eos_version, volumes, image_ids, true)
|
||||||
crate::ErrorKind::ValidateS9pk,
|
.with_ctx(|_| {
|
||||||
format!("Migration from {}", version),
|
(
|
||||||
)
|
crate::ErrorKind::ValidateS9pk,
|
||||||
})?;
|
format!("Migration from {}", version),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
for (version, migration) in &self.to {
|
for (version, migration) in &self.to {
|
||||||
migration.validate(volumes, image_ids, true).with_ctx(|_| {
|
migration
|
||||||
(
|
.validate(eos_version, volumes, image_ids, true)
|
||||||
crate::ErrorKind::ValidateS9pk,
|
.with_ctx(|_| {
|
||||||
format!("Migration to {}", version),
|
(
|
||||||
)
|
crate::ErrorKind::ValidateS9pk,
|
||||||
})?;
|
format!("Migration to {}", version),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ pub struct DockerProcedure {
|
|||||||
impl DockerProcedure {
|
impl DockerProcedure {
|
||||||
pub fn validate(
|
pub fn validate(
|
||||||
&self,
|
&self,
|
||||||
|
eos_version: &Version,
|
||||||
volumes: &Volumes,
|
volumes: &Volumes,
|
||||||
image_ids: &BTreeSet<ImageId>,
|
image_ids: &BTreeSet<ImageId>,
|
||||||
expected_io: bool,
|
expected_io: bool,
|
||||||
@@ -85,7 +86,10 @@ impl DockerProcedure {
|
|||||||
if expected_io && self.io_format.is_none() {
|
if expected_io && self.io_format.is_none() {
|
||||||
color_eyre::eyre::bail!("expected io-format");
|
color_eyre::eyre::bail!("expected io-format");
|
||||||
}
|
}
|
||||||
if self.inject && !self.mounts.is_empty() {
|
if &**eos_version >= &emver::Version::new(0, 3, 1, 1)
|
||||||
|
&& self.inject
|
||||||
|
&& !self.mounts.is_empty()
|
||||||
|
{
|
||||||
color_eyre::eyre::bail!("mounts not allowed in inject actions");
|
color_eyre::eyre::bail!("mounts not allowed in inject actions");
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -40,12 +40,15 @@ impl PackageProcedure {
|
|||||||
#[instrument]
|
#[instrument]
|
||||||
pub fn validate(
|
pub fn validate(
|
||||||
&self,
|
&self,
|
||||||
|
eos_version: &Version,
|
||||||
volumes: &Volumes,
|
volumes: &Volumes,
|
||||||
image_ids: &BTreeSet<ImageId>,
|
image_ids: &BTreeSet<ImageId>,
|
||||||
expected_io: bool,
|
expected_io: bool,
|
||||||
) -> Result<(), color_eyre::eyre::Report> {
|
) -> Result<(), color_eyre::eyre::Report> {
|
||||||
match self {
|
match self {
|
||||||
PackageProcedure::Docker(action) => action.validate(volumes, image_ids, expected_io),
|
PackageProcedure::Docker(action) => {
|
||||||
|
action.validate(eos_version, volumes, image_ids, expected_io)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "js_engine")]
|
#[cfg(feature = "js_engine")]
|
||||||
PackageProcedure::Script(action) => action.validate(volumes),
|
PackageProcedure::Script(action) => action.validate(volumes),
|
||||||
|
|||||||
@@ -153,23 +153,26 @@ impl<R: AsyncRead + AsyncSeek + Unpin> S9pkReader<R> {
|
|||||||
man.actions
|
man.actions
|
||||||
.0
|
.0
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_, action)| action.validate(&man.volumes, &validated_image_ids))
|
.map(|(_, action)| {
|
||||||
|
action.validate(&man.eos_version, &man.volumes, &validated_image_ids)
|
||||||
|
})
|
||||||
.collect::<Result<(), Error>>()?;
|
.collect::<Result<(), Error>>()?;
|
||||||
man.backup.validate(&man.volumes, &validated_image_ids)?;
|
man.backup
|
||||||
|
.validate(&man.eos_version, &man.volumes, &validated_image_ids)?;
|
||||||
if let Some(cfg) = &man.config {
|
if let Some(cfg) = &man.config {
|
||||||
cfg.validate(&man.volumes, &validated_image_ids)?;
|
cfg.validate(&man.eos_version, &man.volumes, &validated_image_ids)?;
|
||||||
}
|
}
|
||||||
man.health_checks
|
man.health_checks
|
||||||
.validate(&man.volumes, &validated_image_ids)?;
|
.validate(&man.eos_version, &man.volumes, &validated_image_ids)?;
|
||||||
man.interfaces.validate()?;
|
man.interfaces.validate()?;
|
||||||
man.main
|
man.main
|
||||||
.validate(&man.volumes, &validated_image_ids, false)
|
.validate(&man.eos_version, &man.volumes, &validated_image_ids, false)
|
||||||
.with_ctx(|_| (crate::ErrorKind::ValidateS9pk, "Main"))?;
|
.with_ctx(|_| (crate::ErrorKind::ValidateS9pk, "Main"))?;
|
||||||
man.migrations
|
man.migrations
|
||||||
.validate(&man.volumes, &validated_image_ids)?;
|
.validate(&man.eos_version, &man.volumes, &validated_image_ids)?;
|
||||||
if let Some(props) = &man.properties {
|
if let Some(props) = &man.properties {
|
||||||
props
|
props
|
||||||
.validate(&man.volumes, &validated_image_ids, true)
|
.validate(&man.eos_version, &man.volumes, &validated_image_ids, true)
|
||||||
.with_ctx(|_| (crate::ErrorKind::ValidateS9pk, "Properties"))?;
|
.with_ctx(|_| (crate::ErrorKind::ValidateS9pk, "Properties"))?;
|
||||||
}
|
}
|
||||||
man.volumes.validate(&man.interfaces)?;
|
man.volumes.validate(&man.interfaces)?;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
use std::collections::{BTreeMap, BTreeSet};
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
|
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::context::RpcContext;
|
use crate::context::RpcContext;
|
||||||
use crate::id::{ ImageId};
|
use crate::id::ImageId;
|
||||||
use crate::procedure::{NoOutput, PackageProcedure, ProcedureName};
|
use crate::procedure::{NoOutput, PackageProcedure, ProcedureName};
|
||||||
use crate::s9pk::manifest::PackageId;
|
use crate::s9pk::manifest::PackageId;
|
||||||
use crate::util::serde::Duration;
|
use crate::util::serde::Duration;
|
||||||
@@ -19,11 +19,16 @@ pub use models::HealthCheckId;
|
|||||||
pub struct HealthChecks(pub BTreeMap<HealthCheckId, HealthCheck>);
|
pub struct HealthChecks(pub BTreeMap<HealthCheckId, HealthCheck>);
|
||||||
impl HealthChecks {
|
impl HealthChecks {
|
||||||
#[instrument]
|
#[instrument]
|
||||||
pub fn validate(&self, volumes: &Volumes, image_ids: &BTreeSet<ImageId>) -> Result<(), Error> {
|
pub fn validate(
|
||||||
|
&self,
|
||||||
|
eos_version: &Version,
|
||||||
|
volumes: &Volumes,
|
||||||
|
image_ids: &BTreeSet<ImageId>,
|
||||||
|
) -> Result<(), Error> {
|
||||||
for (_, check) in &self.0 {
|
for (_, check) in &self.0 {
|
||||||
check
|
check
|
||||||
.implementation
|
.implementation
|
||||||
.validate(&volumes, image_ids, false)
|
.validate(eos_version, &volumes, image_ids, false)
|
||||||
.with_ctx(|_| {
|
.with_ctx(|_| {
|
||||||
(
|
(
|
||||||
crate::ErrorKind::ValidateS9pk,
|
crate::ErrorKind::ValidateS9pk,
|
||||||
|
|||||||
Reference in New Issue
Block a user