config

package
v0.14.8 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: MIT Imports: 18 Imported by: 21

Documentation

Overview

Package config contains a canonical configuration for signer.

Index

Constants

This section is empty.

Variables

View Source
var AllSignerTypes []SignerType

AllSignerTypes is a list of all contract types. Since we use stringer and this is a testing library, instead of manually copying all these out we pull the names out of stringer. In order to make sure stringer is updated, we panic on any method called where the index is higher than the stringer array length.

View Source
var ErrUnsupportedSignerType = errors.New("unsupported signer type")

ErrUnsupportedSignerType indicates the signer type being used is unsupported.

Functions

func SignerFromConfig

func SignerFromConfig(ctx context.Context, config SignerConfig) (signer.Signer, error)

SignerFromConfig creates a new signer from a signer config. TODO: this needs to be moved to some kind of common package. in the old code configs were split into responsible packages. Maybe something like that works here?

Types

type AWSConfig

type AWSConfig struct {
	// Region is the region the signer is in.
	Region string `yaml:"region"`
	// AccessKey is the access key for the signer.
	AccessKey string `yaml:"access_key"`
	// AccessSecret is the access secret for the signer.
	AccessSecret string `yaml:"access_secret"`
	// KeyID is the key id for the signer.
	KeyID string `yaml:"key_id"`
}

AWSConfig is the config for an AWS signer. this should match the schema of the file passed in.

func DecodeAWSConfig

func DecodeAWSConfig(filePath string) (cfg AWSConfig, err error)

DecodeAWSConfig decodes the config from a file.

func (AWSConfig) Encode

func (a AWSConfig) Encode() ([]byte, error)

Encode encodes the config to yaml.

type GCPConfig

type GCPConfig struct {
	// KeyName is the name of the key to use.
	KeyName string `yaml:"key_name"`
	// CredentialFile is the path to the credentials file.
	// note: this is not recommended for production use.
	// workload identity federation is recommended.
	CredentialFile string `yaml:"credential_file"`
	// Endpoint is the endpoint to use. This is useful for testing.
	Endpoint string `yaml:"endpoint"`
}

GCPConfig is the config for a GCP signer.

func DecodeGCPConfig

func DecodeGCPConfig(filePath string) (cfg GCPConfig, err error)

DecodeGCPConfig decodes the config from a file.

func (GCPConfig) Encode

func (a GCPConfig) Encode() ([]byte, error)

Encode encodes the config to yaml.

type SignerConfig

type SignerConfig struct {
	// Type is the driver used for the signer
	Type string
	// File is the file used for the key.
	File string
}

SignerConfig contains a signer config. Currently this config only supports local based signers due to a lack of isomorphic types when we parse yaml.

func (SignerConfig) IsValid

func (s SignerConfig) IsValid(_ context.Context) (ok bool, err error)

IsValid determines if the config is valid.

type SignerType

type SignerType int

SignerType is the signer type

const (
	// FileType is a file-based signer.
	FileType SignerType = iota + 1 // File
	// AWSType is an aws kms based signer.
	AWSType // AWS
	// GCPType is a gcp cloud based signer.
	GCPType // GCP
)

func (SignerType) String

func (i SignerType) String() string

Jump to

Keyboard shortcuts

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