flux: github.com/weaveworks/flux/pkg/update Index | Files

package update

import "github.com/weaveworks/flux/pkg/update"

Index

Package Files

automated.go filter.go images.go menu.go menu_unix.go metrics.go print.go release_containers.go release_image.go result.go spec.go sync.go workload.go

Constants

const (
    Locked                 = "locked"
    Ignore                 = "ignore"
    NotIncluded            = "not included"
    Excluded               = "excluded"
    DifferentImage         = "a different image"
    NotAccessibleInCluster = "not accessible in cluster"
    NotInRepo              = "not found in repository"
    ImageNotFound          = "cannot find one or more images"
    ImageUpToDate          = "image(s) up to date"
    DoesNotUseImage        = "does not use image(s)"
    ContainerNotFound      = "container(s) not found: %s"
    ContainerTagMismatch   = "container(s) tag mismatch: %s"
)
const (
    ResourceSpecAll = ResourceSpec("<all>")
    ImageSpecLatest = ImageSpec("<all latest>")
)
const (
    Images     = "image"
    Policy     = "policy"
    Auto       = "auto"
    Sync       = "sync"
    Containers = "containers"
)
const UserAutomated = "<automated>"

Variables

var (
    ErrInvalidReleaseKind = errors.New("invalid release kind")
)

func FilterImages Uses

func FilterImages(images []image.Info, pattern policy.Pattern) []image.Info

FilterImages returns only the images that match the pattern, in a new list.

func NewStageTimer Uses

func NewStageTimer(stage string) *metrics.Timer

func ObserveRelease Uses

func ObserveRelease(start time.Time, success bool, releaseType ReleaseType, releaseKind ReleaseKind)

func PrintResults Uses

func PrintResults(out io.Writer, results Result, verbosity int)

PrintResults outputs a result set to the `io.Writer` provided, at the given level of verbosity:

- 2 = include skipped and ignored resources
- 1 = include skipped resources, exclude ignored resources
- 0 = exclude skipped and ignored resources

type Automated Uses

type Automated struct {
    Changes []Change
}

func (*Automated) Add Uses

func (a *Automated) Add(service resource.ID, container resource.Container, image image.Ref)

func (*Automated) CalculateRelease Uses

func (a *Automated) CalculateRelease(ctx context.Context, rc ReleaseContext, logger log.Logger) ([]*WorkloadUpdate, Result, error)

func (*Automated) CommitMessage Uses

func (a *Automated) CommitMessage(result Result) string

func (*Automated) ReleaseKind Uses

func (a *Automated) ReleaseKind() ReleaseKind

func (*Automated) ReleaseType Uses

func (a *Automated) ReleaseType() ReleaseType

type Cause Uses

type Cause struct {
    Message string
    User    string
}

How did this update get triggered?

type Change Uses

type Change struct {
    WorkloadID resource.ID
    Container  resource.Container
    ImageID    image.Ref
}

type ContainerUpdate Uses

type ContainerUpdate struct {
    Container string
    Current   image.Ref
    Target    image.Ref
}

type ExcludeFilter Uses

type ExcludeFilter struct {
    IDs []resource.ID
}

func (*ExcludeFilter) Filter Uses

func (f *ExcludeFilter) Filter(u WorkloadUpdate) WorkloadResult

type IgnoreFilter Uses

type IgnoreFilter struct {
}

func (*IgnoreFilter) Filter Uses

func (f *IgnoreFilter) Filter(u WorkloadUpdate) WorkloadResult

type ImageRepos Uses

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

ImageRepos contains a map of image repositories to their metadata

func FetchImageRepos Uses

func FetchImageRepos(reg registry.Registry, cs containers, logger log.Logger) (ImageRepos, error)

FetchImageRepos finds all the known image metadata for containers in the controllers given.

func (ImageRepos) GetRepositoryMetadata Uses

func (r ImageRepos) GetRepositoryMetadata(repo image.Name) image.RepositoryMetadata

GetRepositoryMetadata returns the metadata for all the images in the named image repository.

type ImageSpec Uses

type ImageSpec string

ImageSpec is an ImageID, or "<all latest>" (update all containers to the latest available).

