...

Source file src/edge-infra.dev/pkg/edge/rollouts/internal/engine_conditions.go

Documentation: edge-infra.dev/pkg/edge/rollouts/internal

     1  package internal
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"edge-infra.dev/pkg/edge/rollouts"
     7  )
     8  
     9  // TODO(dk185217): Only referenced in test code, perhaps move to a *_test.go file?
    10  type TestCondition struct {
    11  	NodeState rollouts.NodeState
    12  	Action    func(*InMemStore, rollouts.NodeExecutionResult)
    13  }
    14  
    15  // TODO(dk185217): Only referenced in test code, perhaps move to a *_test.go file?
    16  type ConditionMap map[rollouts.NodeKey]TestCondition
    17  
    18  // TODO(dk185217): Only referenced in test code, perhaps move to a *_test.go file?
    19  func ModifyStore(inMemStore *InMemStore, conditions ConditionMap, result rollouts.NodeExecutionResult) error {
    20  	resultKey := result.Key
    21  	nodeCondition, found := conditions[resultKey]
    22  	if !found {
    23  		return fmt.Errorf("node key %s not found", resultKey)
    24  	}
    25  
    26  	if nodeCondition.NodeState == result.State {
    27  		fmt.Printf("running func for %s state %s\n", resultKey, result.State)
    28  		nodeCondition.Action(inMemStore, result)
    29  	} else {
    30  		fmt.Printf("result %s for key %s did not match desired state %s", result.State, resultKey, nodeCondition.NodeState)
    31  	}
    32  	return nil
    33  }
    34  

View as plain text