Skip to content

Commit

Permalink
add GoDocs to all public things
Browse files Browse the repository at this point in the history
Signed-off-by: Kengo TODA <skypencil+github@gmail.com>
  • Loading branch information
KengoTODA committed Aug 23, 2022
1 parent d35e88e commit 5a75d4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gcs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ import (
gcStorage "cloud.google.com/go/storage"
)

// A minimal interface to mock behavior of GCS client.
type Client interface {
// Read an object from a GCS bucket.
Read(ctx context.Context) ([]byte, error)

// Write an object onto a GCS bucket.
Write(ctx context.Context, p []byte) error
}

// An implementation of Client that delegates actual operation to gcsStorage.Client.
type Adapter struct {
// A config to specify which bucket and object we handle.
config Config
// A GCS client which is delegated actual operation.
client *gcStorage.Client
}

Expand Down Expand Up @@ -42,6 +49,7 @@ func (a Adapter) Write(ctx context.Context, p []byte) error {
return w.Close()
}

// NewClient returns a new Client with given Context and Config.
func NewClient(ctx context.Context, config Config) (Client, error) {
c, err := gcStorage.NewClient(ctx)
a := &Adapter{
Expand Down
1 change: 1 addition & 0 deletions gcs/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
storage "github.com/minamijoyo/tfmigrate-storage"
)

// An implementation of [storage.Storage] interface.
type Storage struct {
// config is a storage config for GCS.
config *Config
Expand Down

0 comments on commit 5a75d4a

Please sign in to comment.