gs

package
v0.0.0-...-d996d1d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2025 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Overview

Copyright 2021 The Chromium Authors Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Copyright 2021 The Chromium Authors Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	WriteFileToGS(gsPath gs.Path, data []byte) error
	Download(gsPath gs.Path, localPath string) error
	DownloadWithGsutil(ctx context.Context, gsPath gs.Path, localPath string) error
	Read(gsPath gs.Path) ([]byte, error)
	SetTTL(ctx context.Context, gsPath gs.Path, ttl time.Duration) error
	SetMetadata(ctx context.Context, gsPath gs.Path, key, value string) error
	List(ctx context.Context, bucket string, prefix string) ([]string, error)
}

type FakeClient

type FakeClient struct {
	T *testing.T
	// ExpectedLists is indexed by bucket and then by prefix.
	ExpectedLists     map[string]map[string][]string
	ExpectedWrites    map[string][]byte
	ExpectedDownloads map[string][]byte
	ExpectedReads     map[string][]byte
	ExpectedSetTTL    map[string]time.Duration
	ExpectedMetadata  map[string]map[string]string
}

func (*FakeClient) Download

func (f *FakeClient) Download(gsPath gs.Path, localPath string) error

func (*FakeClient) DownloadWithGsutil

func (f *FakeClient) DownloadWithGsutil(_ context.Context, gsPath gs.Path, localPath string) error

func (*FakeClient) List

func (f *FakeClient) List(_ context.Context, bucket string, prefix string) ([]string, error)

func (*FakeClient) Read

func (f *FakeClient) Read(gsPath gs.Path) ([]byte, error)

func (*FakeClient) SetMetadata

func (f *FakeClient) SetMetadata(ctx context.Context, gsPath gs.Path, key, value string) error

func (*FakeClient) SetTTL

func (f *FakeClient) SetTTL(_ context.Context, gsPath gs.Path, ttl time.Duration) error

func (*FakeClient) WriteFileToGS

func (f *FakeClient) WriteFileToGS(gsPath gs.Path, data []byte) error

WriteFileToGS writes the specified data to the specified gs path.

type ProdClient

type ProdClient struct {
	// contains filtered or unexported fields
}

func NewProdClient

func NewProdClient(ctx context.Context, authedClient *http.Client) (*ProdClient, error)

func (*ProdClient) Download

func (g *ProdClient) Download(gsPath gs.Path, localPath string) error

Download reads the specified path from gs to the specified local path.

func (*ProdClient) DownloadWithGsutil

func (g *ProdClient) DownloadWithGsutil(ctx context.Context, gsPath gs.Path, localPath string) error

DownloadWithGsutil reads the specified path from gs to the specified local path by shelling out to `gsutil` (which must exist on the client's path). This function is used in contexts where OAuth-based authentication is not available.

func (*ProdClient) List

func (g *ProdClient) List(ctx context.Context, bucket string, prefix string) ([]string, error)

List lists all the files in a specific bucket matching the given prefix.

func (*ProdClient) Read

func (g *ProdClient) Read(gsPath gs.Path) ([]byte, error)

Read reads the specified path from gs and returns its contents.

func (*ProdClient) SetMetadata

func (g *ProdClient) SetMetadata(ctx context.Context, gsPath gs.Path, key, value string) error

SetMetadata sets object metadata for an arbitrary key-value pair.

func (*ProdClient) SetTTL

func (g *ProdClient) SetTTL(ctx context.Context, gsPath gs.Path, ttl time.Duration) error

Set TTL sets the object's time to live.

func (*ProdClient) WriteFileToGS

func (g *ProdClient) WriteFileToGS(gsPath gs.Path, data []byte) error

WriteFileToGS writes the specified data to the specified gs path.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL