storage

package
v0.28.0-rc6 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Flags = []cli.Flag{

	&cli.BoolFlag{
		Name:  "storage.enable",
		Usage: "enable object storage",
		Sources: cli.NewValueSourceChain(
			cli.EnvVar("VELA_STORAGE_ENABLE"),
			cli.File("vela/storage/enable"),
		),
	},
	&cli.StringFlag{
		Name:  "storage.driver",
		Usage: "object storage driver",
		Sources: cli.NewValueSourceChain(
			cli.EnvVar("VELA_STORAGE_DRIVER"),
			cli.EnvVar("STORAGE_DRIVER"),
			cli.File("vela/storage/driver"),
		),
	},
	&cli.StringFlag{
		Name:  "storage.addr",
		Usage: "set the storage endpoint (ex. scheme://host:port)",
		Sources: cli.NewValueSourceChain(
			cli.EnvVar("VELA_STORAGE_ADDRESS"),
			cli.EnvVar("STORAGE_ADDRESS"),
			cli.File("vela/storage/addr"),
		),
		Action: func(_ context.Context, _ *cli.Command, v string) error {

			if !strings.Contains(v, "://") {
				return fmt.Errorf("storage address must be fully qualified (<scheme>://<host>)")
			}

			if strings.HasSuffix(v, "/") {
				return fmt.Errorf("storage address must not have trailing slash")
			}

			return nil
		},
	},

	&cli.StringFlag{
		Name:  "storage.access.key",
		Usage: "set storage access key",
		Sources: cli.NewValueSourceChain(
			cli.EnvVar("VELA_STORAGE_ACCESS_KEY"),
			cli.EnvVar("STORAGE_ACCESS_KEY"),
			cli.File("vela/storage/access_key"),
		),
	},
	&cli.StringFlag{
		Name:  "storage.secret.key",
		Usage: "set storage secret key",
		Sources: cli.NewValueSourceChain(
			cli.EnvVar("VELA_STORAGE_SECRET_KEY"),
			cli.EnvVar("STORAGE_SECRET_KEY"),
			cli.File("vela/storage/secret_key"),
		),
	},
	&cli.StringFlag{
		Name:  "storage.bucket.name",
		Usage: "set storage bucket name",
		Sources: cli.NewValueSourceChain(
			cli.EnvVar("VELA_STORAGE_BUCKET"),
			cli.File("vela/storage/bucket"),
		),
	},
	&cli.BoolFlag{
		Name:    "storage.use.ssl",
		Usage:   "enable storage to use SSL",
		Value:   false,
		Sources: cli.EnvVars("VELA_STORAGE_USE_SSL"),
	},
}

Functions

func ToContext

func ToContext(c Setter, s Storage)

ToContext adds the secret Service to this context if it supports the Setter interface.

func WithContext

func WithContext(ctx context.Context, s Storage) context.Context

WithContext adds the minio Storage to the context.

func WithGinContext

func WithGinContext(c *gin.Context, s Storage)

WithGinContext inserts the minio Storage into the gin.Context.

Types

type Setter

type Setter interface {
	Set(any, any)
}

Setter defines a context that enables setting values.

type Setup

type Setup struct {
	Enable    bool
	Driver    string
	Endpoint  string
	AccessKey string
	SecretKey string
	Bucket    string
	Region    string
	Secure    bool
	Token     string
}

Setup represents the configuration necessary for creating a Vela service capable of integrating with a configured S3 environment.

func (*Setup) Minio

func (s *Setup) Minio() (Storage, error)

Minio creates and returns a Vela service capable of integrating with an S3 environment.

func (*Setup) Validate

func (s *Setup) Validate() error

Validate verifies the necessary fields for the provided configuration are populated correctly.

type Storage

type Storage interface {
	StatObject(context.Context, *api.Object) (*api.Object, error)
	ListBuildObjectNames(context.Context, string, string, string) (map[string]string, error)
	PresignedGetObject(context.Context, *api.Object) (string, error)
	PresignedPutObject(context.Context, string, time.Duration) (string, error)
}

Storage defines the service interface for object storage operations.

func FromContext

func FromContext(ctx context.Context) Storage

FromContext retrieves minio service from the context.

func FromGinContext

func FromGinContext(c *gin.Context) Storage

FromGinContext retrieves the S3 Service from the gin.Context.

func New

func New(s *Setup) (Storage, error)

New creates and returns a Vela service capable of integrating with the configured storage environment. Currently, the following storages are supported:

* minio .

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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