Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace EnsureOpSpec and CleanOpSpec with ApplyOpSpec #67

Closed
1 task
azriel91 opened this issue Jan 6, 2023 · 1 comment · Fixed by #99
Closed
1 task

Replace EnsureOpSpec and CleanOpSpec with ApplyOpSpec #67

azriel91 opened this issue Jan 6, 2023 · 1 comment · Fixed by #99
Assignees

Comments

@azriel91
Copy link
Owner

azriel91 commented Jan 6, 2023

The ensure and clean operations are the same "apply" logic, with the target state either being the desired state, or the cleaned state.

Peace is intended to be able to support a set of target states such as "an empty set of servers", e.g. reusing servers for testing installation of software. This means arbitrary target states for each item -- "desired state for items a and b, but cleaned state for item c".

This may include some support to model "defined state" and "clean state" as top level concepts which are currently captured as separate commands.

  • As part of this, move peace_core::progress to peace_cfg::resources.
@azriel91
Copy link
Owner Author

azriel91 commented Mar 16, 2023

Tasks

  • Rename EnsureOpSpec to ApplyOpSpec.

    fd -Ftf 'ensure_op_spec' -x bash -c 'mv $0 ${0/ensure_op_spec/apply_op_spec}' {}
    sd -s 'ensure_op_spec' 'apply_op_spec' $(fd -tf)
    sd -s 'EnsureOpSpec' 'ApplyOpSpec' $(fd -tf)
    sd -s 'Ensure OpSpec' 'ApplyOpSpec' $(fd -tf)
    sd -s 'ensure_op' 'apply_op' $(fd -tf)
    sd -s 'ensure op' 'apply op' $(fd -tf)
    sd '/// (.+) apply_op_spec(.*)' '/// $1 apply op spec $2' $(fd -tf)
    cargo fmt --all
  • Add ItemSpec::state_clean to return an example of an empty State.

    On naming, because we want to consolidate functions into one trait (Consolidate Item Spec functions into single trait #96), we will likely have the following names:

    trait ItemSpec {
        async fn state_clean();
        async fn state_current();
        async fn state_desired();
    
        async fn try_state_current();
        async fn try_state_desired();
    }
  • Split ApplyCmd from EnsureCmd, and take in target state, which may be state_desired or state_clean.

  • EnsureCmd and CleanCmd both delegate to ApplyCmd.

  • Update item specs to move CleanOpSpec logic into ApplyOpSpec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant