notation

package
v0.0.0-...-fd3f69f Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotationDirName   = "notation"
	TrustPolicyName   = "trustpolicy.json"
	TrustStoreDirName = "truststore"
	TrustStoreTypeCA  = "ca"
	PluginDirName     = "plugins"
	PluginName        = "e2e-plugin"
	ConfigJsonName    = "config.json"
)
View Source
const (
	SigningKeysFileName     = "signingkeys.json"
	LocalKeysDirName        = "localkeys"
	LocalConfigJsonsDirName = "configjsons"
)
View Source
const ArtifactTypeNotation = "application/vnd.cncf.notary.signature"

Variables

View Source
var (
	// NotationBinPath is the notation binary path.
	NotationBinPath string
	// NotationOldBinPath is the path of an old version notation binary for
	// testing forward compatibility.
	NotationOldBinPath                    string
	NotationE2EPluginPath                 string
	NotationE2EPluginTarGzPath            string
	NotationE2EMaliciousPluginArchivePath string
	NotationE2EConfigPath                 string
	NotationE2ELocalKeysDir               string
	NotationE2ETrustPolicyDir             string
	NotationE2EConfigJsonDir              string
)
View Source
var (
	OCILayoutPath       string
	TestRepoUri         string
	TestTag             string
	RegistryStoragePath string
)
View Source
var TestRegistry = Registry{}

Functions

func AddConfigJsonOption

func AddConfigJsonOption(configJsonName string) utils.HostOption

AddConfigJsonOption adds a valid config.json for testing.

func AddKeyOption

func AddKeyOption(keyName, certName string) utils.HostOption

AddKeyOption adds the test signingkeys.json, key and cert files to the notation directory.

func AddKeyPairs

func AddKeyPairs(dir, keyName, certName string) error

AddKeyPairs creates the signingkeys.json file and the localkeys directory with e2e.key and e2e.crt

func AddPlugin

func AddPlugin(pluginPath string) utils.HostOption

AddPlugin adds a pluginkeys.json config file and installs an e2e-plugin.

func AddTrustPolicyOption

func AddTrustPolicyOption(trustpolicyName string) utils.HostOption

AddTrustPolicyOption adds a valid trust policy for testing.

func AddTrustStoreOption

func AddTrustStoreOption(namedstore string, srcCertPath string) utils.HostOption

AddTrustStoreOption adds the test cert to the trust store.

func AuthOption

func AuthOption(username, password string) utils.HostOption

AuthOption sets the auth environment variables for notation.

func BaseOptions

func BaseOptions() []utils.HostOption

BaseOptions returns a list of base Options for a valid notation. testing environment.

func BaseOptionsWithExperimental

func BaseOptionsWithExperimental() []utils.HostOption

func CreateNotationDirOption

func CreateNotationDirOption() utils.HostOption

CreateNotationDirOption creates the notation directory in temp user dir.

func EnableExperimental

func EnableExperimental() utils.HostOption

EnableExperimental enables experimental features.

func Host

func Host(options []utils.HostOption, fn CoreTestFunc)

Host creates a virtualized notation testing host by modify the "XDG_CONFIG_HOME" environment variable of the Executor.

options is the required testing environment options fn is the callback function containing the testing logic.

func HostInGithubAction

func HostInGithubAction(options []utils.HostOption, fn CoreTestFunc)

HostInGithubAction only run the test in GitHub Actions.

The booting script will setup TLS reverse proxy and TLS certificate for Github Actions environment.

func HostWithOCILayout

func HostWithOCILayout(options []utils.HostOption, fn OCILayoutTestFunc)

HostWithOCILayout creates a virtualized notation testing host by modify the "XDG_CONFIG_HOME" environment variable of the Executor. It generates isolated OCI layout in the testing host.

options is the required testing environment options fn is the callback function containing the testing logic.

func OldNotation

func OldNotation(options ...utils.HostOption) *utils.ExecOpts

OldNotation create an old version notation ExecOpts in a VirtualHost for testing forward compatibility.

func Opts

func Opts(options ...utils.HostOption) []utils.HostOption

Opts is a grammar sugar to generate a list of HostOption.

func TestLoginOptions

func TestLoginOptions() []utils.HostOption

TestLoginOptions returns the BaseOptions with removing AuthOption and adding ConfigOption. testing environment.

Types

type Artifact