func ImageSpecFromRef Uses

func ImageSpecFromRef(id image.Ref) ImageSpec

func ParseImageSpec Uses

func ParseImageSpec(s string) (ImageSpec, error)

func (ImageSpec) AsRef Uses

func (s ImageSpec) AsRef() (image.Ref, error)

func (ImageSpec) String Uses

func (s ImageSpec) String() string

type IncludeFilter Uses

type IncludeFilter struct {
    IDs []resource.ID
}

func (*IncludeFilter) Filter Uses

func (f *IncludeFilter) Filter(u WorkloadUpdate) WorkloadResult

type LockedFilter Uses

type LockedFilter struct {
}

func (*LockedFilter) Filter Uses

func (f *LockedFilter) Filter(u WorkloadUpdate) WorkloadResult

type ManualSync Uses

type ManualSync struct {
}
type Menu struct {
    // contains filtered or unexported fields
}

Menu presents a list of controllers which can be interacted with.

func NewMenu Uses

func NewMenu(out io.Writer, results Result, verbosity int) *Menu

NewMenu creates a menu printer that outputs a result set to the `io.Writer` provided, at the given level of verbosity:

- 2 = include skipped and ignored resources
- 1 = include skipped resources, exclude ignored resources
- 0 = exclude skipped and ignored resources

It can print a one time listing with `Print()` or then enter interactive mode with `Run()`.

func (m *Menu) AddItem(mi menuItem)
func (m *Menu) Print()
func (m *Menu) Run() (map[resource.ID][]ContainerUpdate, error)

Run starts the interactive menu mode.

type ReleaseContainersSpec Uses

type ReleaseContainersSpec struct {
    Kind           ReleaseKind
    ContainerSpecs map[resource.ID][]ContainerUpdate
    SkipMismatches bool
    Force          bool
}

ReleaseContainersSpec defines the spec for a `containers` manifest update.

func (ReleaseContainersSpec) CalculateRelease Uses

func (s ReleaseContainersSpec) CalculateRelease(ctx context.Context, rc ReleaseContext,
    logger log.Logger) ([]*WorkloadUpdate, Result, error)

CalculateRelease computes required controller updates to satisfy this specification. It returns an error if any spec calculation fails unless `SkipMismatches` is true.

func (ReleaseContainersSpec) CommitMessage Uses

func (s ReleaseContainersSpec) CommitMessage(result Result) string

func (ReleaseContainersSpec) ReleaseKind Uses

func (s ReleaseContainersSpec) ReleaseKind() ReleaseKind

func (ReleaseContainersSpec) ReleaseType Uses

func (s ReleaseContainersSpec) ReleaseType() ReleaseType

type ReleaseContext Uses

type ReleaseContext interface {
    SelectWorkloads(context.Context, Result, []WorkloadFilter, []WorkloadFilter) ([]*WorkloadUpdate, error)
    Registry() registry.Registry
}

type ReleaseImageSpec Uses

type ReleaseImageSpec struct {
    ServiceSpecs []ResourceSpec // TODO: rename to WorkloadSpecs after adding versioning
    ImageSpec    ImageSpec
    Kind         ReleaseKind
    Excludes     []resource.ID
    Force        bool
}

NB: these get sent from fluxctl, so we have to maintain the json format of this. Eugh.

func (ReleaseImageSpec) CalculateRelease Uses

func (s ReleaseImageSpec) CalculateRelease(ctx context.Context, rc ReleaseContext, logger log.Logger) ([]*WorkloadUpdate, Result, error)

func (ReleaseImageSpec) CommitMessage Uses

func (s ReleaseImageSpec) CommitMessage(result Result) string

func (ReleaseImageSpec) ReleaseKind Uses

func (s ReleaseImageSpec) ReleaseKind() ReleaseKind

func (ReleaseImageSpec) ReleaseType Uses

func (s ReleaseImageSpec) ReleaseType() ReleaseType

ReleaseType gives a one-word description of the release, mainly useful for labelling metrics or log messages.

type ReleaseKind Uses

type ReleaseKind string

ReleaseKind says whether a release is to be planned only, or planned then executed

