files

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// GCSScheme is the scheme for GCS
	GCSScheme = "gs"
	// FileScheme is the scheme for local files
	FileScheme = "file"
)
View Source
const (
	// SecretManagerScheme URI scheme for gcp secrets. These need to be lowercase.
	SecretManagerScheme = "gcpsecretmanager"
)

Variables

This section is empty.

Functions

func Read

func Read(uri string) ([]byte, error)

Read reads the given URI

Types

type Factory

type Factory struct{}

Factory returns the correct filehelper based on a files scheme

func (*Factory) Get

func (f *Factory) Get(uri string) (FileHelper, error)

type FileHelper

type FileHelper interface {
	Exists(path string) (bool, error)
	NewReader(path string) (io.Reader, error)
	NewWriter(path string) (io.Writer, error)
}

FileHelper is an interface intended to transparently handle working with GCS, local files, and other filesystems e.g. GCP Secret manager.

type GCPSecretManager

type GCPSecretManager struct {
	Client *secretmanager.Client
}

GCPSecretManager implements the interface but for GCP secrets URIs should look like gcpsecretmanager:///projects/${project}/secrets/${secret}/versions/${version}

func (*GCPSecretManager) Exists

func (h *GCPSecretManager) Exists(uri string) (bool, error)

Exists checks whether the file exists.

func (*GCPSecretManager) NewReader

func (h *GCPSecretManager) NewReader(uri string) (io.Reader, error)

NewReader creates a new Reader for local file.

func (*GCPSecretManager) NewWriter

func (h *GCPSecretManager) NewWriter(uri string) (io.Writer, error)

NewWriter creates a new Writer

type LocalFileHelper

type LocalFileHelper struct{}

func (*LocalFileHelper) Exists

func (h *LocalFileHelper) Exists(uri string) (bool, error)

Exists checks whether the file exists.

func (*LocalFileHelper) NewReader

func (h *LocalFileHelper) NewReader(uri string) (io.Reader, error)

NewReader creates a new Reader for local file.

func (*LocalFileHelper) NewWriter

func (h *LocalFileHelper) NewWriter(uri string) (io.Writer, error)

NewWriter creates a new Writer for the local file.

TODO(jlewi): Can we add options to control filemode?

Jump to

Keyboard shortcuts

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