gcs

package
v7.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, gcsConfig *Config, options ...Option) (vustorage.Storage, error)

New instantiates a gcs.Storage client to handle storing and retrieving storage.ContentRevision and Collated Versions.

Types

type Config

type Config struct {
	GcsRegion             string
	GcsEndpoint           string
	BucketName            string
	IamRoleEnabled        bool
	Credentials           StaticKeyCredentials
	WithoutAuthentication bool
}

Config holds setting up and targeting proper GCS targets.

type Option

type Option func(*Storage)

Option defines a Storage constructor option.

func NewCollator

func NewCollator(newCollator func() (*vustorage.Collator, error)) Option

NewCollator configures the Storage instance to use the given constructor function for creating collator instances.

type StaticKeyCredentials

type StaticKeyCredentials struct {
	ProjectId string
	Filename  string
}

StaticKeyCredentials structure google.Credentials for GCS storage.NewClient API.

type Storage

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

Storage implements storage.Storage.

func (*Storage) CollateVersions

func (s *Storage) CollateVersions(ctx context.Context, serviceFilter map[string]bool) error

CollateVersions iterates over all possible permutations of Service versions to create a unified version spec for each unique vervet.Version.

func (*Storage) CreateBucket

func (s *Storage) CreateBucket(ctx context.Context) error

CreateBucket idempotently creates an GCS bucket for VU.

func (*Storage) DeleteObject

func (s *Storage) DeleteObject(ctx context.Context, key string) error

DeleteObject deletes a file if it exists.

func (*Storage) GetCollatedVersionSpec

func (s *Storage) GetCollatedVersionSpec(ctx context.Context, version string) ([]byte, error)

GetCollatedVersionSpec retrieves a single collated vervet.Version and returns the JSON blob.

func (*Storage) GetCollatedVersionSpecs

func (s *Storage) GetCollatedVersionSpecs(ctx context.Context) (map[string][]byte, error)

GetCollatedVersionSpecs retrieves a map of vervet.Version strings and their corresponding JSON blobs and returns the result.

func (*Storage) GetObject

func (s *Storage) GetObject(ctx context.Context, key string) ([]byte, error)

GetObject actually retrieves the json blob form GCS.

func (*Storage) GetObjectWithMetadata

func (s *Storage) GetObjectWithMetadata(ctx context.Context,
	key string) (*storage.Reader,
	*storage.ObjectAttrs,
	error,
)

GetObjectWithMetadata actually retrieves the json blob form GCS with metadata around the storage in GCS.

func (*Storage) HasVersion

func (s *Storage) HasVersion(ctx context.Context, name string, version string, digest string) (bool, error)

HasVersion implements scraper.Storage.

func (*Storage) ListBucketContents

func (s *Storage) ListBucketContents(ctx context.Context) ([]string, error)

ListBucketContents lists all available files in a GCS bucket.

func (*Storage) ListCollatedVersions

func (s *Storage) ListCollatedVersions(ctx context.Context) ([]string, error)

ListCollatedVersions nice wrapper around the GCS ListObjects request. example: key = "collated-versions/" result: []string{"2022-02-02~wip", "2022-12-02~beta"} Defaults to 1000 results.

func (*Storage) ListObjects

func (s *Storage) ListObjects(ctx context.Context, key string, delimeter string) ([]storage.ObjectAttrs, error)

ListObjects nice wrapper around the GCS storage.BucketHandle Objects request. Defaults to 1000 results.

func (*Storage) NotifyVersion

func (s *Storage) NotifyVersion(ctx context.Context,
	name string,
	version string,
	contents []byte,
	scrapeTime time.Time,
) error

NotifyVersion updates a Service's storage.ContentRevision if storage.Digest has changed.

func (*Storage) NotifyVersions

func (s *Storage) NotifyVersions(ctx context.Context, name string, versions []string, scrapeTime time.Time) error

NotifyVersions implements scraper.Storage.

func (*Storage) PutObject

func (s *Storage) PutObject(ctx context.Context, key string, reader io.Reader) (putErr error)

PutObject nice wrapper around the GCS PutObject request.

func (*Storage) Version

func (s *Storage) Version(ctx context.Context, version string) ([]byte, error)

Version implements scraper.Storage.

func (*Storage) VersionIndex

func (s *Storage) VersionIndex(ctx context.Context) (vervet.VersionIndex, error)

Versions lists all available Collated Versions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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