filespec

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FileSpecTemplateFuncMap = template.FuncMap{
	"timeToInt": func(tm *time.Time) (string, error) {
		if tm == nil {
			return "", errors.New("nil time")
		}
		return fmt.Sprintf("%d", tm.UTC().Unix()), nil
	},
	"timeToDebianSnapshot": func(tm *time.Time) (string, error) {
		if tm == nil {
			return "", errors.New("nil time")
		}
		u := tm.UTC()
		return fmt.Sprintf("%04d%02d%02dT%02d%02d%02dZ",
			u.Year(), u.Month(), u.Day(), u.Hour(), u.Minute(), u.Second()), nil
	},
}

Functions

func NewFromSHA256SUMS

func NewFromSHA256SUMS(sha256sumsMapByFilename map[string]string, options ...HashMapOption) (map[string]*FileSpec, error)

NewFromSHA256SUMS returns a file spec map from the sha256sums map. The key of the returned map is a file name such as "pool/main/h/hello/hello_2.10-2_amd64.deb"". The key does not contain "pseudo" file names prefixed with "/ipfs/".

func NewFromSHA256SUMSFiles

func NewFromSHA256SUMSFiles(fnames ...string) (map[string]*FileSpec, error)

func ValidateName

func ValidateName(name string) error

Types

type FileSpec

type FileSpec struct {
	Name     string             `json:"Name"`            // "pool/main/h/hello/hello_2.10-2_amd64.deb"
	Basename string             `json:"Basename"`        // "hello_2.10-2_amd64.deb"
	SHA256   string             `json:"SHA256"`          // "35b1508eeee9c1dfba798c4c04304ef0f266990f936a51f165571edf53325cbc"
	CID      string             `json:"CID,omitempty"`   // IPFS CID
	Epoch    *time.Time         `json:"Epoch,omitempty"` // Timestamp of SHA256SUMS, or $SOURCE_DATE_EPOCH
	Dpkg     *dpkgutil.Dpkg     `json:"Dpkg,omitempty"`
	RPM      *rpmutil.RPM       `json:"RPM,omitempty"`
	APK      *apkutil.APK       `json:"APK,omitempty"`
	Pacman   *pacmanutil.Pacman `json:"Pacman,omitempty"`
}

func New

func New(name, sha256 string, options ...Option) (*FileSpec, error)

func (FileSpec) URL

func (sp FileSpec) URL(provider string) (*url.URL, error)

type HashMapOption added in v0.4.0

type HashMapOption func(o *hashMapOpts)

func WithHashMapEpoch added in v0.4.0

func WithHashMapEpoch(epoch *time.Time) HashMapOption

type Option

type Option func(o *opts)

func WithCID

func WithCID(cid string) Option

func WithEpoch added in v0.4.0

func WithEpoch(epoch *time.Time) Option

type PseudoFilename

type PseudoFilename struct {
	CID string
}

PseudoFilename is prefixed with "/ipfs/". e.g., "/ipfs/QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH".

func ParsePseudoFilename

func ParsePseudoFilename(s string) *PseudoFilename

ParsePseudoFilename parses a pseudo file name.

Jump to

Keyboard shortcuts

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