github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/states/statemgr/lineage.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package statemgr
     5  
     6  import (
     7  	"fmt"
     8  
     9  	uuid "github.com/hashicorp/go-uuid"
    10  )
    11  
    12  // NewLineage generates a new lineage identifier string. A lineage identifier
    13  // is an opaque string that is intended to be unique in space and time, chosen
    14  // when state is recorded at a location for the first time and then preserved
    15  // afterwards to allow Terraform to recognize when one state snapshot is a
    16  // predecessor or successor of another.
    17  func NewLineage() string {
    18  	lineage, err := uuid.GenerateUUID()
    19  	if err != nil {
    20  		panic(fmt.Errorf("Failed to generate lineage: %v", err))
    21  	}
    22  	return lineage
    23  }