Documentation
¶
Index ¶
- Constants
- Variables
- func SetLogLevel(level string)
- func ShowScanResult(s *Scanner, opt *Option) error
- func ShowSummary(s SummaryTable, opt *Option) error
- type App
- type CLI
- type ClusterConfig
- type Config
- type DeletableImageIDs
- type DeleteCLI
- type GenerateCLI
- type Generator
- type ImageURI
- type Images
- type LambdaConfig
- type NopCloserWriter
- type Option
- type OutputCLI
- type PlanCLI
- type PlanOrDelete
- type Planner
- type RepoSummary
- type RepositoryConfig
- type RepositoryName
- type ScanCLI
- type Scanner
- type Summary
- type SummaryTable
- type TaskdefConfig
Constants ¶
View Source
const ( SummaryTypeImage = "Image" SummaryTypeImageIndex = "Image index" SummaryTypeSociIndex = "Soci index" )
View Source
const (
MediaTypeSociIndex = "application/vnd.amazon.soci.index.v1+json"
)
Variables ¶
View Source
var ( DefaultKeepCount = 5 DefaultExpiresStr = "30d" DefaultKeepTagPatterns = []string{"latest"} )
View Source
var LogLevelFilter = &logutils.LevelFilter{ Levels: []logutils.LogLevel{"debug", "info", "notice", "warn", "error"}, ModifierFuncs: []logutils.ModifierFunc{ nil, logutils.Color(color.FgWhite), logutils.Color(color.FgHiBlue), logutils.Color(color.FgYellow), logutils.Color(color.FgRed, color.Bold), }, Writer: os.Stderr, }
Functions ¶
func SetLogLevel ¶ added in v0.2.0
func SetLogLevel(level string)
func ShowScanResult ¶ added in v0.5.0
func ShowSummary ¶ added in v0.5.0
func ShowSummary(s SummaryTable, opt *Option) error
Types ¶
type App ¶
type App struct { Version string // contains filtered or unexported fields }
func (*App) DeleteImages ¶
func (app *App) DeleteImages(ctx context.Context, repo RepositoryName, ids []ecrTypes.ImageIdentifier, force bool) error
DeleteImages deletes images from the repository
func (*App) GenerateConfig ¶ added in v0.2.0
type CLI ¶ added in v0.5.0
type CLI struct { Config string `help:"Load configuration from FILE" short:"c" default:"ecrm.yaml" env:"ECRM_CONFIG"` LogLevel string `help:"Set log level (debug, info, notice, warn, error)" default:"info" env:"ECRM_LOG_LEVEL"` Color bool `help:"Whether or not to color the output" default:"true" env:"ECRM_COLOR" negatable:""` ShowVersion bool `help:"Show version." name:"version"` Generate *GenerateCLI `cmd:"" help:"Generate a configuration file."` Scan *ScanCLI `cmd:"" help:"Scan ECS/Lambda resources. Output image URIs in use."` Plan *PlanCLI `cmd:"" help:"Scan ECS/Lambda resources and find unused ECR images that can be deleted safely."` Delete *DeleteCLI `cmd:"" help:"Scan ECS/Lambda resources and delete unused ECR images."` Version struct{} `cmd:"" default:"1" help:"Show version."` // contains filtered or unexported fields }
func (*CLI) NewLambdaHandler ¶ added in v0.5.0
type ClusterConfig ¶
type ClusterConfig struct { Name string `yaml:"name,omitempty"` NamePattern string `yaml:"name_pattern,omitempty"` }
func (*ClusterConfig) Match ¶
func (c *ClusterConfig) Match(name string) bool
func (*ClusterConfig) Validate ¶
func (c *ClusterConfig) Validate() error
type Config ¶
type Config struct { Clusters []*ClusterConfig `yaml:"clusters"` TaskDefinitions []*TaskdefConfig `yaml:"task_definitions"` LambdaFunctions []*LambdaConfig `yaml:"lambda_functions"` Repositories []*RepositoryConfig `yaml:"repositories"` }
func LoadConfig ¶
type DeletableImageIDs ¶ added in v0.5.0
type DeletableImageIDs map[RepositoryName][]ecrTypes.ImageIdentifier
func (DeletableImageIDs) RepositoryNames ¶ added in v0.5.0
func (d DeletableImageIDs) RepositoryNames() []RepositoryName
type DeleteCLI ¶ added in v0.5.0
type DeleteCLI struct { PlanOrDelete ScannedFiles []string `help:"Files of the scan result. ecrm does not delete images in these files." env:"ECRM_SCANNED_FILES"` Force bool `help:"force delete images without confirmation" env:"ECRM_FORCE"` }
type GenerateCLI ¶ added in v0.5.0
type GenerateCLI struct { }
func (*GenerateCLI) Option ¶ added in v0.5.0
func (c *GenerateCLI) Option() *Option
type Generator ¶ added in v0.5.0
type Generator struct {
// contains filtered or unexported fields
}
func NewGenerator ¶ added in v0.5.0
type ImageURI ¶ added in v0.5.0
type ImageURI string
ImageURI represents an image URI.
func (ImageURI) IsDigestURI ¶ added in v0.5.0
func (ImageURI) IsECRImage ¶ added in v0.5.0
type LambdaConfig ¶ added in v0.1.0
type LambdaConfig struct { Name string `yaml:"name,omitempty"` NamePattern string `yaml:"name_pattern,omitempty"` KeepCount int64 `yaml:"keep_count,omitempty"` KeepAliase *bool `yaml:"keep_aliase,omitempty"` // for backward compatibility }
func (*LambdaConfig) Match ¶ added in v0.1.0
func (c *LambdaConfig) Match(name string) bool
func (*LambdaConfig) Validate ¶ added in v0.1.0
func (c *LambdaConfig) Validate() error
type NopCloserWriter ¶ added in v0.5.0
NopCloserWriter is a writer that does nothing on Close
func (NopCloserWriter) Close ¶ added in v0.5.0
func (NopCloserWriter) Close() error
type Option ¶
type Option struct { ScanOnly bool Scan bool Delete bool Force bool Repository RepositoryName OutputFile string Format outputFormat ScannedFiles []string }
func (*Option) OutputWriter ¶ added in v0.5.0
func (opt *Option) OutputWriter() (io.WriteCloser, error)
type OutputCLI ¶ added in v0.5.0
type OutputCLI struct {
Output string `help:"File name of the output. The default is STDOUT." short:"o" default:"-" env:"ECRM_OUTPUT"`
}
type PlanCLI ¶ added in v0.5.0
type PlanCLI struct {
PlanOrDelete
}
type PlanOrDelete ¶ added in v0.5.0
type PlanOrDelete struct { OutputCLI Format string `help:"Output format of plan(table, json)" default:"table" enum:"table,json" env:"ECRM_FORMAT"` Scan bool `help:"Scan ECS/Lambda resources that in use." default:"true" negatable:"" env:"ECRM_SCAN"` Repository string `help:"Manage images in the repository only." short:"r" env:"ECRM_REPOSITORY"` }
type Planner ¶ added in v0.5.0
type Planner struct {
// contains filtered or unexported fields
}
func NewPlanner ¶ added in v0.5.0
func (*Planner) Plan ¶ added in v0.5.0
func (p *Planner) Plan(ctx context.Context, rcs []*RepositoryConfig, keepImages Images, repo RepositoryName) (SummaryTable, DeletableImageIDs, error)
Plan scans repositories and find expired images, and returns a summary table and a map of deletable image identifiers.
keepImages is a set of images in use by ECS tasks / task definitions / lambda functions so that they are not deleted
type RepoSummary ¶ added in v0.4.0
type RepoSummary []*Summary
func NewRepoSummary ¶ added in v0.4.0
func NewRepoSummary(repo RepositoryName) RepoSummary
func (RepoSummary) Add ¶ added in v0.4.0
func (s RepoSummary) Add(img ecrTypes.ImageDetail)
func (RepoSummary) Expire ¶ added in v0.4.0
func (s RepoSummary) Expire(img ecrTypes.ImageDetail)
type RepositoryConfig ¶
type RepositoryConfig struct { Name RepositoryName `yaml:"name,omitempty"` NamePattern string `yaml:"name_pattern,omitempty"` Expires string `yaml:"expires,omitempty"` KeepCount int64 `yaml:"keep_count,omitempty"` KeepTagPatterns []string `yaml:"keep_tag_patterns,omitempty"` // contains filtered or unexported fields }
func (*RepositoryConfig) MatchName ¶
func (r *RepositoryConfig) MatchName(name RepositoryName) bool
func (*RepositoryConfig) MatchTag ¶
func (r *RepositoryConfig) MatchTag(tag string) bool
func (*RepositoryConfig) Validate ¶
func (r *RepositoryConfig) Validate() error
type RepositoryName ¶ added in v0.5.0
type RepositoryName string
type Scanner ¶ added in v0.5.0
type Scanner struct { Images Images // contains filtered or unexported fields }
func NewScanner ¶ added in v0.5.0
type SummaryTable ¶ added in v0.4.0
type SummaryTable []*Summary
func (*SummaryTable) Print ¶ added in v0.5.0
func (s *SummaryTable) Print(w io.Writer, format outputFormat) error
func (SummaryTable) Sort ¶ added in v0.5.0
func (s SummaryTable) Sort()
type TaskdefConfig ¶ added in v0.1.0
type TaskdefConfig struct { Name string `yaml:"name,omitempty"` NamePattern string `yaml:"name_pattern,omitempty"` KeepCount int64 `yaml:"keep_count,omitempty"` }
func (*TaskdefConfig) Match ¶ added in v0.1.0
func (c *TaskdefConfig) Match(name string) bool
func (*TaskdefConfig) Validate ¶ added in v0.1.0
func (c *TaskdefConfig) Validate() error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.