github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/command/jsonformat/collections/action.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package collections
     5  
     6  import "github.com/terramate-io/tf/plans"
     7  
     8  // CompareActions will compare current and next, and return plans.Update if they
     9  // are different, and current if they are the same.
    10  func CompareActions(current, next plans.Action) plans.Action {
    11  	if next == plans.NoOp {
    12  		return current
    13  	}
    14  
    15  	if current != next {
    16  		return plans.Update
    17  	}
    18  	return current
    19  }