fornellas / resonance

A transactional host configuration management tool.
GNU General Public License v3.0
4 stars 1 forks source link

apply: add validations #135

Open fornellas opened 1 month ago

fornellas commented 1 month ago

53 delivered the apply command. It works, but it'd be good to have extra validaiton:

These 2 extra checks should catch any implementation bugs on any resources, which will be quite useful.

fornellas commented 1 month ago

Note to self: draft of what needs changing:

diff --git a/internal/blueprint/step.go b/internal/blueprint/step.go
index 89709ef..f28c674 100644
--- a/internal/blueprint/step.go
+++ b/internal/blueprint/step.go
@@ -153,6 +153,7 @@ func (s *Step) Resolve(ctx context.Context, hst host.Host) error {
 // Load returns a copy of the Step, with all resource states loaded from given Host.
 func (s *Step) Load(ctx context.Context, hst host.Host) (*Step, error) {
        ns := *s
+       // TODO move to resourcePkg.LoadResources()
        if s.singleResource != nil {
                resosurce := resourcesPkg.NewResourceWithSameId(s.singleResource)

diff --git a/internal/plan/plan.go b/internal/plan/plan.go
index 4b30b33..ca32b6c 100644
--- a/internal/plan/plan.go
+++ b/internal/plan/plan.go
@@ -189,6 +189,9 @@ func (a *Action) Apply(ctx context.Context, host hostPkg.Host) error {
                }
        }

+       // TODO load host state, compare with ApplyResources
+       //   use resourcePkg.LoadResources(a.ApplyResources)
+
        return nil
 }

@@ -290,5 +293,7 @@ func (p Plan) Apply(ctx context.Context, host hostPkg.Host) error {
                }
        }

+       // TODO load host state, compare with plan
+
        return nil
 }