From 47eebc7be30f6dcd5f7276e674753aed6300efea Mon Sep 17 00:00:00 2001 From: Linus Vogel Date: Sat, 22 Aug 2026 15:20:15 +0200 Subject: [PATCH] added some state types --- src/sls/state/command.rs | 10 ++++++++++ src/sls/state/file.rs | 33 ++++++++++++++++++++++++++++----- src/sls/state/group.rs | 9 +++++++++ src/sls/state/mod.rs | 23 ++++++++++++++++++++++- src/sls/state/package.rs | 11 +++++++++++ src/sls/state/service.rs | 8 ++++++-- src/sls/state/user.rs | 13 +++++++++++++ 7 files changed, 99 insertions(+), 8 deletions(-) create mode 100644 src/sls/state/command.rs create mode 100644 src/sls/state/group.rs create mode 100644 src/sls/state/package.rs create mode 100644 src/sls/state/user.rs diff --git a/src/sls/state/command.rs b/src/sls/state/command.rs new file mode 100644 index 0000000..232efbb --- /dev/null +++ b/src/sls/state/command.rs @@ -0,0 +1,10 @@ +pub enum CommandState { + Run { + name: String, + cwd: Option, + shell: Option, + create: Option, + unless: Option, + onlyif: Option, + }, +} \ No newline at end of file diff --git a/src/sls/state/file.rs b/src/sls/state/file.rs index a28058b..aacd646 100644 --- a/src/sls/state/file.rs +++ b/src/sls/state/file.rs @@ -1,8 +1,31 @@ pub enum FileState { - Managed, - Present, - Absent, - BlockReplace, - Symlinked + Managed { + source: Option, + user: Option, + group: Option, + mode: Option, + contents: Option, + template: Option, + clean: Option, + clean_mode: Option, + }, + Directory { + user: Option, + group: Option, + mode: Option, + clean: Option, + clean_mode: Option, + }, + File { + source: Option, + user: Option, + group: Option, + mode: Option, + contents: Option, + template: Option, + }, + Symlink { + target: String, + }, } \ No newline at end of file diff --git a/src/sls/state/group.rs b/src/sls/state/group.rs new file mode 100644 index 0000000..8dac33d --- /dev/null +++ b/src/sls/state/group.rs @@ -0,0 +1,9 @@ +pub enum GroupState { + Present { + name: String, + gid: Option, + }, + Absent { + name: String, + }, +} \ No newline at end of file diff --git a/src/sls/state/mod.rs b/src/sls/state/mod.rs index 32aa675..6cd785a 100644 --- a/src/sls/state/mod.rs +++ b/src/sls/state/mod.rs @@ -1,10 +1,31 @@ use crate::sls::state::file::FileState; use crate::sls::state::service::ServiceState; +use crate::sls::state::package::PackageState; +use crate::sls::state::command::CommandState; +use crate::sls::state::user::UserState; +use crate::sls::state::group::GroupState; pub mod file; pub mod service; +pub mod package; +pub mod command; +pub mod user; +pub mod group; -pub enum State { +pub struct State { + pub function: StateFunction, + pub dependency: Vec, +} + +pub enum StateFunction { File (FileState), Service (ServiceState), + Package (PackageState), + Command (CommandState), + User (UserState), + Group (GroupState), +} + +pub enum StateDependency { + } \ No newline at end of file diff --git a/src/sls/state/package.rs b/src/sls/state/package.rs new file mode 100644 index 0000000..9ce8d37 --- /dev/null +++ b/src/sls/state/package.rs @@ -0,0 +1,11 @@ +pub enum PackageState { + Installed { + name: String, + }, + Latest { + name: String, + }, + Removed { + name: String, + }, +} \ No newline at end of file diff --git a/src/sls/state/service.rs b/src/sls/state/service.rs index 07185c9..f135b21 100644 --- a/src/sls/state/service.rs +++ b/src/sls/state/service.rs @@ -1,6 +1,10 @@ pub enum ServiceState { - Running, - Stopped, + Running { + enable: Option, + }, + Stopped { + enable: Option, + }, } \ No newline at end of file diff --git a/src/sls/state/user.rs b/src/sls/state/user.rs new file mode 100644 index 0000000..62840ce --- /dev/null +++ b/src/sls/state/user.rs @@ -0,0 +1,13 @@ +pub enum UserState { + Present { + name: String, + uid: Option, + gid: Option, + shell: Option, + home: Option, + groups: Option>, + }, + Absent { + name: String, + }, +} \ No newline at end of file