type Artifact struct {
	*Registry
	// Repo is the repository name.
	Repo string
	// Tag is the tag of the artifact.
	Tag string
	// Digest is the digest of the artifact.
	Digest string
}

Artifact describes an artifact in a repository.

func GenerateArtifact

func GenerateArtifact(srcRepo, newRepo string) *Artifact

GenerateArtifact generates a new artifact with a new repository by copying the source repository in the OCILayoutPath to be a new repository.

func (*Artifact) DomainReferenceWithDigest

func (r *Artifact) DomainReferenceWithDigest() string

DomainReferenceWithDigest returns the <domainHost>/<Repository>@<alg>:<digest> for testing --insecure-registry flag and TLS request.

func (*Artifact) ReferenceWithDigest

func (r *Artifact) ReferenceWithDigest() string

ReferenceWithDigest returns the <registryHost>/<Repository>@<alg>:<digest>

func (*Artifact) ReferenceWithTag

func (r *Artifact) ReferenceWithTag() string

ReferenceWithTag returns the <registryHost>/<Repository>:<Tag>

func (*Artifact) SignatureDescriptors

func (r *Artifact) SignatureDescriptors() ([]ocispec.Descriptor, error)

SignatureManifest returns the manifest of the artifact.

type CoreTestFunc

type CoreTestFunc func(notation *utils.ExecOpts, artifact *Artifact, vhost *utils.VirtualHost)

CoreTestFunc is the test function running in a VirtualHost.

notation is an Executor isolated by $XDG_CONFIG_HOME. artifact is a generated artifact in a new repository. vhost is the VirtualHost instance.

type ExternalKey

type ExternalKey struct {
	ID           string            `json:"id,omitempty"`
	PluginName   string            `json:"pluginName,omitempty"`
	PluginConfig map[string]string `json:"pluginConfig,omitempty"`
}

ExternalKey contains the necessary information to delegate the signing operation to the named plugin.

type KeySuite

type KeySuite struct {
	Name string `json:"name"`
	*X509KeyPair
	*ExternalKey
}

KeySuite is a named key suite.

type OCILayout

type OCILayout struct {
	// Path is the path of the OCI layout directory.
	Path string
	// Tag is the tag of artifact in the OCI layout.
	Tag string
	// Digest is the digest of artifact in the OCI layout.
	Digest string
}

OCILayout is a OCI layout directory for

func GenerateOCILayout

func GenerateOCILayout(srcRepoName string) (*OCILayout, error)

GenerateOCILayout creates a new OCI layout in a temporary directory.

func (*OCILayout) ReferenceWithDigest

func (o *OCILayout) ReferenceWithDigest() string

ReferenceWithDigest returns the reference with digest.

func (*OCILayout) ReferenceWithTag

func (o *OCILayout) ReferenceWithTag() string

ReferenceWithTag returns the reference with tag.

type OCILayoutTestFunc

type OCILayoutTestFunc func(notation *utils.ExecOpts, ocilayout *OCILayout, vhost *utils.VirtualHost)

OCILayoutTestFunc is the test function running in a VirtualHost with isolated OCI layout for each test case.

notation is an Executor isolated by $XDG_CONFIG_HOME. vhost is the VirtualHost instance.

type Registry

type Registry struct {
	// Host is the registry host.
	Host string
	// Username is the username to access the registry.
	Username string
	// Password is the password to access the registry.
	Password string
	// DomainHost is a registry host, separate from localhost, used for testing
	// the --insecure-registry flag.
	//
	// If the host is localhost, Notation connects via plain HTTP. For
	// non-localhost hosts, Notation defaults to HTTPS. However, users can
	// enforce HTTP by setting the --insecure-registry flag.
	DomainHost string
}

func (*Registry) CreateArtifact

func (r *Registry) CreateArtifact(srcRepoName, destRepoName string) (*Artifact, error)

CreateArtifact copies a local OCI layout to the registry to create a new artifact with a new repository.

srcRepoName is the repo name in ./testdata/registry/oci_layout folder. destRepoName is the repo name to be created in the registry.

type SigningKeys

type SigningKeys struct {
	Default string     `json:"default"`
	Keys    []KeySuite `json:"keys"`
}

SigningKeys reflects the signingkeys.json file.

type X509KeyPair

type X509KeyPair struct {
	KeyPath         string `json:"keyPath"`
	CertificatePath string `json:"certPath"`
}

X509KeyPair contains the paths of a public/private key pair files.

Jump to

Keyboard shortcuts

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