actions

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package actions provides utilities to work with GitHub Actions.

Index

Constants

View Source
const (

	// GitHubActionsRegex is regular expression pattern to match GitHub Actions usage
	GitHubActionsRegex = `uses:\s*[^\s]+/[^\s]+@[^\s]+|uses:\s*docker://[^\s]+:[^\s]+`
	// ReferenceType is the type of the reference
	ReferenceType = "action"
)

Variables

View Source
var (
	// ErrInvalidAction is returned when parsing the action fails.
	ErrInvalidAction = errors.New("invalid action")
	// ErrInvalidActionReference is returned when parsing the action reference fails.
	ErrInvalidActionReference = errors.New("action reference is not a tag nor branch")
)

Functions

func GetChecksum

func GetChecksum(ctx context.Context, cfg config.GHActions, restIf interfaces.REST, action, ref string) (string, error)

GetChecksum returns the checksum for a given action and tag.

func ParseActionReference

func ParseActionReference(input string) (action string, reference string, err error)

ParseActionReference parses an action reference into action and reference.

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser is a struct to replace action references with digests

func New

func New() *Parser

New creates a new Parser

func (*Parser) ConvertToEntityRef

func (_ *Parser) ConvertToEntityRef(reference string) (*interfaces.EntityRef, error)

ConvertToEntityRef converts an action reference to an EntityRef

func (*Parser) GetRegex

func (p *Parser) GetRegex() string

GetRegex returns the regular expression pattern to match GitHub Actions usage

func (*Parser) Replace

func (p *Parser) Replace(
	ctx context.Context,
	matchedLine string,
	restIf interfaces.REST,
	cfg config.Config,
) (*interfaces.EntityRef, error)

Replace replaces the action reference with the digest

func (*Parser) SetCache

func (p *Parser) SetCache(cache store.RefCacher)

SetCache returns the regular expression pattern to match GitHub Actions usage

func (*Parser) SetRegex

func (p *Parser) SetRegex(regex string)

SetRegex returns the regular expression pattern to match GitHub Actions usage

Jump to

Keyboard shortcuts

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