Help us shape the future of Go! Take the 2026 Go Developer Survey

snap

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PayloadTypeStruct = "struct"
	PayloadTypeArray  = "array"
)

Variables

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

	// Platform is the explicitly selected platform (optional, auto-detected if not set)
	Platform platform.Type

	// SpecPath is the path to the spec file (used for auto-detection)
	SpecPath string

	// Client is a pre-built API client the snapper uses instead of creating
	// one through the platform registry. Set it when the credentials come from
	// somewhere other than the process environment — for example a server
	// seeding each call with a short-lived installation token. When set, its
	// platform also resolves the snapshot defaults unless Platform is set
	// explicitly.
	Client platform.Client
}

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

New creates a 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(platform.Type) (platform.Client, error)
	CallAPI(context.Context, platform.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"`
	Name     string            `json:"name"`
	Url      string            `json:"url"`
	Type     string            `json:"type"`
	Metadata Metadata          `json:"metadata"`
	Headers  map[string]string `json:"headers"`
	Values   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) GetOrigin added in v0.2.0

func (s *Snapshot) GetOrigin() attestation.Subject

func (*Snapshot) GetParsed

func (s *Snapshot) GetParsed() any

func (*Snapshot) GetSource added in v0.1.1

func (s *Snapshot) GetSource() attestation.Subject

func (*Snapshot) GetType

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

func (*Snapshot) GetVerification added in v0.2.0

func (s *Snapshot) GetVerification() attestation.Verification

func (*Snapshot) SetOrigin added in v0.2.0

func (s *Snapshot) SetOrigin(attestation.Subject)

func (*Snapshot) SetSource added in v0.1.1

func (s *Snapshot) SetSource(attestation.Subject)

func (*Snapshot) SetType

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

func (*Snapshot) SetVerification added in v0.2.0

func (s *Snapshot) SetVerification(attestation.Verification)

type Spec

type Spec struct {
	// ID is the string that will be used to generate the subject's
	// hash when generating an attestation. It should identify the
	// object described by the data returned by the API call. This
	// ID MUST be unique for each instance the API returns.
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Url         string   `json:"url"`
	Type        string   `json:"type"`
	Endpoint    string   `json:"endpoint"`
	Method      string   `json:"method"`
	PayloadType string   `json:"payload" yaml:"payload"` //nolint:tagalign
	Mask        []string `json:"mask"`
	Data        string   `json:"data"`
	TrimNL      bool     `json:"trimNL"   yaml:"trimNL"`
}

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)

ParseWithOptions parses a spec yaml definition.

Jump to

Keyboard shortcuts

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