Documentation
¶
Index ¶
- func DefaultHeuristic(text string) [][]int
- type Annotation
- func (annotation *Annotation) AsYamlObject() map[string]interface{}
- func (named *Annotation) Data() map[string]interface{}
- func (annotation *Annotation) Image() string
- func (annotation *Annotation) Name() string
- func (annotation *Annotation) SetImage(image string)
- func (annotation *Annotation) String() string
- type Container
- type Heuristic
- type InitContainer
- func (named *InitContainer) AsYamlObject() map[string]interface{}
- func (named *InitContainer) Data() map[string]interface{}
- func (named *InitContainer) Image() string
- func (named *InitContainer) Name() string
- func (named *InitContainer) SetImage(image string)
- func (container *InitContainer) String() string
- type NamedPullSpec
- type OperatorCSV
- func (csv *OperatorCSV) Dump(writer io.Writer) error
- func (csv *OperatorCSV) GetPullSpecs() ([]*imagename.ImageName, error)
- func (csv *OperatorCSV) HasRelatedImageEnvs() bool
- func (csv *OperatorCSV) HasRelatedImages() bool
- func (csv *OperatorCSV) ReplacePullSpecs(replacement map[imagename.ImageName]imagename.ImageName) error
- func (csv *OperatorCSV) ReplacePullSpecsEverywhere(replacement map[imagename.ImageName]imagename.ImageName) error
- func (csv *OperatorCSV) SetRelatedImages() error
- func (csv *OperatorCSV) ToYaml() ([]byte, error)
- type RelatedImage
- func (named *RelatedImage) AsYamlObject() map[string]interface{}
- func (named *RelatedImage) Data() map[string]interface{}
- func (named *RelatedImage) Image() string
- func (named *RelatedImage) Name() string
- func (named *RelatedImage) SetImage(image string)
- func (relatedImage *RelatedImage) String() string
- type RelatedImageEnv
- func (relatedImageEnv *RelatedImageEnv) AsYamlObject() map[string]interface{}
- func (named *RelatedImageEnv) Data() map[string]interface{}
- func (named *RelatedImageEnv) Image() string
- func (relatedImageEnv *RelatedImageEnv) Name() string
- func (named *RelatedImageEnv) SetImage(image string)
- func (relatedImageEnv *RelatedImageEnv) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultHeuristic ¶
DefaultHeuristic attempts to find all pullspecs in arbitrary structured/unstructured text. Returns a list of (start, end) tuples such that:
text[start:end] == <n-th pullspec in text> for all (start, end)
The basic idea: - Find continuous sequences of characters that might appear in a pullspec
- That being <alphanumeric> + "/-._@:"
- For each such sequence:
- Strip non-alphanumeric characters from both ends
- Match remainder against the pullspec regex
Put simply, this heuristic should find anything in the form:
registry/namespace*/repo:tag registry/namespace*/repo@sha256:digest
Where registry must contain at least one '.' and all parts follow various restrictions on the format (most typical pullspecs should be caught). Any number of namespaces, including 0, is valid. NOTE: Pullspecs without a tag (implicitly :latest) will not be caught. This would produce way too many false positives (and 1 false positive is already too many). :param text: Arbitrary blob of text in which to find pullspecs :return: Slice of []int{start, end} tuples of substring indices
Types ¶
type Annotation ¶
type Annotation struct {
// contains filtered or unexported fields
}
Annotation is a pullspec representing images in the annotation field of kubernetes objects.
func NewAnnotation ¶
func NewAnnotation(data map[string]interface{}, key string, startI, endI int) *Annotation
NewAnnotation returns a new annotation pullspec.
func (*Annotation) AsYamlObject ¶
func (annotation *Annotation) AsYamlObject() map[string]interface{}
AsYamlObject returns the annotation pullspec as a map[string]interface{}.
func (*Annotation) Data ¶
func (named *Annotation) Data() map[string]interface{}
Data returns the namedPullSpec as a json map
func (*Annotation) Image ¶
func (annotation *Annotation) Image() string
Image returns the image string of the pullspec.
func (*Annotation) Name ¶
func (annotation *Annotation) Name() string
Name returns the name of the pullspec.
func (*Annotation) SetImage ¶
func (annotation *Annotation) SetImage(image string)
SetImage will replace the image string with the provided image string.
func (*Annotation) String ¶
func (annotation *Annotation) String() string
String returns a string representation of the pullspec.
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container is a pullspec for containers in kubernetes resources like a pod
func NewContainer ¶
NewContainer returns a container pullspec
func (*Container) AsYamlObject ¶
func (named *Container) AsYamlObject() map[string]interface{}
AsYamlObject returns the pull spec as an object
func (*Container) Data ¶
func (named *Container) Data() map[string]interface{}
Data returns the namedPullSpec as a json map
func (*Container) Name ¶
func (named *Container) Name() string
Name returns the name of the pull spec data.
type Heuristic ¶
Heuristic takes a text and returns a matching slice of []{start, end} slices of substring indices
type InitContainer ¶
type InitContainer struct {
// contains filtered or unexported fields
}
InitContainer is a pull spec representing init containers in kubernetes objects.
func NewInitContainer ¶
func NewInitContainer(data interface{}) (*InitContainer, error)
NewInitContainer returns a new init container pullspec.
func (*InitContainer) AsYamlObject ¶
func (named *InitContainer) AsYamlObject() map[string]interface{}
AsYamlObject returns the pull spec as an object
func (*InitContainer) Data ¶
func (named *InitContainer) Data() map[string]interface{}
Data returns the namedPullSpec as a json map
func (*InitContainer) Image ¶
func (named *InitContainer) Image() string
Image returns the image string.
func (*InitContainer) Name ¶
func (named *InitContainer) Name() string
Name returns the name of the pull spec data.
func (*InitContainer) SetImage ¶
func (named *InitContainer) SetImage(image string)
SetImage will override the image of the pull spec
func (*InitContainer) String ¶
func (container *InitContainer) String() string
String returns a string representation of the pullspec.
type NamedPullSpec ¶
type NamedPullSpec interface { fmt.Stringer Name() string Image() string Data() map[string]interface{} SetImage(string) AsYamlObject() map[string]interface{} }
NamedPullSpec is an interface that allows for some elements of a pull spec to be generalized.
type OperatorCSV ¶
type OperatorCSV struct {
// contains filtered or unexported fields
}
OperatorCSV represents the CSV data and holds information regarding how to parse the image strings.
func FromDirectory ¶
func FromDirectory(path string, pullSpecHeuristic Heuristic) ([]*OperatorCSV, error)
FromDirectory creates a NewOperatorCSV from the directory path provided.
func NewOperatorCSV ¶
func NewOperatorCSV(path string, data *unstructured.Unstructured, pullSpecHeuristic Heuristic) (*OperatorCSV, error)
NewOperatorCSV creates a OperatorCSV using the data provided via an unstructured kubernetes object.
func NewOperatorCSVFromFile ¶
func NewOperatorCSVFromFile( path string, pullSpecHeuristic Heuristic, ) (*OperatorCSV, error)
NewOperatorCSVFromFile creates a NewOperatorCSV from a filepath.
func (*OperatorCSV) Dump ¶
func (csv *OperatorCSV) Dump(writer io.Writer) error
Dump will dump the csv yaml to a writer if provided or the file the OperatorCSV started from if the filesystem is writable.
func (*OperatorCSV) GetPullSpecs ¶
func (csv *OperatorCSV) GetPullSpecs() ([]*imagename.ImageName, error)
GetPullSpecs will return a list of all the images found in via pullspecs.
func (*OperatorCSV) HasRelatedImageEnvs ¶
func (csv *OperatorCSV) HasRelatedImageEnvs() bool
HasRelatedImageEnvs returns true with the CSV has RelatedImageEnv pullspecs.
func (*OperatorCSV) HasRelatedImages ¶
func (csv *OperatorCSV) HasRelatedImages() bool
HasRelatedImages returns true with the CSV has RelatedImage pullspecs.
func (*OperatorCSV) ReplacePullSpecs ¶
func (csv *OperatorCSV) ReplacePullSpecs(replacement map[imagename.ImageName]imagename.ImageName) error
ReplacePullSpecs will replace each pullspec found with the provide image.
func (*OperatorCSV) ReplacePullSpecsEverywhere ¶
func (csv *OperatorCSV) ReplacePullSpecsEverywhere(replacement map[imagename.ImageName]imagename.ImageName) error
ReplacePullSpecsEverywhere will replace image values in each pullspec throughout the entire OperatorCSV.
func (*OperatorCSV) SetRelatedImages ¶
func (csv *OperatorCSV) SetRelatedImages() error
SetRelatedImages will set the related images fields based on the CSV pullspecs discovered.
func (*OperatorCSV) ToYaml ¶
func (csv *OperatorCSV) ToYaml() ([]byte, error)
ToYaml will write the OperatorCSV to yaml string and return the bytes.
type RelatedImage ¶
type RelatedImage struct {
// contains filtered or unexported fields
}
RelatedImage is a pullspec representing the CSV relatedImage field.
func NewRelatedImage ¶
func NewRelatedImage(data interface{}) (*RelatedImage, error)
NewRelatedImage returns a new related image pullspec.
func (*RelatedImage) AsYamlObject ¶
func (named *RelatedImage) AsYamlObject() map[string]interface{}
AsYamlObject returns the pull spec as an object
func (*RelatedImage) Data ¶
func (named *RelatedImage) Data() map[string]interface{}
Data returns the namedPullSpec as a json map
func (*RelatedImage) Image ¶
func (named *RelatedImage) Image() string
Image returns the image string.
func (*RelatedImage) Name ¶
func (named *RelatedImage) Name() string
Name returns the name of the pull spec data.
func (*RelatedImage) SetImage ¶
func (named *RelatedImage) SetImage(image string)
SetImage will override the image of the pull spec
func (*RelatedImage) String ¶
func (relatedImage *RelatedImage) String() string
String returns a string representation of the pullspec.
type RelatedImageEnv ¶
type RelatedImageEnv struct {
// contains filtered or unexported fields
}
RelatedImageEnv is a pullspec representing environment variables that start with RELATED_IMAGE_.
func NewRelatedImageEnv ¶
func NewRelatedImageEnv(data map[string]interface{}) *RelatedImageEnv
NewRelatedImageEnv returns a new related iamge env pullspec.
func (*RelatedImageEnv) AsYamlObject ¶
func (relatedImageEnv *RelatedImageEnv) AsYamlObject() map[string]interface{}
AsYamlObject returns the pullspec as a map[string]interface{}.
func (*RelatedImageEnv) Data ¶
func (named *RelatedImageEnv) Data() map[string]interface{}
Data returns the namedPullSpec as a json map
func (*RelatedImageEnv) Image ¶
func (named *RelatedImageEnv) Image() string
Image returns the image string.
func (*RelatedImageEnv) Name ¶
func (relatedImageEnv *RelatedImageEnv) Name() string
Name returns the name of the related image.
func (*RelatedImageEnv) SetImage ¶
func (named *RelatedImageEnv) SetImage(image string)
SetImage will override the image of the pull spec
func (*RelatedImageEnv) String ¶
func (relatedImageEnv *RelatedImageEnv) String() string
String returns a string representation of the pullspec.