update

package
v0.0.0-...-73a212e Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2018 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Locked               = "locked"
	NotIncluded          = "not included"
	Excluded             = "excluded"
	DifferentImage       = "a different image"
	NotInCluster         = "not running 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"
)
View Source
const (
	ResourceSpecAll = ResourceSpec("<all>")
	ImageSpecLatest = ImageSpec("<all latest>")
)
View Source
const (
	Images     = "image"
	Policy     = "policy"
	Auto       = "auto"
	Sync       = "sync"
	Containers = "containers"
)
View Source
const UserAutomated = "<automated>"

Variables

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

Functions

func NewStageTimer

func NewStageTimer(stage string) *metrics.Timer

func ObserveRelease

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

func PrintResults

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

Types

type Automated

type Automated struct {
	Changes []Change
}

func (*Automated) Add

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

func (*Automated) CalculateRelease

func (a *Automated) CalculateRelease(rc ReleaseContext, logger log.Logger) ([]*ControllerUpdate, Result, error)

func (*Automated) CommitMessage

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

func (*Automated) ReleaseKind

func (a *Automated) ReleaseKind() ReleaseKind

func (*Automated) ReleaseType

func (a *Automated) ReleaseType() ReleaseType

type Cause

type Cause struct {
	Message string
	User    string
}

How did this update get triggered?

type Change

type Change struct {
	ServiceID flux.ResourceID
	Container resource.Container
	ImageID   image.Ref
}

type ContainerSpecs

type ContainerSpecs struct {
	Kind           ReleaseKind
	ContainerSpecs map[flux.ResourceID][]ContainerUpdate
	SkipMismatches bool
}

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

func (ContainerSpecs) CalculateRelease

func (s ContainerSpecs) CalculateRelease(rc ReleaseContext, logger log.Logger) ([]*ControllerUpdate, 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 (ContainerSpecs) CommitMessage

func (s ContainerSpecs) CommitMessage(result Result) string

func (ContainerSpecs) ReleaseKind

func (s ContainerSpecs) ReleaseKind() ReleaseKind

func (ContainerSpecs) ReleaseType

func (s ContainerSpecs) ReleaseType() ReleaseType

type ContainerUpdate

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

type ControllerFilter

type ControllerFilter interface {
	Filter(ControllerUpdate) ControllerResult
}

type ControllerResult

type ControllerResult struct {
	Status       ControllerUpdateStatus // 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 ControllerUpdate

type ControllerUpdate struct {
	ResourceID   flux.ResourceID
	Controller   cluster.Controller
	Resource     resource.Workload
	ManifestPath string
	Updates      []ContainerUpdate
}

func (*ControllerUpdate) Filter

func (s *ControllerUpdate) Filter(filters ...ControllerFilter) ControllerResult

type ControllerUpdateStatus

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

type ExcludeFilter

type ExcludeFilter struct {
	IDs []flux.ResourceID
}

func (*ExcludeFilter) Filter

type ImageInfos

type ImageInfos []image.Info

ImageInfos is a list of image.Info which can be filtered.

func (ImageInfos) Filter

func (ii ImageInfos) Filter(pattern policy.Pattern) ImageInfos

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

func (ImageInfos) FilterAndSort

func (ii ImageInfos) FilterAndSort(pattern policy.Pattern) SortedImageInfos

FilterAndSort is an optimized helper function to compose filtering and sorting.

func (ImageInfos) FindWithRef

func (ii ImageInfos) FindWithRef(ref image.Ref) image.Info

FindWithRef returns image.Info given an image ref. If the image cannot be found, it returns the image.Info with the ID provided.

func (ImageInfos) Sort

func (ii ImageInfos) Sort(pattern policy.Pattern) SortedImageInfos

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

type ImageRepos

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

ImageRepos contains a map of image repositories to their images

func FetchImageRepos

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) GetRepoImages

func (r ImageRepos) GetRepoImages(repo image.Name) ImageInfos

GetRepoImages returns image.Info entries for all the images in the named image repository.

type ImageSpec

type ImageSpec string

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

func ImageSpecFromRef

func ImageSpecFromRef(id image.Ref) ImageSpec

func ParseImageSpec

func ParseImageSpec(s string) (ImageSpec, error)

func (ImageSpec) AsRef

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

func (ImageSpec) String

func (s ImageSpec) String() string

type IncludeFilter

type IncludeFilter struct {
	IDs []flux.ResourceID
}

func (*IncludeFilter) Filter

type LockedFilter

type LockedFilter struct {
}

func (*LockedFilter) Filter

type ManualSync

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

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

func NewMenu

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[flux.ResourceID][]ContainerUpdate, error)

Run starts the interactive menu mode.

type ReleaseContext

type ReleaseContext interface {
	SelectServices(Result, []ControllerFilter, []ControllerFilter) ([]*ControllerUpdate, error)
	Registry() registry.Registry
}

type ReleaseKind

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

func ParseReleaseKind(s string) (ReleaseKind, error)

type ReleaseSpec

type ReleaseSpec struct {
	ServiceSpecs []ResourceSpec
	ImageSpec    ImageSpec
	Kind         ReleaseKind
	Excludes     []flux.ResourceID
	Force        bool
}

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

func (ReleaseSpec) CalculateRelease

func (s ReleaseSpec) CalculateRelease(rc ReleaseContext, logger log.Logger) ([]*ControllerUpdate, Result, error)

func (ReleaseSpec) CommitMessage

func (s ReleaseSpec) CommitMessage(result Result) string

func (ReleaseSpec) ReleaseKind

func (s ReleaseSpec) ReleaseKind() ReleaseKind

func (ReleaseSpec) ReleaseType

func (s ReleaseSpec) ReleaseType() ReleaseType

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

type ReleaseType

type ReleaseType string

type ResourceSpec

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

func MakeResourceSpec

func MakeResourceSpec(id flux.ResourceID) ResourceSpec

func ParseResourceSpec

func ParseResourceSpec(s string) (ResourceSpec, error)

func (ResourceSpec) AsID

func (s ResourceSpec) AsID() (flux.ResourceID, error)

func (ResourceSpec) String

func (s ResourceSpec) String() string

type Result

type Result map[flux.ResourceID]ControllerResult

func (Result) AffectedResources

func (r Result) AffectedResources() flux.ResourceIDs

func (Result) ChangedImages

func (r Result) ChangedImages() []string

func (Result) Error

func (r Result) Error() string

Error returns the error for this release (if any)

func (Result) ServiceIDs

func (r Result) ServiceIDs() []string

type SortedImageInfos

type SortedImageInfos []image.Info

SortedImageInfos is a list of sorted image.Info

func (SortedImageInfos) Filter

func (is SortedImageInfos) Filter(pattern policy.Pattern) SortedImageInfos

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

func (SortedImageInfos) Latest

func (is 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.

func (SortedImageInfos) Sort

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

type Spec

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

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

type SpecificImageFilter

type SpecificImageFilter struct {
	Img image.Ref
}

func (*SpecificImageFilter) Filter

Jump to

Keyboard shortcuts

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