Skip to main content

GroupDef

Struct GroupDef 

Source
pub struct GroupDef {
    pub id: String,
    pub description: Option<String>,
    pub members: Vec<String>,
    pub query: Option<String>,
    pub refresh: Option<String>,
    pub tags: Vec<String>,
    pub origin: Option<RepoOrigin>,
}
Expand description

A declared fleet group (#1032): the third manifest kind alongside Manifest (jobs) and Schedule (schedules), stored in BUCKET_GROUP_DEFS keyed by id.

(The first doc line deliberately does not start with #NNN — schemars treats a leading # as a Markdown heading and would extract it as the schema title, garbling it. Same reason View’s doc leads with prose.)

A group definition names a set of PCs in one of two mutually-exclusive ways:

  • static — a literal members list. Declared, git-reviewable membership (the auditability win over hand-editing the imperative agent_groups KV).
  • dynamic — a read-only SQL query that returns a pc_id column. Membership is derived from the fleet’s own facts (agents, inventory_facts + json_extract(facts_json, …), feeds, check_status, explode: tables — anything in the projector DB), so “every client OS”, “the servers sharing a hostname prefix”, “machines still on build 26100” are all just a SELECT. The query runs in the backend read-only sandbox (api::query), never on the endpoint.

A schedule’s target.groups resolves a defined group (static or dynamic) in addition to the imperative agent_groups membership, so declared groups and manually-assigned ones coexist and this never mutates agent_groups.

Fields§

§id: String

Stable identifier (the KV key + URL segment + the name a schedule’s target.groups references). Required; same [A-Za-z0-9._-] charset as a View id via is_valid_resource_id.

§description: Option<String>

Optional human description shown on the groups admin page.

§members: Vec<String>

Static membership — a literal list of pc_ids. Mutually exclusive with query; exactly one of the two must be set (enforced by GroupDef::validate).

§query: Option<String>

Dynamic membership — a read-only SELECT/WITH returning a pc_id column. Mutually exclusive with members. The backend validates it read-only at group create and again at run time; a write verb / stacked statement is rejected. Empty string is treated as unset so an operator can comment the body out to switch to members: without dropping the key.

§refresh: Option<String>

Membership-recompute cadence for a dynamic group as a humantime duration ("30m", "6h"). Absent ⇒ DEFAULT_GROUP_REFRESH. Ignored for a static group.

§tags: Vec<String>

Free-form operator taxonomy (same role as Manifest::tags).

§origin: Option<RepoOrigin>

GitOps provenance (#678), stamped by kanade group def create from the source YAML’s Git context — same as View::origin.

Implementations§

Source§

impl GroupDef

Source

pub fn dynamic_query(&self) -> Option<&str>

The dynamic SQL body if this is a dynamic group — a non-blank query. (An empty-string query reads as unset, mirroring Execute::script.)

Source

pub fn refresh_interval(&self) -> Duration

The effective recompute cadence for a dynamic group — the parsed refresh or DEFAULT_GROUP_REFRESH. Falls back to the default on an unparseable value rather than panicking on the read path (validation already rejected a bad value at create time).

Source

pub fn validate(&self) -> Result<(), String>

Trait Implementations§

Source§

impl Clone for GroupDef

Source§

fn clone(&self) -> GroupDef

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GroupDef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for GroupDef

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for GroupDef

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl Serialize for GroupDef

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StrictSchema for GroupDef

GroupDef likewise has no flattened field.

Source§

fn strict_top_level_keys() -> Option<&'static [&'static str]>

The complete set of valid top-level keys, or None when the type has no flattened field. See the trait docs.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more