snap

package
v0.0.1-pre1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	Date     time.Time `json:"date"`
	Endpoint string    `json:"endpoint"`
	Method   string    `json:"method"`
}

type Options

type Options struct {
	// ResponseHeaders is the list of response headers the snapper will record
	ResponseHeaders []string
}

type ParseOptions

type ParseOptions struct {
	Variables map[string]string
}

type Snapper

type Snapper struct {
	Options Options
	// contains filtered or unexported fields
}

func New

func New() *Snapper

func (*Snapper) Take

func (s *Snapper) Take(ctx context.Context, spec *Spec) (*Snapshot, error)

Take grabs a snapshot of the repo status

type SnapperImplementation

type SnapperImplementation interface {
	ValidateSpec(*Spec) error
	GetClient() (*github.Client, error)
	CallAPI(context.Context, *github.Client, *Spec) (*http.Response, error)
	ParseResponse(*Options, *Spec, *http.Response) (*Snapshot, error)
	ApplyFieldMask(*Snapshot, []string) (*Snapshot, error)
}

type Snapshot

type Snapshot struct {
	ID       string              `json:"id"`
	Type     string              `json:"type"`
	Metadata Metadata            `json:"metadata"`
	Headers  map[string][]string `json:"headers"`
	Values   map[string]any      `json:"values"`
}

func (*Snapshot) AsStatement

func (s *Snapshot) AsStatement() attestation.Statement

AsStatement converts the snapshot to an intoto attestation

func (*Snapshot) GetData

func (s *Snapshot) GetData() []byte

func (*Snapshot) GetParsed

func (s *Snapshot) GetParsed() any

func (*Snapshot) GetType

func (s *Snapshot) GetType() attestation.PredicateType

func (*Snapshot) SetType

func (s *Snapshot) SetType(t attestation.PredicateType) error

type Spec

type Spec struct {
	ID       string   `json:"id"`
	Type     string   `json:"type"`
	Endpoint string   `json:"endpoint"`
	Method   string   `json:"method"`
	Mask     []string `json:"mask"`
}

func (*Spec) Validate

func (spec *Spec) Validate() error

type SpecParser

type SpecParser struct{}

func (*SpecParser) ParseWithOptions

func (sp *SpecParser) ParseWithOptions(r io.Reader, opts *ParseOptions) (*Spec, error)

Jump to

Keyboard shortcuts

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