core

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionSwipe = "swipe"
	ActionSwot  = "swot"
	ActionSift  = "sift"
	ActionStun  = "stun"
	ActionShake = "shake"
	ActionKube  = "kube"
	ActionDock  = "dock"
)
View Source
const (
	PreCommitConfigFile = ".pre-commit-config.yaml"
	GitHubPrefix        = "https://github.com/"
	FilePermissions     = 0666
)

Add constants for repeated values

Variables

This section is empty.

Functions

func GetFiles

func GetFiles(dir string) ([]string, error)

func GetGithubBody

func GetGithubBody(token, url string) (interface{}, error)

GetGithubBody fetches data from GitHub API (existing function, keep as-is for compatibility)

func GetGithubBodyWithCache added in v0.1.14

func GetGithubBodyWithCache(token, url string, cache *Cache) (interface{}, error)

GetGithubBodyWithCache fetches data from GitHub API with caching support

func GetLatestRelease

func GetLatestRelease(action string, gitHubToken string) (interface{}, error)

func GetLatestTag

func GetLatestTag(action string, gitHubToken string) (interface{}, error)

func GetReleases

func GetReleases(action string, gitHubToken string, days *uint) (map[string]interface{}, error)

GetReleases fetches releases from GitHub with rate limit handling

func GetStringValue

func GetStringValue(block *hclwrite.Block, attribute string) string

func GetTerraformFiles added in v0.1.15

func GetTerraformFiles(directory string) ([]string, error)

GetTerraformFiles returns all .tf files in the entries

func GetVersion

func GetVersion(block *hclwrite.Block) string

func IsOK

func IsOK(rawURL string) (bool, error)

Types

type Cache added in v0.1.14

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

Cache handles caching of GitHub API responses

func NewCache added in v0.1.14

func NewCache(ttl time.Duration, enabled bool) (*Cache, error)

NewCache creates a new cache instance ttl is the time-to-live for cached entries (e.g., 24 hours)

func (*Cache) Clear added in v0.1.14

func (c *Cache) Clear() error

Clear removes all cached entries

func (*Cache) ClearExpired added in v0.1.14

func (c *Cache) ClearExpired() error

ClearExpired removes expired cache entries

func (*Cache) Get added in v0.1.14

func (c *Cache) Get(url string) (interface{}, bool)

Get retrieves a cached response Returns the cached data and true if found and not expired, otherwise nil and false

func (*Cache) IsEnabled added in v0.1.14

func (c *Cache) IsEnabled() bool

IsEnabled returns whether the cache is enabled

func (*Cache) Set added in v0.1.14

func (c *Cache) Set(url string, data interface{}) error

Set stores a response in the cache

func (*Cache) Stats added in v0.1.14

func (c *Cache) Stats() (int, int64, error)

Stats returns cache statistics

type CacheEntry added in v0.1.14

type CacheEntry struct {
	Data      interface{} `json:"data"`
	ExpiresAt time.Time   `json:"expires_at"`
	URL       string      `json:"url"`
}

CacheEntry represents a cached API response

type ConfigFile

type ConfigFile struct {
	DefaultLanguageVersion struct {
		Python string `yaml:"python"`
	} `yaml:"default_language_version"`
	Repos []Repo `yaml:"repos"`
}

type Flags

type Flags struct {
	// Existing fields
	DryRun          bool
	Update          bool
	File            string
	Directory       string
	GitHubToken     string
	Stable          *uint
	Entries         []string // For tracking entries
	Days            *uint    // Days parameter
	ContinueOnError bool     // Continue on error flag

	// New cache fields
	Cache        *Cache
	CacheEnabled bool
	CacheTTL     time.Duration
}

Flags represents command-line flags and configuration

func NewFlags added in v0.1.14

func NewFlags() *Flags

NewFlags creates a new Flags instance with default cache settings

func (*Flags) Action

func (myFlags *Flags) Action(action string) error

func (*Flags) GetComposeFiles added in v0.1.19

func (myFlags *Flags) GetComposeFiles() []string

GetComposeFiles returns all Docker Compose files from the scanned entries.

func (*Flags) GetDockerfiles added in v0.1.19

func (myFlags *Flags) GetDockerfiles() []string

GetDockerfiles returns all Dockerfile paths from the scanned entries.

func (*Flags) GetGHA

func (myFlags *Flags) GetGHA() []string

GetGHA gets all the actions in a directory

func (*Flags) GetGithubHash

func (myFlags *Flags) GetGithubHash(newModule string, tag string) (string, error)

func (*Flags) GetGithubLatestHash

func (myFlags *Flags) GetGithubLatestHash(newModule string) (string, string, error)

func (*Flags) GetGitlabFiles added in v0.1.15

func (myFlags *Flags) GetGitlabFiles() []string

GetGitlabFiles finds GitLab CI files in the entries

func (*Flags) GetHook

func (myFlags *Flags) GetHook() (*string, error)

func (*Flags) GetKubeFiles added in v0.1.18

func (myFlags *Flags) GetKubeFiles() []string

GetKubeFiles returns all Kubernetes manifest files from the scanned entries.

func (*Flags) GetProviderFiles added in v0.1.15

func (myFlags *Flags) GetProviderFiles() ([]string, error)

GetProviderFiles finds Terraform files that likely contain provider definitions

func (*Flags) GetTF

func (myFlags *Flags) GetTF() ([]string, error)

func (*Flags) GetType

func (myFlags *Flags) GetType(module string) (string, error)

func (*Flags) InitializeCache added in v0.1.14

func (f *Flags) InitializeCache() error

InitializeCache initializes the cache based on flags

func (*Flags) ListProvidersInDirectory added in v0.1.15

