mindpak

package
v0.0.75 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package mindpak abstracts to bundle profiles and rule types together in an artifact that allows for easy distribution and upgrade.

Package mindpak abstracts to bundle profiles and rule types together in an artifact that allows for easy distribution and upgrade.

Index

Constants

View Source
const (
	// PathProfiles is the name of the directory holding the profiles of a bundle
	PathProfiles = "profiles"

	// PathRuleTypes is the name of the directory holding the rule types of a bundle
	PathRuleTypes = "rule_types"

	// ManifestFileName is the defaul filename for the manifest
	ManifestFileName = "manifest.json"
)
View Source
const (
	// SHA256 is the algorith name constant for the manifest and tests
	SHA256 = HashAlgorithm("sha-256")
)

Variables

View Source
var (
	// ValidNameRegex is used to check a bundle name or namespace
	ValidNameRegex = regexp.MustCompile(`^[a-zA-Z0-9](?:[-_a-zA-Z0-9]{0,61}[a-zA-Z0-9])?$`)
)

Functions

This section is empty.

Types

type Bundle

type Bundle struct {
	Manifest *Manifest
	Metadata *Metadata
	Files    *Files
	Source   fs.StatFS
}

Bundle abstracts the bundle data.

The bundle has a manifest. The manifest is composed by reading the Source filesystem and categorizing its entries.

func NewBundleFromDirectory

func NewBundleFromDirectory(path string) (*Bundle, error)

NewBundleFromDirectory reads a directory from a directory and returns a bundle loaded with its contents. The bundle will have its Source filesystem bound to the directory via an os.DirFS.

func NewBundleFromTarGZ

func NewBundleFromTarGZ(path string) (*Bundle, error)

NewBundleFromTarGZ loads a bundle from a .tar.gz file containing the bundle structure. Note that this implementation loads the entire contents of the bundle into memory. This is tested by the test in the `internal/marketplace` package.

func (*Bundle) ReadSource

func (b *Bundle) ReadSource() error

ReadSource loads the data from the mindpak source filesystem

func (*Bundle) UpdateManifest

func (b *Bundle) UpdateManifest() error

UpdateManifest updates the bundle manifest to reflect the bundle data source

func (*Bundle) Verify

func (_ *Bundle) Verify() error

Verify checks the contents of the bundle against its manifest

type BundleID

type BundleID struct {
	Namespace string
	Name      string
}

BundleID groups together the pieces of information needed to identify a bundle. This cleans up the interfaces which deal with bundles.

func ID

func ID(namespace string, name string) BundleID

ID is a convenience function for creating BundleID instances

func (BundleID) String

func (b BundleID) String() string

type File

type File struct {
	Name   string                   `json:"name,omitempty"`
	Hashes map[HashAlgorithm]string `json:"hashes,omitempty"`
}

File captures the name and hashes of a file included in the bundle

type Files

type Files struct {
	Profiles  []*File `json:"profiles,omitempty"`
	RuleTypes []*File `json:"ruleTypes,omitempty"`
}

Files is a collection of the files included in the bundle organized by type

type HashAlgorithm

type HashAlgorithm string

HashAlgorithm is a label that indicates a hashing algorithm

type Manifest

type Manifest struct {
	Metadata *Metadata `json:"metadata,omitempty"`
	Files    *Files    `json:"files"`
}

Manifest abstracts the json file included in the bundle that contains its metadata

func (*Manifest) Read

func (m *Manifest) Read(r io.Reader) error

Read loads the manifest data by parsing json data from reader r

func (*Manifest) Write

func (m *Manifest) Write(w io.Writer) error

Write writes the bundle manifest to a file

type Metadata

type Metadata struct {
	Name      string     `json:"name,omitempty"`
	Namespace string     `json:"namespace,omitempty"`
	Version   string     `json:"version,omitempty"`
	Date      *time.Time `json:"date,omitempty"`
}

Metadata is the data describing the bundle

Directories

Path Synopsis
Package build implements tools and function to build mindpaks.
Package build implements tools and function to build mindpaks.
Package reader contains logic for accessing the contents of a bundle
Package reader contains logic for accessing the contents of a bundle
Package sources contains logic for loading a bundle from a source of bundles
Package sources contains logic for loading a bundle from a source of bundles

Jump to

Keyboard shortcuts

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