2024-02-08 03:48:59 -06:00
|
|
|
// Copyright (c) The OpenTofu Authors
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
2023-05-02 10:33:06 -05:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2018-08-27 17:54:03 -05:00
|
|
|
package statemgr
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2023-09-26 12:09:27 -05:00
|
|
|
"github.com/hashicorp/go-uuid"
|
2018-08-27 17:54:03 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// NewLineage generates a new lineage identifier string. A lineage identifier
|
|
|
|
// is an opaque string that is intended to be unique in space and time, chosen
|
|
|
|
// when state is recorded at a location for the first time and then preserved
|
2023-09-26 12:09:27 -05:00
|
|
|
// afterwards to allow OpenTofu to recognize when one state snapshot is a
|
2018-08-27 17:54:03 -05:00
|
|
|
// predecessor or successor of another.
|
|
|
|
func NewLineage() string {
|
|
|
|
lineage, err := uuid.GenerateUUID()
|
|
|
|
if err != nil {
|
2023-09-18 07:53:49 -05:00
|
|
|
panic(fmt.Errorf("Failed to generate lineage: %w", err))
|
2018-08-27 17:54:03 -05:00
|
|
|
}
|
|
|
|
return lineage
|
|
|
|
}
|