github.com/ojiry/terraform@v0.8.2-0.20161218223921-e50cec712c4a/state/remote/client_inmem.go (about)

     1  package remote
     2  
     3  import (
     4  	"crypto/md5"
     5  )
     6  
     7  // InmemClient is a Client implementation that stores data in memory.
     8  type InmemClient struct {
     9  	Data []byte
    10  	MD5  []byte
    11  }
    12  
    13  func (c *InmemClient) Get() (*Payload, error) {
    14  	return &Payload{
    15  		Data: c.Data,
    16  		MD5:  c.MD5,
    17  	}, nil
    18  }
    19  
    20  func (c *InmemClient) Put(data []byte) error {
    21  	md5 := md5.Sum(data)
    22  
    23  	c.Data = data
    24  	c.MD5 = md5[:]
    25  	return nil
    26  }
    27  
    28  func (c *InmemClient) Delete() error {
    29  	c.Data = nil
    30  	c.MD5 = nil
    31  	return nil
    32  }