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

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package remote
     5  
     6  import (
     7  	"github.com/terramate-io/tf/states/statemgr"
     8  )
     9  
    10  // Client is the interface that must be implemented for a remote state
    11  // driver. It supports dumb put/get/delete, and the higher level structs
    12  // handle persisting the state properly here.
    13  type Client interface {
    14  	Get() (*Payload, error)
    15  	Put([]byte) error
    16  	Delete() error
    17  }
    18  
    19  // ClientForcePusher is an optional interface that allows a remote
    20  // state to force push by managing a flag on the client that is
    21  // toggled on by a call to EnableForcePush.
    22  type ClientForcePusher interface {
    23  	Client
    24  	EnableForcePush()
    25  }
    26  
    27  // ClientLocker is an optional interface that allows a remote state
    28  // backend to enable state lock/unlock.
    29  type ClientLocker interface {
    30  	Client
    31  	statemgr.Locker
    32  }
    33  
    34  // Payload is the return value from the remote state storage.
    35  type Payload struct {
    36  	MD5  []byte
    37  	Data []byte
    38  }
    39  
    40  // Factory is the factory function to create a remote client.
    41  type Factory func(map[string]string) (Client, error)