github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/states/statefile/version0.go (about)

     1  package statefile
     2  
     3  // looksLikeVersion0 sniffs for the signature indicating a version 0 state
     4  // file.
     5  //
     6  // Version 0 was the number retroactively assigned to Terraform's initial
     7  // (unversioned) binary state file format, which was later superseded by the
     8  // version 1 format in JSON.
     9  //
    10  // Version 0 is no longer supported, so this is used only to detect it and
    11  // return a nice error to the user.
    12  func looksLikeVersion0(src []byte) bool {
    13  	// Version 0 files begin with the magic prefix "tfstate".
    14  	const magic = "tfstate"
    15  	if len(src) < len(magic) {
    16  		// Not even long enough to have the magic prefix
    17  		return false
    18  	}
    19  	if string(src[0:len(magic)]) == magic {
    20  		return true
    21  	}
    22  	return false
    23  }