swarm: unrestricted_internet flag on the agent permissions record, unset reads as on, create writes false
This commit is contained in:
parent
e77459d2cb
commit
8699857024
1 changed files with 381 additions and 107 deletions
|
|
@ -5,7 +5,8 @@ use hive_types::Permission;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// One agent's permissions. A field left out is not set by the swarm, and the
|
||||
/// compiled-in default applies; an empty list grants nothing.
|
||||
/// compiled-in default applies; an empty list grants nothing. A
|
||||
/// `PUT` that leaves out `unrestricted_internet` keeps the stored value.
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
|
@ -18,6 +19,11 @@ pub struct Permissions {
|
|||
schema(value_type = Option<Vec<String>>, example = json!(["messaging", "meta", "inbox", "execution"]))
|
||||
)]
|
||||
pub permissions: Option<Vec<Permission>>,
|
||||
/// Whether the agent's traffic leaves the host unfiltered. Absent in a
|
||||
/// `GET` means the swarm never set it, which counts as on. Absent in a
|
||||
/// `PUT` keeps the stored value.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub unrestricted_internet: Option<bool>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
@ -32,12 +38,21 @@ mod tests {
|
|||
(
|
||||
Permissions {
|
||||
permissions: Some(vec![]),
|
||||
unrestricted_internet: None,
|
||||
},
|
||||
r#"{"permissions":[]}"#,
|
||||
),
|
||||
(
|
||||
Permissions {
|
||||
permissions: None,
|
||||
unrestricted_internet: Some(false),
|
||||
},
|
||||
r#"{"unrestricted_internet":false}"#,
|
||||
),
|
||||
(
|
||||
Permissions {
|
||||
permissions: Some(vec![Permission::Messaging, Permission::ManageRootAgent]),
|
||||
unrestricted_internet: None,
|
||||
},
|
||||
r#"{"permissions":["messaging","manage_root_agent"]}"#,
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in a new issue