Repository: etcd-io/etcd
File: client/v3/kubernetes/interface.go (Go)

Code before:
package kubernetes

import (
	"context"

	"go.etcd.io/etcd/api/v3/mvccpb"
	clientv3 "go.etcd.io/etcd/client/v3"
)

// Interface defines the minimal client-side interface that Kubernetes requires
// to interact with etcd. Methods below are standard etcd operations with
// semantics adjusted to better suit Kubernetes' needs.
type Interface interface {
	// Get retrieves a single key-value pair from etcd.
	//
	// If opts.Revision is set to a non-zero value, the key-value pair is retrieved at the specified revision.
	// If the required revision has been compacted, the request will fail with ErrCompacted.
	Get(ctx context.Context, key string, opts GetOptions) (GetResponse, error)

	// List retrieves key-value pairs with the specified prefix, ordered lexicographically by key.
	//
	// If opts.Revision is non-zero, the key-value pairs are retrieved at the specified revision.
	// If the required revision has been compacted, the request will fail with ErrCompacted.
	// If opts.Limit is greater than zero, the number of returned key-value pairs is bounded by the limit.
	// If opts.Continue is not empty, the listing will start from the key specified by it.
	// The Continue value should be the last key returned in a previous
	// paginated ListResponse with "\x00" appended to it.
	List(ctx context.Context, prefix string, opts ListOptions) (ListResponse, error)

	// Count returns the number of keys with the specified prefix.
	//
	// Currently, there are no options for the Count operation. However, a placeholder options struct (CountOptions)
	// is provided for future extensibility in case options become necessary.
	Count(ctx context.Context, prefix string, opts CountOptions) (int64, error)

	// OptimisticPut creates or updates a key-value pair if the key has not been modified or created
	// since the revision specified in expectedRevision.
	//
	// An OptimisticPut fails if the key has been modified since expectedRevision.
	OptimisticPut(ctx context.Context, key string, value []byte, expectedRevision int64, opts PutOptions) (PutResponse, error)

	// OptimisticDelete deletes the key-value pair if it hasn't been modified since the revision
	// specified in expectedRevision.
	//
	// An OptimisticDelete fails if the key has been modified since expectedRevision.
	OptimisticDelete(ctx context.Context, key string, expectedRevision int64, opts DeleteOptions) (DeleteResponse, error)
}

type GetOptions struct {
	// Revision is the point-in-time of the etcd key-value store to use for the Get operation.
	// If Revision is 0, it gets the latest value.

Review comment (suggestion):
```suggestion
	// When Paginating the Continue should be set to last observed key with "\x00" appended to it.
```

Code after:
package kubernetes

import (
	"context"

	"go.etcd.io/etcd/api/v3/mvccpb"
	clientv3 "go.etcd.io/etcd/client/v3"
)

// Interface defines the minimal client-side interface that Kubernetes requires
// to interact with etcd. Methods below are standard etcd operations with
// semantics adjusted to better suit Kubernetes' needs.
type Interface interface {
	// Get retrieves a single key-value pair from etcd.
	//
	// If opts.Revision is set to a non-zero value, the key-value pair is retrieved at the specified revision.
	// If the required revision has been compacted, the request will fail with ErrCompacted.
	Get(ctx context.Context, key string, opts GetOptions) (GetResponse, error)

	// List retrieves key-value pairs with the specified prefix, ordered lexicographically by key.
	//
	// If opts.Revision is non-zero, the key-value pairs are retrieved at the specified revision.
	// If the required revision has been compacted, the request will fail with ErrCompacted.
	// If opts.Limit is greater than zero, the number of returned key-value pairs is bounded by the limit.
	// If opts.Continue is not empty, the listing will start from the key
	// specified by it. When paginating, the Continue value should be set
	// to the last observed key with "\x00" appended to it.
	List(ctx context.Context, prefix string, opts ListOptions) (ListResponse, error)

	// Count returns the number of keys with the specified prefix.
	//
	// Currently, there are no options for the Count operation. However, a placeholder options struct (CountOptions)
	// is provided for future extensibility in case options become necessary.
	Count(ctx context.Context, prefix string, opts CountOptions) (int64, error)

	// OptimisticPut creates or updates a key-value pair if the key has not been modified or created
	// since the revision specified in expectedRevision.
	//
	// An OptimisticPut fails if the key has been modified since expectedRevision.
	OptimisticPut(ctx context.Context, key string, value []byte, expectedRevision int64, opts PutOptions) (PutResponse, error)

	// OptimisticDelete deletes the key-value pair if it hasn't been modified since the revision
	// specified in expectedRevision.
	//
	// An OptimisticDelete fails if the key has been modified since expectedRevision.
	OptimisticDelete(ctx context.Context, key string, expectedRevision int64, opts DeleteOptions) (DeleteResponse, error)
}

type GetOptions struct {
	// Revision is the point-in-time of the etcd key-value store to use for the Get operation.
	// If Revision is 0, it gets the latest value.