processor

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PinCommentPattern matches pin directive comments like "# pin@v5"
	PinCommentPattern = regexp.MustCompile(`#\s*pin@([^\s]+)`)
)

Common regex patterns used across processors

Functions

func ExtractPinComment

func ExtractPinComment(text string) string

ExtractPinComment extracts pin directive from comment like "# pin@v5" This is now generic and can be used by any processor

func FormatActionPin

func FormatActionPin(originalRef, pinnedRef string)

FormatActionPin formats a GitHub Action pin message with granular coloring

func FormatActionPinMessage

func FormatActionPinMessage(originalRef, pinnedRef string)

FormatActionPinMessage formats a pin message for GitHub Actions

func FormatAlreadyPinnedActionsMessage

func FormatAlreadyPinnedActionsMessage(pinnedActions []string)

FormatAlreadyPinnedActionsMessage formats a detailed message showing already pinned actions

func FormatAlreadyPinnedDockerMessage

func FormatAlreadyPinnedDockerMessage(fileType string, pinnedImages []string, serviceNames []string)

FormatAlreadyPinnedDockerMessage formats a detailed message showing already pinned Docker images

func FormatAlreadyPinnedMessage

func FormatAlreadyPinnedMessage(fileType string, count int)

FormatAlreadyPinnedMessage formats a message when all references are already pinned

func FormatDockerPin

func FormatDockerPin(fileType, serviceName, originalImage, pinnedImage string)

FormatDockerPin formats a Docker image pin message with granular coloring

func LogWarning

func LogWarning(format string, args ...interface{})

LogWarning provides consistent warning message formatting

func ParseImageNameAndTag added in v0.0.2

func ParseImageNameAndTag(image string) (name, tag string)

ParseImageNameAndTag splits an image reference into name and tag

func PinImage

func PinImage(rc *regclient.RegClient, image string, config ProcessorConfig) (string, error)

PinImage resolves an image tag to its immutable digest using regclient Returns clean tag@digest format for better Docker compatibility

func ProcessActions

func ProcessActions(rc *regclient.RegClient, path string, config ProcessorConfig) error

ProcessActions updates GitHub Actions workflow files to pin action references to commit SHAs

func ProcessCompose

func ProcessCompose(rc *regclient.RegClient, path string, config ProcessorConfig) error

ProcessCompose updates image tags in a Compose file

func ProcessDockerfile

func ProcessDockerfile(rc *regclient.RegClient, path string, config ProcessorConfig) error

ProcessDockerfile updates FROM lines in a Dockerfile

func ProcessFileGeneric

func ProcessFileGeneric(path string, config ProcessorConfig, processor FileProcessor) error

ProcessFileGeneric provides a common pattern for file processing operations

func UpdateCommentWithPin

func UpdateCommentWithPin(text, originalRef string) string

UpdateCommentWithPin adds or updates a pin comment in text

Types

type ComposeFile

type ComposeFile map[string]interface{}

ComposeFile is a flexible representation of a docker-compose YAML that preserves all fields

type DefaultGitHubResolver

type DefaultGitHubResolver struct{}

DefaultGitHubResolver implements GitHubResolver using the GitHub CLI

func (*DefaultGitHubResolver) ResolveActionToSHA

func (r *DefaultGitHubResolver) ResolveActionToSHA(ref *GitHubRef) (string, error)

ResolveActionToSHA resolves a GitHub action tag/ref to a commit SHA using GitHub CLI's REST client

type FileProcessor

type FileProcessor func(data []byte, config ProcessorConfig) ([]byte, bool, error)

FileProcessor represents a generic file processing function

type GitHubRef

type GitHubRef struct {
	Owner string
	Repo  string
	Ref   string
	SHA   string
}

GitHubRef represents a GitHub repository reference

type GitHubResolver

type GitHubResolver interface {
	ResolveActionToSHA(ref *GitHubRef) (string, error)
}

GitHubResolver interface for resolving GitHub action references

type ImagePinner added in v0.1.0

type ImagePinner func(rc *regclient.RegClient, image string, config ProcessorConfig) (string, error)

ImagePinner resolves an image reference to a pinned digest reference.

type ProcessorConfig

type ProcessorConfig struct {
	DryRun         bool
	Algorithm      string
	NoColor        bool
	Pervasive      bool
	ExpandRegistry bool
	ForceMode      string         // "docker", "actions", or "" for auto-detection
	Quiet          bool           // suppress informational messages when no changes are needed
	Platform       string         // platform-specific manifest digest (e.g., linux/amd64, linux/arm/v7)
	GitHubResolver GitHubResolver // resolver for GitHub API calls (injected for testing)
	ImagePinner    ImagePinner    // resolver for Docker image pins (injected for testing)
}

ProcessorConfig holds configuration for the processor

type StaticGitHubResolver added in v0.1.0

type StaticGitHubResolver map[string]string

StaticGitHubResolver resolves action refs from an in-memory mapping.

func NewStaticGitHubResolverFromFile added in v0.1.0

func NewStaticGitHubResolverFromFile(path string) (StaticGitHubResolver, error)

NewStaticGitHubResolverFromFile loads a JSON object mapping "owner/repo@ref" to a 40-character SHA.

func (StaticGitHubResolver) ResolveActionToSHA added in v0.1.0

func (r StaticGitHubResolver) ResolveActionToSHA(ref *GitHubRef) (string, error)

ResolveActionToSHA resolves a GitHub action tag/ref to a commit SHA from a static map.

Jump to

Keyboard shortcuts

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