updater

package
v1.20250224.6 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNewer

func IsNewer(v1, v2 string) bool

IsNewer compares two version strings and returns true if v1 is newer than v2

Types

type ActionReference

type ActionReference struct {
	Owner           string
	Name            string
	Version         string
	CommitHash      string
	Path            string
	Line            int
	Comments        []string
	VersionComment  string // Comment indicating version (e.g., "# v3")
	OriginalVersion string // For tracking version history
}

ActionReference represents a GitHub Action reference in a workflow file

type DefaultPRCreator

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

DefaultPRCreator implements the PRCreator interface

func NewPRCreator

func NewPRCreator(token, owner, repo string) *DefaultPRCreator

NewPRCreator creates a new instance of DefaultPRCreator

func (*DefaultPRCreator) CreatePR

func (c *DefaultPRCreator) CreatePR(ctx context.Context, updates []*Update) error

CreatePR creates a pull request with the given updates

type DefaultUpdateManager

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

DefaultUpdateManager implements the UpdateManager interface

func NewUpdateManager

func NewUpdateManager(baseDir string) *DefaultUpdateManager

NewUpdateManager creates a new instance of DefaultUpdateManager

func (*DefaultUpdateManager) ApplyUpdates

func (m *DefaultUpdateManager) ApplyUpdates(ctx context.Context, updates []*Update) error

ApplyUpdates applies the given updates to workflow files

func (*DefaultUpdateManager) CreateUpdate

func (m *DefaultUpdateManager) CreateUpdate(ctx context.Context, file string, action ActionReference, latestVersion string, commitHash string) (*Update, error)

CreateUpdate creates an update for a given action and its latest version

func (*DefaultUpdateManager) PreserveComments

func (m *DefaultUpdateManager) PreserveComments(action ActionReference) []string

PreserveComments preserves existing comments when updating an action

type DefaultVersionChecker

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

DefaultVersionChecker implements the VersionChecker interface using GitHub API

func NewDefaultVersionChecker

func NewDefaultVersionChecker(token string) *DefaultVersionChecker

NewDefaultVersionChecker creates a new DefaultVersionChecker instance

func (*DefaultVersionChecker) GetCommitHash

func (c *DefaultVersionChecker) GetCommitHash(ctx context.Context, action ActionReference, version string) (string, error)

GetCommitHash returns the commit hash for a specific version of an action

func (*DefaultVersionChecker) GetLatestVersion

func (c *DefaultVersionChecker) GetLatestVersion(ctx context.Context, action ActionReference) (string, string, error)

GetLatestVersion returns the latest version and its commit hash for a given action

func (*DefaultVersionChecker) IsUpdateAvailable

func (c *DefaultVersionChecker) IsUpdateAvailable(ctx context.Context, action ActionReference) (bool, string, string, error)

IsUpdateAvailable checks if a newer version is available

type PRCreator

type PRCreator interface {
	// CreatePR creates a pull request with the given updates
	CreatePR(ctx context.Context, updates []*Update) error
}

PRCreator creates pull requests for GitHub Action updates

type Scanner

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

Scanner handles scanning and parsing of workflow files

func NewScanner

func NewScanner(baseDir string) *Scanner

NewScanner creates a new Scanner instance

func (*Scanner) ParseActionReferences

func (s *Scanner) ParseActionReferences(path string) ([]ActionReference, error)

ParseActionReferences extracts action references from a workflow file

func (*Scanner) ScanWorkflows

func (s *Scanner) ScanWorkflows(dir string) ([]string, error)

ScanWorkflows finds all GitHub Actions workflow files in the repository

func (*Scanner) SetRateLimit

func (s *Scanner) SetRateLimit(limit int, duration time.Duration)

SetRateLimit configures the rate limiting for the scanner

type Update

type Update struct {
	Action          ActionReference
	OldVersion      string
	NewVersion      string
	OldHash         string
	NewHash         string
	FilePath        string
	LineNumber      int
	Description     string
	Comments        []string // Preserved comments
	VersionComment  string   // New version comment
	OriginalVersion string   // For tracking version history
}

Update represents a pending update for a GitHub Action

type UpdateManager

type UpdateManager interface {
	// CreateUpdate creates an update for a given action and its latest version
	// Now includes commit hash and preserves comments
	CreateUpdate(ctx context.Context, file string, action ActionReference, latestVersion string, commitHash string) (*Update, error)

	// ApplyUpdates applies the given updates to workflow files
	// Now handles comment preservation and hash updates
	ApplyUpdates(ctx context.Context, updates []*Update) error

	// PreserveComments preserves existing comments when updating an action
	PreserveComments(action ActionReference) []string
}

UpdateManager manages the process of updating GitHub Actions

type VersionChecker

type VersionChecker interface {
	// GetLatestVersion returns the latest version and its commit hash for a given action
	GetLatestVersion(ctx context.Context, action ActionReference) (version string, hash string, err error)

	// IsUpdateAvailable checks if a newer version is available
	// Returns: available, new version, new hash, error
	IsUpdateAvailable(ctx context.Context, action ActionReference) (bool, string, string, error)

	// GetCommitHash returns the commit hash for a specific version of an action
	GetCommitHash(ctx context.Context, action ActionReference, version string) (string, error)
}

VersionChecker checks for newer versions of GitHub Actions

Jump to

Keyboard shortcuts

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