secretmanager

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 14 Imported by: 1

README

GCP Secret Manager storage

Usage

package mypkg

import (
	"context"
	"fmt"
	"github.com/viant/afs"
	"github.com/viant/afs/file"
	_ "github.com/viant/afsc/gcp"
	"log"
	"strings"
)

func Example_DownloadWithURL() {
	fs := afs.New()
	URL := "gcp://secretmanager/projects/gcp-e2e/secrets/test2sec"
	err := fs.Upload(context.TODO(), URL, file.DefaultFileOsMode, strings.NewReader("test is super secret"))
	if err != nil {
		log.Fatalf("err: %v\n", err)
	}
	data, err := fs.DownloadWithURL(context.TODO(), URL)
	if err != nil {
		log.Fatalf("err: %v\n", err)
	}
	fmt.Printf("%s %v\n", data, err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resource

type Resource struct {
	ProjectID string
	Secret    string
	Version   string
}

Resource represent secret resource

func (*Resource) Name

func (r *Resource) Name() string

Name returns resource name

func (*Resource) VersionedName

func (r *Resource) VersionedName() string

VersionedName return versioned name

type Storager added in v1.10.0

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

func NewStorager

func NewStorager(ctx context.Context, baseURL string, options ...storage.Option) (*Storager, error)

NewStorager create a new secreate manager storager

func (*Storager) Close added in v1.10.0

func (s *Storager) Close() error

Close closes storage

func (*Storager) Create added in v1.10.0

func (s *Storager) Create(ctx context.Context, destination string, mode os.FileMode, reader io.Reader, isDir bool, options ...storage.Option) error

Create create file or directory

func (*Storager) Delete added in v1.10.0

func (s *Storager) Delete(ctx context.Context, location string, options ...storage.Option) error

Delete deletes locations

func (*Storager) Exists added in v1.10.0

func (s *Storager) Exists(ctx context.Context, resourceID string, options ...storage.Option) (bool, error)

Exists returns true if location exists

func (*Storager) Get added in v1.10.0

func (s *Storager) Get(ctx context.Context, location string, options ...storage.Option) (os.FileInfo, error)

Get returns a file info for supplied location

func (*Storager) List added in v1.10.0

func (s *Storager) List(ctx context.Context, resourceID string, options ...storage.Option) ([]os.FileInfo, error)

List lists location assets

func (*Storager) Open added in v1.10.0

func (s *Storager) Open(ctx context.Context, resourceID string, options ...storage.Option) (io.ReadCloser, error)

Open returns a reader closer for supplied resources

func (*Storager) Upload added in v1.10.0

func (s *Storager) Upload(ctx context.Context, destination string, mode os.FileMode, reader io.Reader, options ...storage.Option) error

Upload uploads

Jump to

Keyboard shortcuts

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