func (myFlags *Flags) ListProvidersInDirectory() ([]ProviderInfo, error)

ListProvidersInDirectory lists all providers found in Terraform files

func (*Flags) UpdateCompose added in v0.1.19

func (myFlags *Flags) UpdateCompose(file string) error

UpdateCompose pins image references in a Docker Compose file to SHA digests.

func (*Flags) UpdateDockerfile added in v0.1.19

func (myFlags *Flags) UpdateDockerfile(file string) error

UpdateDockerfile pins FROM image references in a single Dockerfile to SHA digests. Output format: FROM image:tag@sha256:digest (valid Docker syntax, tag preserved inline).

func (*Flags) UpdateDockerfiles added in v0.1.19

func (myFlags *Flags) UpdateDockerfiles() error

UpdateDockerfiles pins FROM image references in all Dockerfiles found in the entries.

func (*Flags) UpdateGHA

func (myFlags *Flags) UpdateGHA(file string) error

UpdateGHA updates am action with latest dependencies

func (*Flags) UpdateGHAS

func (myFlags *Flags) UpdateGHAS() error

func (*Flags) UpdateGithubSource

func (myFlags *Flags) UpdateGithubSource(version string, newModule string) (string, string, error)

func (*Flags) UpdateGitlab added in v0.1.15

func (myFlags *Flags) UpdateGitlab() error

func (*Flags) UpdateHooks

func (myFlags *Flags) UpdateHooks() error

func (*Flags) UpdateKube added in v0.1.18

func (myFlags *Flags) UpdateKube(file string) error

UpdateKube pins container image references in a single Kubernetes manifest file.

func (*Flags) UpdateKubes added in v0.1.18

func (myFlags *Flags) UpdateKubes() error

UpdateKubes pins all Kubernetes manifests and Docker Compose files found in the scanned entries.

func (*Flags) UpdateModule

func (myFlags *Flags) UpdateModule(file string) error

func (*Flags) UpdateModules

func (myFlags *Flags) UpdateModules() error

func (*Flags) UpdateProvider added in v0.1.15

func (myFlags *Flags) UpdateProvider(file string) error

UpdateProvider updates providers in a single Terraform file

func (*Flags) UpdateProviders added in v0.1.15

func (myFlags *Flags) UpdateProviders() error

UpdateProviders updates all Terraform providers in the directory

func (*Flags) UpdateSource

func (myFlags *Flags) UpdateSource(module string, moduleType string, version string) (string, string, error)

func (*Flags) WithSubDir

func (myFlags *Flags) WithSubDir(version string, newModule string, subdir string) (string, string, error)

type Hook

type Hook struct {
	ID                      string   `yaml:"id"`
	Name                    string   `yaml:"name,omitempty"`
	Entry                   string   `yaml:"entry,omitempty"`
	Language                string   `yaml:"language,omitempty"`
	Files                   string   `yaml:"files,omitempty"`
	Exclude                 string   `yaml:"exclude,omitempty"`
	Types                   []string `yaml:"types,omitempty"`
	TypesOr                 []string `yaml:"types_or,omitempty"`
	ExcludeTypes            []string `yaml:"exclude_types,omitempty"`
	AlwaysRun               *bool    `yaml:"always_run,omitempty"`
	FailFast                *bool    `yaml:"fail_fast,omitempty"`
	Verbose                 *bool    `yaml:"verbose,omitempty"`
	PassFilenames           *bool    `yaml:"pass_filenames,omitempty"`
	RequireSerial           *bool    `yaml:"require_serial,omitempty"`
	Description             string   `yaml:"description,omitempty"`
	LanguageVersion         string   `yaml:"language_version,omitempty"`
	MinimumPrecommitVersion string   `yaml:"minimum_pre_commit_version,omitempty"`
	Args                    []string `yaml:"args,omitempty"`
	Stages                  []string `yaml:"stages,omitempty"`
}

type ImageReference added in v0.1.15

type ImageReference struct {
	Registry   string
	Repository string
	Tag        string
	Digest     string
	Original   string
}

ImageReference represents a container image reference

type ProviderInfo added in v0.1.15

type ProviderInfo struct {
	Name           string
	Source         string
	Namespace      string
	Type           string
	CurrentVersion string
	LatestVersion  string
}

ProviderInfo holds information about a provider

type ProviderVersion added in v0.1.15

type ProviderVersion struct {
	Version   string   `json:"version"`
	Protocols []string `json:"protocols"`
	Platforms []struct {
		OS   string `json:"os"`
		Arch string `json:"arch"`
	} `json:"platforms"`
}

ProviderVersion represents a Terraform provider version from the registry

type ProviderVersionsResponse added in v0.1.15

type ProviderVersionsResponse struct {
	Versions []ProviderVersion `json:"versions"`
}

ProviderVersionsResponse represents the API response from Terraform Registry

type RateLimitError added in v0.1.14

type RateLimitError struct {
	ResetTime time.Time
	Remaining int
}

RateLimitError represents a rate limit error

func (*RateLimitError) Error added in v0.1.14

func (e *RateLimitError) Error() string

type Registry

type Registry struct {
	Registry      bool
	LatestVersion string
}

func (*Registry) GetLatest

func (myRegistry *Registry) GetLatest(module string) (*string, error)

func (*Registry) IsRegistryModule

func (myRegistry *Registry) IsRegistryModule(module string) (bool, error)

type Repo

type Repo struct {
	Hooks []Hook `yaml:"hooks"`
	Repo  string `yaml:"repo"`
	Rev   string `yaml:"rev,omitempty"`
}

type URLFormatError added in v0.1.10

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

func (URLFormatError) Error added in v0.1.10

func (e URLFormatError) Error() string

Jump to

Keyboard shortcuts

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