github.com/opentofu/opentofu@v1.7.1/internal/command/jsonformat/collections/action.go (about)

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