const (
    ReleaseKindPlan    ReleaseKind = "plan"
    ReleaseKindExecute ReleaseKind = "execute"
)

func ParseReleaseKind Uses

func ParseReleaseKind(s string) (ReleaseKind, error)

type ReleaseType Uses

type ReleaseType string

type ResourceSpec Uses

type ResourceSpec string // ID or "<all>"

func MakeResourceSpec Uses

func MakeResourceSpec(id resource.ID) ResourceSpec

func ParseResourceSpec Uses

func ParseResourceSpec(s string) (ResourceSpec, error)

func (ResourceSpec) AsID Uses

func (s ResourceSpec) AsID() (resource.ID, error)

func (ResourceSpec) String Uses

func (s ResourceSpec) String() string

type Result Uses

type Result map[resource.ID]WorkloadResult

func (Result) AffectedResources Uses

func (r Result) AffectedResources() resource.IDs

func (Result) ChangedImages Uses

func (r Result) ChangedImages() []string

func (Result) Error Uses

func (r Result) Error() string

Error returns the error for this release (if any)

func (Result) WorkloadIDs Uses

func (r Result) WorkloadIDs() []string

type SortedImageInfos Uses

type SortedImageInfos []image.Info

SortedImageInfos is a list of sorted image.Info

func FilterAndSortRepositoryMetadata Uses

func FilterAndSortRepositoryMetadata(rm image.RepositoryMetadata, pattern policy.Pattern) (SortedImageInfos, error)

FilterAndSortRepositoryMetadata obtains all the image information from the metadata after filtering and sorting. Filtering happens in the metadata directly to minimize problems with tag inconsistencies (i.e. tags without matching image information)

func SortImages Uses

func SortImages(images []image.Info, pattern policy.Pattern) SortedImageInfos

SortImages orders the images according to the pattern order in a new list.

func (SortedImageInfos) Latest Uses

func (sii SortedImageInfos) Latest() (image.Info, bool)

Latest returns the latest image from SortedImageInfos. If no such image exists, returns a zero value and `false`, and the caller can decide whether that's an error or not.

type Spec Uses

type Spec struct {
    Type  string      `json:"type"`
    Cause Cause       `json:"cause"`
    Spec  interface{} `json:"spec"`
}

A tagged union for all (both) kinds of update. The type is just so we know how to decode the rest of the struct.

func (*Spec) UnmarshalJSON Uses

func (spec *Spec) UnmarshalJSON(in []byte) error

type SpecificImageFilter Uses

type SpecificImageFilter struct {
    Img image.Ref
}

func (*SpecificImageFilter) Filter Uses

func (f *SpecificImageFilter) Filter(u WorkloadUpdate) WorkloadResult

type WorkloadFilter Uses

type WorkloadFilter interface {
    Filter(WorkloadUpdate) WorkloadResult
}

type WorkloadResult Uses

type WorkloadResult struct {
    Status       WorkloadUpdateStatus // summary of what happened, e.g., "incomplete", "ignored", "success"
    Error        string               `json:",omitempty"` // error if there was one finding the service (e.g., it doesn't exist in repo)
    PerContainer []ContainerUpdate    // what happened with each container
}

type WorkloadUpdate Uses

type WorkloadUpdate struct {
    ResourceID resource.ID
    Workload   cluster.Workload
    Resource   resource.Workload
    Updates    []ContainerUpdate
}

func (*WorkloadUpdate) Filter Uses

func (s *WorkloadUpdate) Filter(filters ...WorkloadFilter) WorkloadResult

type WorkloadUpdateStatus Uses

type WorkloadUpdateStatus string
const (
    ReleaseStatusSuccess WorkloadUpdateStatus = "success"
    ReleaseStatusFailed  WorkloadUpdateStatus = "failed"
    ReleaseStatusSkipped WorkloadUpdateStatus = "skipped"
    ReleaseStatusIgnored WorkloadUpdateStatus = "ignored"
    ReleaseStatusUnknown WorkloadUpdateStatus = "unknown"
)

Package update imports 25 packages (graph). Updated 2020-10-19. Refresh now. Tools for package owners.