dir

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: Apache-2.0 Imports: 4 Imported by: 9

Documentation

Overview

package dir implements Notation directory structure. [directory spec]: https://github.com/notaryproject/notation/blob/main/specs/directory.md

Example:

  • Read config.json: file, err := dir.ConfigFS().Open(dir.PathConfigFile)

  • Get the path of config.json: path, err := dir.ConfigFS().SysPath(dir.PathConfigFile)

  • Read trustpolicy.json: file, err := dir.ConfigFS().Open(dir.PathTrustPolicy)

  • Get the path of trustpolicy.json: path, err := dir.ConfigFS().SysPath(dir.PathTrustPolicy)

  • Set custom configurations directory: dir.UserConfigDir = '/path/to/configurations/'

Only user level directory is supported for RC.1, and system level directory may be added later.

Index

Constants

View Source
const (
	// PathConfigFile is the config.json file relative path.
	PathConfigFile = "config.json"
	// PathSigningKeys is the signingkeys file relative path.
	PathSigningKeys = "signingkeys.json"
	// PathTrustPolicy is the trust policy file relative path.
	PathTrustPolicy = "trustpolicy.json"
	// PathPlugins is the plugins directory relative path.
	PathPlugins = "plugins"
	// LocalKeysDir is the directory name for local key relative path.
	LocalKeysDir = "localkeys"
	// LocalCertificateExtension defines the extension of the certificate files.
	LocalCertificateExtension = ".crt"
	// LocalKeyExtension defines the extension of the key files.
	LocalKeyExtension = ".key"
	// TrustStoreDir is the directory name of trust store.
	TrustStoreDir = "truststore"
)

The relative path to {NOTATION_CONFIG}

Variables

View Source
var (
	UserConfigDir  string // Absolute path of user level {NOTATION_CONFIG}
	UserLibexecDir string // Absolute path of user level {NOTATION_LIBEXEC}
)

Functions

func LocalKeyPath

func LocalKeyPath(name string) (keyPath, certPath string)

LocalKeyPath returns the local key and local cert relative paths.

func X509TrustStoreDir

func X509TrustStoreDir(items ...string) string

X509TrustStoreDir returns the trust store relative path.

items includes named-store and cert-file names. the directory follows the pattern of {NOTATION_CONFIG}/truststore/x509/{store-type}/{named-store}/{cert-file}

Types

type SysFS

type SysFS interface {
	fs.FS

	// SysPath returns the real system path of the given path items in the SysFS.
	SysPath(items ...string) (string, error)
}

SysFS is virtual file system interface that support fs.FS and SysPath method.

func ConfigFS

func ConfigFS() SysFS

ConfigFS is the config SysFS

func NewSysFS

func NewSysFS(root string) SysFS

NewSysFS returns the SysFS for the given root directory.

Support one root directory for rc.1, and may support union directories FS after rc.1.

func PluginFS

func PluginFS() SysFS

PluginFS is the plugin SysFS

Jump to

Keyboard shortcuts

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