github.com/nevins-b/terraform@v0.3.8-0.20170215184714-bbae22007d5a/state/testdata/lockstate.go (about)

     1  package main
     2  
     3  import (
     4  	"io"
     5  	"log"
     6  	"os"
     7  
     8  	"github.com/hashicorp/terraform/state"
     9  )
    10  
    11  // Attempt to open and lock a terraform state file.
    12  // Lock failure exits with 0 and writes "lock failed" to stderr.
    13  func main() {
    14  	if len(os.Args) != 2 {
    15  		log.Fatal(os.Args[0], "statefile")
    16  	}
    17  
    18  	s := &state.LocalState{
    19  		Path: os.Args[1],
    20  	}
    21  
    22  	err := s.Lock("test")
    23  	if err != nil {
    24  		io.WriteString(os.Stderr, "lock failed")
    25  
    26  	}
    27  	return
    28  }