oci

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CreatedAnnotation is the OpenContainers annotation for specifying
	// the date and time on which the OCI artifact was built (RFC 3339).
	CreatedAnnotation = "org.opencontainers.image.created"

	// ConfigMediaType is the OpenContainers artifact media type for the config layer.
	ConfigMediaType = "application/vnd.genval.config.v1+json"

	// ContentMediaType is the OpenContainers artifact media type for the content layer.
	ContentMediaType = "application/vnd.genval.content.v1.tar+gzip"

	ContentTypeAnnotation = "genval.content.type"

	// SourceAnnotation is the OpenContainers annotation for specifying
	// the upstream source of an OCI artifact.
	SourceAnnotation = "org.opencontainers.image.source"

	URLPrefix = "oci://"

	// TODO: Move all the URLs to a .env file to read from
	// OCI URLs for Rego policies
	DockerfilePolicies = URLPrefix + "ghcr.io/intelops/policyhub/genval/dockerfile_policies:v0.0.1"
	InfrafilePolicies  = URLPrefix + "ghcr.io/intelops/policyhub/genval/infrafile_policies:v0.0.1"
	TerraformPolicies  = URLPrefix + "ghcr.io/intelops/policyhub/genval/terraform_policies:v0.0.1"
	InputPolicies      = URLPrefix + "ghcr.io/intelops/policyhub/genval/input_policies:v0.0.1"
)

Variables

This section is empty.

Functions

func CheckTagAndPullArchive added in v0.1.1

func CheckTagAndPullArchive(url, tool, creds string, archivePath *os.File) error

CheckTagAndPullArchive checks for provided tag to be available in the remote, if available pulls the archive and stores it in the specified directory and retuens an error if encountered.

func CreateTarball

func CreateTarball(sourcePath, outputPath string) error

CreateTarball creates a tarball from a file or directory.

func CreateWorkspace

func CreateWorkspace(desiredTool, ociURL, creds string) error

func ExtractTarContents

func ExtractTarContents(tarReader *tar.Reader, destinationDir string) error

ExtractTarContents extracts the contents of a tar.Reader to the specified directory.

func FetchPolicyFromRegistry added in v0.1.5

func FetchPolicyFromRegistry(cmd string) (string, error)

FetchPolicyFromRegistry fetches the policy based on the command provided

func GenerateCraneOptions added in v0.1.6

func GenerateCraneOptions(ctx context.Context, ref name.Reference, auth authn.Authenticator, scopes []string) ([]crane.Option, error)

Most parts of GenerateCraneOptions and its related funcs are copied from https://github.com/google/go-containerregistry/blob/1b4e4078a545f2b6f96766a064b45ee77cdbefdd/pkg/v1/remote/options.go#L128

func GetCreds

func GetCreds(creds string) (authn.Authenticator, error)

func GetRemoteURL added in v0.1.5

func GetRemoteURL() (string, error)

GetGitRemoteURL fetches the remote url

func ParseAnnotations

func ParseAnnotations(args []string) (map[string]string, error)

func ParseOCIReference added in v0.1.6

func ParseOCIReference(ociURL string) (name.Reference, error)

func PullArtifact

func PullArtifact(ctx context.Context, creds, dest, path string) error

PullArtifact checks if tag exists and pull's the artifact from remote repository and writes to disk

func SignCosign

func SignCosign(imageRef, keyRef string) error

SignCosign signs an image (`imageRef`) in Keyless mode https://github.com/sigstore/cosign/blob/main/KEYLESS.md.

func VerifyArifact

func VerifyArifact(ctx context.Context, url, key string) (verified bool, err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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