Documentation ¶
Overview ¶
Package app defines reference objects used to generate OpenShift API objects
Index ¶
- Constants
- Variables
- func AllContainerPorts(containers ...corev1.Container) []corev1.ContainerPort
- func CloneAndCheckoutSources(repo git.Repository, remote, ref, localDir, contextDir string) (string, error)
- func ContainerPortsFromString(portString string) ([]corev1.ContainerPort, error)
- func GenerateSecret(n int) string
- func GenerateService(meta metav1.ObjectMeta, selector map[string]string) *corev1.Service
- func IsBuilderImage(image *dockerv10.DockerImage) bool
- func IsBuilderMatch(match *ComponentMatch) bool
- func IsBuilderStreamTag(stream *imagev1.ImageStream, tag string) bool
- func IsComponentReference(s string) error
- func IsDirectory(name string) (bool, error)
- func IsParameterizableValue(s string) bool
- func IsPossibleTemplateFile(value string) (bool, error)
- func IsRemoteRepository(s string) (bool, error)
- func JoinEnvironment(a, b []corev1.EnvVar) (out []corev1.EnvVar)
- func LabelsFromSpec(spec []string) (map[string]string, []string, error)
- func MakeSimpleName(name string) string
- func StrategyAndSourceForRepository(repo *SourceRepository, image *ImageRef) (*BuildStrategyRef, *SourceRef, error)
- func UniqueContainerToServicePorts(ports []corev1.ContainerPort) []corev1.ServicePort
- type Acceptor
- func NewAcceptBuildConfigs(typer runtime.ObjectTyper) Acceptor
- func NewAcceptFirst() Acceptor
- func NewAcceptNonExistentImageStream(typer runtime.ObjectTyper, getter imagev1typedclient.ImageV1Interface, ...) Acceptor
- func NewAcceptNonExistentImageStreamTag(typer runtime.ObjectTyper, getter imagev1typedclient.ImageV1Interface, ...) Acceptor
- func NewAcceptUnique(typer runtime.ObjectTyper) Acceptor
- type Acceptors
- type BuildRef
- type BuildStrategyRef
- type CircularOutputReferenceError
- type CircularReferenceError
- type ComponentInput
- type ComponentMatch
- type ComponentMatches
- type ComponentReference
- type ComponentReferences
- func (r ComponentReferences) Group() (refs []ComponentReferences)
- func (r ComponentReferences) HasSource() bool
- func (r ComponentReferences) HumanString(separator string) string
- func (r ComponentReferences) ImageComponentRefs() (refs ComponentReferences)
- func (r ComponentReferences) InstallableComponentRefs() (refs ComponentReferences)
- func (r ComponentReferences) NeedsSource() (refs ComponentReferences)
- func (components ComponentReferences) Resolve() error
- func (components ComponentReferences) Search() error
- func (r ComponentReferences) String() string
- func (r ComponentReferences) TemplateComponentRefs() (refs ComponentReferences)
- func (r ComponentReferences) UseSource() (refs ComponentReferences)
- type DeploymentConfigRef
- type DeploymentHook
- type Detector
- type DockerClient
- type DockerClientSearcher
- type DockerRegistrySearcher
- type Dockerfile
- type Environment
- func LoadEnvironmentFile(filename string, stdin io.Reader) (Environment, error)
- func NewEnvironment(envs ...map[string]string) Environment
- func ParseAndCombineEnvironment(envs []string, filenames []string, stdin io.Reader, ...) (Environment, error)
- func ParseEnvironment(vals ...string) (Environment, []string, []error)
- func ParseEnvironmentAllowEmpty(vals ...string) Environment
- type ErrMultipleMatches
- type ErrNoMatch
- type ErrNoTagsFound
- type ErrPartialMatch
- type FirstMatchResolver
- type Generated
- type GeneratorInput
- type GeneratorJobReference
- type GroupedComponentReferences
- type HighestScoreResolver
- type HighestUniqueScoreResolver
- type ImageImportSearcher
- type ImageRef
- func (r *ImageRef) BuildOutput() (*buildv1.BuildOutput, error)
- func (r *ImageRef) BuildTriggers() []buildv1.BuildTriggerPolicy
- func (r *ImageRef) DeployableContainer() (container *corev1.Container, triggers []appsv1.DeploymentTriggerPolicy, ...)
- func (r *ImageRef) Exists() bool
- func (r *ImageRef) ImageStream() (*imagev1.ImageStream, error)
- func (r *ImageRef) ImageStreamTag() (*imagev1.ImageStreamTag, error)
- func (r *ImageRef) InstallablePod(generatorInput GeneratorInput, secretAccessor SecretAccessor, ...) (*corev1.Pod, *corev1.Secret, error)
- func (r *ImageRef) InternalTag() string
- func (r *ImageRef) ObjectReference() corev1.ObjectReference
- func (r *ImageRef) PullSpec() string
- func (r *ImageRef) RepoName() string
- func (r *ImageRef) SuggestName() (string, bool)
- func (r *ImageRef) SuggestNamespace() string
- type ImageRefGenerator
- type ImageStreamByAnnotationSearcher
- type ImageStreamSearcher
- type MissingImageSearcher
- type MultiSimpleSearcher
- type MultiWeightedSearcher
- type NameSuggester
- type NameSuggestions
- type Objects
- type PerfectMatchWeightedResolver
- type Pipeline
- type PipelineBuilder
- type PipelineGroup
- type PipelineResolver
- type ReferenceBuilder
- func (r *ReferenceBuilder) AddComponents(inputs []string, fn func(*ComponentInput) ComponentReference) ComponentReferences
- func (r *ReferenceBuilder) AddExistingSourceRepository(source *SourceRepository)
- func (r *ReferenceBuilder) AddGroups(inputs []string)
- func (r *ReferenceBuilder) AddSourceRepository(input string, strategy newapp.Strategy) (*SourceRepository, bool)
- func (r *ReferenceBuilder) Result() (ComponentReferences, SourceRepositories, []error)
- type Resolver
- type ScoredComponentMatches
- type Searcher
- type SecretAccessor
- type SourceLanguageType
- type SourceRef
- type SourceRepositories
- type SourceRepository
- func NewBinarySourceRepository(strategy newapp.Strategy) *SourceRepository
- func NewImageSourceRepository(compRef ComponentReference, from, to string) *SourceRepository
- func NewSourceRepository(s string, strategy newapp.Strategy) (*SourceRepository, error)
- func NewSourceRepositoryForDockerfile(contents string) (*SourceRepository, error)
- func NewSourceRepositoryWithDockerfile(s, dockerfilePath string) (*SourceRepository, error)
- func (r *SourceRepository) AddBuildConfigMaps(configMaps []string) error
- func (r *SourceRepository) AddBuildSecrets(secrets []string) error
- func (r *SourceRepository) AddDockerfile(contents string) error
- func (r *SourceRepository) ConfigMaps() []buildv1.ConfigMapBuildSource
- func (r *SourceRepository) ContextDir() string
- func (r *SourceRepository) Detect(d Detector, dockerStrategy bool) error
- func (r *SourceRepository) DetectAuth() error
- func (r *SourceRepository) GetStrategy() newapp.Strategy
- func (r *SourceRepository) InUse() bool
- func (r *SourceRepository) Info() *SourceRepositoryInfo
- func (r *SourceRepository) LocalPath() (string, error)
- func (r *SourceRepository) Remote() bool
- func (r *SourceRepository) RemoteURL() (*s2igit.URL, bool, error)
- func (r *SourceRepository) Secrets() []buildv1.SecretBuildSource
- func (r *SourceRepository) SetContextDir(dir string)
- func (r *SourceRepository) SetInfo(info *SourceRepositoryInfo)
- func (r *SourceRepository) SetSourceImage(c ComponentReference)
- func (r *SourceRepository) SetSourceImagePath(source, dest string)
- func (r *SourceRepository) SetStrategy(strategy newapp.Strategy)
- func (r *SourceRepository) String() string
- func (r *SourceRepository) UsedBy(ref ComponentReference)
- type SourceRepositoryEnumerator
- type SourceRepositoryInfo
- type TemplateFileSearcher
- type TemplateSearcher
- type TokenInput
- type UniqueExactOrInexactMatchResolver
- type UniqueNameGenerator
- type WeightedResolver
- type WeightedSearcher
Constants ¶
const (
GenerationWarningAnnotation = "app.generate.openshift.io/warnings"
)
Variables ¶
var ErrNameRequired = fmt.Errorf("you must specify a name for your app")
ErrNameRequired is the error returned by new-app when a name cannot be suggested and the user needs to provide one explicitly.
Functions ¶
func AllContainerPorts ¶
func AllContainerPorts(containers ...corev1.Container) []corev1.ContainerPort
AllContainerPorts creates a sorted list of all ports in all provided containers.
func CloneAndCheckoutSources ¶
func CloneAndCheckoutSources(repo git.Repository, remote, ref, localDir, contextDir string) (string, error)
CloneAndCheckoutSources clones the remote repository using either regular git clone operation or shallow git clone, based on the "ref" provided (you cannot shallow clone using the 'ref'). This function will return the full path to the buildable sources, including the context directory if specified.
func ContainerPortsFromString ¶
func ContainerPortsFromString(portString string) ([]corev1.ContainerPort, error)
ContainerPortsFromString extracts sets of port specifications from a comma-delimited string. Each segment must be a single port number (container port) or a colon delimited pair of ports (container port and host port).
func GenerateSecret ¶
GenerateSecret generates a random secret string
func GenerateService ¶
func IsBuilderImage ¶
func IsBuilderImage(image *dockerv10.DockerImage) bool
IsBuilderImage checks whether the provided Docker image is a builder image or not
func IsBuilderMatch ¶
func IsBuilderMatch(match *ComponentMatch) bool
func IsBuilderStreamTag ¶
func IsBuilderStreamTag(stream *imagev1.ImageStream, tag string) bool
IsBuilderStreamTag checks whether the provided image stream tag is a builder image or not
func IsComponentReference ¶
IsComponentReference returns an error if the provided string does not appear to be a reference to a source repository on disk, at a URL, a docker image name (which might be on a Docker registry or an OpenShift image stream), or a template.
func IsDirectory ¶
IsDirectory returns true if the passed-in argument is a directory in the filesystem
func IsParameterizableValue ¶
IsParameterizableValue returns true if the value contains standard replacement syntax, to preserve the value for use inside of the generated output. Passing parameters into output is only valid if the output is used inside of a template.
func IsPossibleTemplateFile ¶
IsPossibleTemplateFile returns true if the argument can be a template file
func IsRemoteRepository ¶
IsRemoteRepository checks whether the provided string is a remote repository or not
func JoinEnvironment ¶
JoinEnvironment joins two different sets of environment variables into one, leaving out all the duplicates
func LabelsFromSpec ¶
LabelsFromSpec turns a set of specs NAME=VALUE or NAME- into a map of labels, a remove label list, or an error.
func MakeSimpleName ¶
MakeSimpleName strips any non-alphanumeric characters out of a string and returns either an empty string or a string which is valid for most Kubernetes resources.
func StrategyAndSourceForRepository ¶
func StrategyAndSourceForRepository(repo *SourceRepository, image *ImageRef) (*BuildStrategyRef, *SourceRef, error)
StrategyAndSourceForRepository returns the build strategy and source code reference of the provided source repository TODO: user should be able to choose whether to download a remote source ref for more info
func UniqueContainerToServicePorts ¶
func UniqueContainerToServicePorts(ports []corev1.ContainerPort) []corev1.ServicePort
UniqueContainerToServicePorts creates one service port for each unique container port.
Types ¶
type Acceptor ¶
type Acceptor interface {
Accept(from interface{}) bool
}
Acceptor is an interface for accepting objects.
var AcceptAll Acceptor = acceptAll{}
AcceptAll accepts all objects.
var AcceptNew Acceptor = acceptNew{}
AcceptNew only accepts runtime.Objects with an empty resource version.
func NewAcceptBuildConfigs ¶
func NewAcceptBuildConfigs(typer runtime.ObjectTyper) Acceptor
NewAcceptBuildConfigs creates an acceptor accepting BuildConfig objects and ImageStreams objects.
func NewAcceptNonExistentImageStream ¶
func NewAcceptNonExistentImageStream(typer runtime.ObjectTyper, getter imagev1typedclient.ImageV1Interface, namespace string) Acceptor
NewAcceptNonExistentImageStream creates an acceptor that accepts an object if it is either a) not an ImageStream, or b) an ImageStream which does not yet exist in the api server
func NewAcceptNonExistentImageStreamTag ¶
func NewAcceptNonExistentImageStreamTag(typer runtime.ObjectTyper, getter imagev1typedclient.ImageV1Interface, namespace string) Acceptor
NewAcceptNonExistentImageStreamTag creates an acceptor that accepts an object if it is either a) not an ImageStreamTag, or b) an ImageStreamTag which does not yet exist in the api server
func NewAcceptUnique ¶
func NewAcceptUnique(typer runtime.ObjectTyper) Acceptor
NewAcceptUnique creates an acceptor that only accepts unique objects by kind and name.
type Acceptors ¶
type Acceptors []Acceptor
Acceptors is a list of acceptors that behave like a single acceptor. All acceptors must accept an object for it to be accepted.
type BuildRef ¶
type BuildRef struct { Source *SourceRef Input *ImageRef Strategy *BuildStrategyRef DockerStrategyOptions *buildv1.DockerStrategyOptions Output *ImageRef Env Environment Binary bool }
BuildRef is a reference to a build configuration
func (*BuildRef) BuildConfig ¶
func (r *BuildRef) BuildConfig() (*buildv1.BuildConfig, error)
BuildConfig creates a buildConfig resource from the build configuration reference
type BuildStrategyRef ¶
BuildStrategyRef is a reference to a build strategy
func (*BuildStrategyRef) BuildStrategy ¶
func (s *BuildStrategyRef) BuildStrategy(env Environment, dockerStrategyOptions *buildv1.DockerStrategyOptions) (*buildv1.BuildStrategy, []buildv1.BuildTriggerPolicy)
BuildStrategy builds an OpenShift BuildStrategy from a BuildStrategyRef
type CircularOutputReferenceError ¶
type CircularOutputReferenceError struct {
Reference string
}
CircularOutputReferenceError is the error returned by new-app when the input and output image stream tags are identical.
func (CircularOutputReferenceError) Error ¶
func (e CircularOutputReferenceError) Error() string
type CircularReferenceError ¶
type CircularReferenceError struct {
Reference string
}
CircularReferenceError is the error returned by new-app when either the input or output image stream tags employ circular loops
func (CircularReferenceError) Error ¶
func (e CircularReferenceError) Error() string
type ComponentInput ¶
type ComponentInput struct { GroupID int From string Argument string Value string ExpectToBuild bool ScratchImage bool Uses *SourceRepository ResolvedMatch *ComponentMatch SearchMatches ComponentMatches Resolver Searcher }
ComponentInput is the necessary input for creating a component
func NewComponentInput ¶
func NewComponentInput(input string) (*ComponentInput, string, error)
NewComponentInput returns a new ComponentInput by checking for image using [image]~ (to indicate builder) or [image]~[code] (builder plus code)
func (*ComponentInput) Input ¶
func (i *ComponentInput) Input() *ComponentInput
Input returns the component input
func (*ComponentInput) NeedsSource ¶
func (i *ComponentInput) NeedsSource() bool
NeedsSource indicates if the component input needs source code
func (*ComponentInput) Resolve ¶
func (i *ComponentInput) Resolve() error
Resolve sets the unique match in input
func (*ComponentInput) Search ¶
func (i *ComponentInput) Search() error
Search sets the search matches in input
func (*ComponentInput) String ¶
func (i *ComponentInput) String() string
func (*ComponentInput) Use ¶
func (i *ComponentInput) Use(repo *SourceRepository)
Use adds the provided source repository as the used one by the component input
type ComponentMatch ¶
type ComponentMatch struct { // what this is a match for (the value that was searched on) Value string // the argument to use to specify this match explicitly Argument string // the exact name of this match Name string Description string Score float32 Insecure bool LocalOnly bool NoTagsFound bool // this match represents a scratch image, there is no // actual image/pullspec. Virtual bool // The source of the match. Generally only a single source is // available. DockerImage *dockerv10.DockerImage ImageStream *imagev1.ImageStream ImageTag string Template *templatev1.Template // Input to generators extracted from the source Builder bool GeneratorInput GeneratorInput // TODO: remove me Meta map[string]string }
ComponentMatch is a match to a provided component
func (*ComponentMatch) Exact ¶
func (m *ComponentMatch) Exact() bool
Exact checks if the ComponentMatch is an exact match
func (*ComponentMatch) IsImage ¶
func (m *ComponentMatch) IsImage() bool
IsImage returns whether or not the component match is an image or image stream
func (*ComponentMatch) IsTemplate ¶
func (m *ComponentMatch) IsTemplate() bool
IsTemplate returns whether or not the component match is a template
func (*ComponentMatch) String ¶
func (m *ComponentMatch) String() string
type ComponentMatches ¶
type ComponentMatches []*ComponentMatch
ComponentMatches holds multiple ComponentMatch
func (ComponentMatches) Exact ¶
func (m ComponentMatches) Exact() ComponentMatches
Exact returns all ComponentMatch that are an exact match
func (ComponentMatches) Inexact ¶
func (m ComponentMatches) Inexact() ComponentMatches
Inexact returns all ComponentMatch that are not an exact match
type ComponentReference ¶
type ComponentReference interface { // Input contains the input of the component Input() *ComponentInput // Resolve sets the match in input Resolve() error // Search sets the search matches in input Search() error // NeedsSource indicates if the component needs source code NeedsSource() bool }
ComponentReference defines an interface for components
type ComponentReferences ¶
type ComponentReferences []ComponentReference
ComponentReferences is a set of components
func (ComponentReferences) Group ¶
func (r ComponentReferences) Group() (refs []ComponentReferences)
Group groups components based on their group ids
func (ComponentReferences) HasSource ¶
func (r ComponentReferences) HasSource() bool
HasSource returns true if there is more than one component that has a repo associated
func (ComponentReferences) HumanString ¶
func (r ComponentReferences) HumanString(separator string) string
func (ComponentReferences) ImageComponentRefs ¶
func (r ComponentReferences) ImageComponentRefs() (refs ComponentReferences)
ImageComponentRefs returns the list of component references to images
func (ComponentReferences) InstallableComponentRefs ¶
func (r ComponentReferences) InstallableComponentRefs() (refs ComponentReferences)
InstallableComponentRefs returns the list of component references to templates
func (ComponentReferences) NeedsSource ¶
func (r ComponentReferences) NeedsSource() (refs ComponentReferences)
NeedsSource returns all the components that need source code in order to build
func (ComponentReferences) Resolve ¶
func (components ComponentReferences) Resolve() error
Resolve the references to ensure they are all valid, and identify any images that don't match user input.
func (ComponentReferences) Search ¶
func (components ComponentReferences) Search() error
Search searches on all references
func (ComponentReferences) String ¶
func (r ComponentReferences) String() string
func (ComponentReferences) TemplateComponentRefs ¶
func (r ComponentReferences) TemplateComponentRefs() (refs ComponentReferences)
TemplateComponentRefs returns the list of component references to templates
func (ComponentReferences) UseSource ¶
func (r ComponentReferences) UseSource() (refs ComponentReferences)
UseSource returns all the components that use source repositories
type DeploymentConfigRef ¶
type DeploymentConfigRef struct { Name string Images []*ImageRef Env Environment Labels map[string]string AsTest bool PostHook *DeploymentHook }
DeploymentConfigRef is a reference to a deployment configuration
func (*DeploymentConfigRef) DeploymentConfig ¶
func (r *DeploymentConfigRef) DeploymentConfig() (*appsv1.DeploymentConfig, error)
DeploymentConfig creates a deploymentConfig resource from the deployment configuration reference
TODO: take a pod template spec as argument
type DeploymentHook ¶
type DeploymentHook struct {
Shell string
}
type Detector ¶
type Detector interface {
Detect(dir string, dockerStrategy bool) (*SourceRepositoryInfo, error)
}
Detector is an interface for detecting information about a source repository
type DockerClient ¶
type DockerClient interface { ListImages(opts docker.ListImagesOptions) ([]docker.APIImages, error) InspectImage(name string) (*docker.Image, error) }
DockerClient is the local interface for the docker client
type DockerClientSearcher ¶
type DockerClientSearcher struct { Client DockerClient // Optional, will delegate resolution to the registry if no local // exact matches are found. RegistrySearcher Searcher // Insecure, if true will add an annotation to generated ImageStream // so that the image can be pulled properly Insecure bool // AllowingMissingImages will allow images that could not be found in the local or // remote registry to be used anyway. AllowMissingImages bool }
DockerClientSearcher finds local docker images locally that match a search value
func (DockerClientSearcher) Search ¶
func (r DockerClientSearcher) Search(precise bool, terms ...string) (ComponentMatches, []error)
Search searches all images in local docker server for images that match terms
func (DockerClientSearcher) Type ¶
func (r DockerClientSearcher) Type() string
type DockerRegistrySearcher ¶
type DockerRegistrySearcher struct { Client dockerregistry.Client AllowInsecure bool }
DockerRegistrySearcher searches for images in a given docker registry. Notice that it only matches exact searches - so a search for "rub" will not return images with the name "ruby". TODO: replace ImageByTag to allow partial matches
func (DockerRegistrySearcher) Search ¶
func (r DockerRegistrySearcher) Search(precise bool, terms ...string) (ComponentMatches, []error)
Search searches in the Docker registry for images that match terms
func (DockerRegistrySearcher) Type ¶
func (r DockerRegistrySearcher) Type() string
type Dockerfile ¶
func NewDockerfile ¶
func NewDockerfile(contents string) (Dockerfile, error)
func NewDockerfileFromFile ¶
func NewDockerfileFromFile(path string) (Dockerfile, error)
type Environment ¶
Environment holds environment variables for new-app
func LoadEnvironmentFile ¶
func LoadEnvironmentFile(filename string, stdin io.Reader) (Environment, error)
LoadEnvironmentFile accepts filename of a file containing key=value pairs and puts these pairs into a map. If filename is "-" the file contents are read from the stdin argument, provided it is not nil.
func NewEnvironment ¶
func NewEnvironment(envs ...map[string]string) Environment
NewEnvironment returns a new set of environment variables based on all the provided environment variables
func ParseAndCombineEnvironment ¶
func ParseAndCombineEnvironment(envs []string, filenames []string, stdin io.Reader, dupfn func(string, string) error) (Environment, error)
ParseAndCombineEnvironment parses key=value records from slice of strings (typically obtained from the command line) and from given files and combines them into single map. Key=value pairs from the envs slice have precedence over those read from file.
The dupfn function is called for all duplicate keys that encountered. If the function returns an error this error is returned by ParseAndCombineEnvironment.
If a file is "-" the file contents will be read from argument stdin (unless it's nil).
func ParseEnvironment ¶
func ParseEnvironment(vals ...string) (Environment, []string, []error)
ParseEnvironment takes a slice of strings in key=value format and transforms them into a map. List of duplicate keys is returned in the second return value.
func ParseEnvironmentAllowEmpty ¶
func ParseEnvironmentAllowEmpty(vals ...string) Environment
ParseEnvironmentAllowEmpty converts the provided strings in key=value form into environment entries. In case there's no equals sign in a string, it's considered as a key with empty value.
func (Environment) Add ¶
func (e Environment) Add(envs ...map[string]string)
Add adds the environment variables to the current environment
func (Environment) AddIfNotPresent ¶
func (e Environment) AddIfNotPresent(more Environment) []string
AddIfNotPresent adds the environment variables to the current environment. In case of key conflict the old value is kept. Conflicting keys are returned as a slice.
func (Environment) List ¶
func (e Environment) List() []corev1.EnvVar
List sorts and returns all the environment variables
type ErrMultipleMatches ¶
type ErrMultipleMatches struct { Value string Matches []*ComponentMatch Errs []error }
ErrMultipleMatches is the error returned to new-app users when multiple matches are found for a given component.
func (ErrMultipleMatches) Error ¶
func (e ErrMultipleMatches) Error() string
type ErrNoMatch ¶
ErrNoMatch is the error returned by new-app when no match is found for a given component.
func (ErrNoMatch) Error ¶
func (e ErrNoMatch) Error() string
func (ErrNoMatch) Suggestion ¶
func (e ErrNoMatch) Suggestion(commandName string) string
Suggestion is the usage error message returned when no match is found.
type ErrNoTagsFound ¶
type ErrNoTagsFound struct { Value string Match *ComponentMatch Errs []error }
ErrNoTagsFound is returned when a matching image stream has no tags associated with it
func (ErrNoTagsFound) Error ¶
func (e ErrNoTagsFound) Error() string
func (ErrNoTagsFound) Suggestion ¶
func (e ErrNoTagsFound) Suggestion(commandName string) string
Suggestion is the usage error message returned when no tags are found on matching image stream
type ErrPartialMatch ¶
type ErrPartialMatch struct { Value string Match *ComponentMatch Errs []error }
ErrPartialMatch is the error returned to new-app users when the best match available is only a partial match for a given component.
func (ErrPartialMatch) Error ¶
func (e ErrPartialMatch) Error() string
func (ErrPartialMatch) Suggestion ¶
func (e ErrPartialMatch) Suggestion(commandName string) string
Suggestion is the usage error message returned when only a partial match is found.
type FirstMatchResolver ¶
type FirstMatchResolver struct {
Searcher Searcher
}
FirstMatchResolver simply takes the first search result returned by the searcher it holds and resolves it to that match. An ErrMultipleMatches will never happen given it will just take the first result, but a ErrNoMatch can happen if the searcher returns no matches.
func (FirstMatchResolver) Resolve ¶
func (r FirstMatchResolver) Resolve(value string) (*ComponentMatch, error)
Resolve resolves as the first match returned by the Searcher
type GeneratorInput ¶
type GeneratorInput struct { Job bool Token *TokenInput }
func GeneratorInputFromMatch ¶
func GeneratorInputFromMatch(match *ComponentMatch) (GeneratorInput, error)
GeneratorInputFromMatch attempts to extract a GeneratorInput struct from the provided match. If errors occur, a partial GeneratorInput may be returned along an error.
type GeneratorJobReference ¶
type GeneratorJobReference struct { Ref ComponentReference Input GeneratorInput Err error }
GeneratorJobReference is a reference that should be treated as a job execution, not a direct app creation.
type GroupedComponentReferences ¶
type GroupedComponentReferences ComponentReferences
GroupedComponentReferences is a set of components that can be grouped by their group id
func (GroupedComponentReferences) Len ¶
func (m GroupedComponentReferences) Len() int
func (GroupedComponentReferences) Less ¶
func (m GroupedComponentReferences) Less(i, j int) bool
func (GroupedComponentReferences) Swap ¶
func (m GroupedComponentReferences) Swap(i, j int)
type HighestScoreResolver ¶
type HighestScoreResolver struct {
Searcher Searcher
}
HighestScoreResolver takes search result returned by the searcher it holds and resolves it to the highest scored match present. An ErrMultipleMatches will never happen given it will just take the best scored result, but a ErrNoMatch can happen if the searcher returns no matches.
func (HighestScoreResolver) Resolve ¶
func (r HighestScoreResolver) Resolve(value string) (*ComponentMatch, error)
Resolve resolves as the first highest scored match returned by the Searcher
type HighestUniqueScoreResolver ¶
type HighestUniqueScoreResolver struct {
Searcher Searcher
}
HighestUniqueScoreResolver takes search result returned by the searcher it holds and resolves it to the highest scored match present. If more than one match exists with that same score, returns an ErrMultipleMatches. A ErrNoMatch can happen if the searcher returns no matches.
func (HighestUniqueScoreResolver) Resolve ¶
func (r HighestUniqueScoreResolver) Resolve(value string) (*ComponentMatch, error)
Resolve resolves as the highest scored match returned by the Searcher, and guarantees the match is unique (the only match with that given score)
type ImageImportSearcher ¶
type ImageImportSearcher struct { Client imagev1client.ImageStreamImportInterface AllowInsecure bool Fallback Searcher }
func (ImageImportSearcher) Search ¶
func (s ImageImportSearcher) Search(precise bool, terms ...string) (ComponentMatches, []error)
Search invokes the new ImageStreamImport API to have the server look up Docker images for the user, using secrets stored on the server.
func (ImageImportSearcher) Type ¶
func (s ImageImportSearcher) Type() string
type ImageRef ¶
type ImageRef struct { Reference imageapi.DockerImageReference // If specified, a more specific location the image is available at ResolvedReference *imageapi.DockerImageReference AsResolvedImage bool AsImageStream bool OutputImage bool Insecure bool HasEmptyDir bool // TagDirectly will create the image stream using a tag for this reference, not a bulk // import. TagDirectly bool // Tag defines tag that other components will reference this image by if set. Must be // set with TagDirectly (otherwise tag remapping is not possible). Tag string // InternalDefaultTag is the default tag for other components that reference this image InternalDefaultTag string // Env represents a set of additional environment to add to this image. Env Environment // ObjectName overrides the name of the ImageStream produced // but does not affect the DockerImageReference ObjectName string // ContainerFn overrides normal container generation with a custom function. ContainerFn func(*corev1.Container) // Stream and Info should *only* be set if the image stream already exists Stream *imagev1.ImageStream Info *dockerv10.DockerImage }
ImageRef is a reference to an image
func InputImageFromMatch ¶
func InputImageFromMatch(match *ComponentMatch) (*ImageRef, error)
InputImageFromMatch returns an image reference from a component match. The component match will either be an image stream or an image.
func (*ImageRef) BuildOutput ¶
func (r *ImageRef) BuildOutput() (*buildv1.BuildOutput, error)
BuildOutput returns the BuildOutput of an image reference
func (*ImageRef) BuildTriggers ¶
func (r *ImageRef) BuildTriggers() []buildv1.BuildTriggerPolicy
BuildTriggers sets up build triggers for the base image
func (*ImageRef) DeployableContainer ¶
func (r *ImageRef) DeployableContainer() (container *corev1.Container, triggers []appsv1.DeploymentTriggerPolicy, err error)
DeployableContainer sets up a container for the image ready for deployment
func (*ImageRef) ImageStream ¶
func (r *ImageRef) ImageStream() (*imagev1.ImageStream, error)
ImageStream returns an ImageStream from an image reference
func (*ImageRef) ImageStreamTag ¶
func (r *ImageRef) ImageStreamTag() (*imagev1.ImageStreamTag, error)
ImageStreamTag returns an ImageStreamTag from an image reference
func (*ImageRef) InstallablePod ¶
func (r *ImageRef) InstallablePod(generatorInput GeneratorInput, secretAccessor SecretAccessor, serviceAccountName string) (*corev1.Pod, *corev1.Secret, error)
func (*ImageRef) InternalTag ¶
func (*ImageRef) ObjectReference ¶
func (r *ImageRef) ObjectReference() corev1.ObjectReference
ObjectReference returns an object reference to this ref (as it would exist during generation)
func (*ImageRef) SuggestName ¶
SuggestName suggests a name for an image reference
func (*ImageRef) SuggestNamespace ¶
SuggestNamespace suggests a namespace for an image reference
type ImageRefGenerator ¶
type ImageRefGenerator interface { FromName(name string) (*ImageRef, error) FromNameAndPorts(name string, ports []string) (*ImageRef, error) FromStream(repo *imagev1.ImageStream, tag string) (*ImageRef, error) FromDockerfile(name string, dir string, context string) (*ImageRef, error) }
ImageRefGenerator is an interface for generating ImageRefs
Generators for ImageRef - Name -> ImageRef - ImageRepo + tag -> ImageRef
func NewImageRefGenerator ¶
func NewImageRefGenerator() ImageRefGenerator
NewImageRefGenerator creates a new ImageRefGenerator
type ImageStreamByAnnotationSearcher ¶
type ImageStreamByAnnotationSearcher struct { Client imagev1typedclient.ImageStreamsGetter ImageStreamImages imagev1typedclient.ImageStreamImagesGetter Namespaces []string // contains filtered or unexported fields }
ImageStreamByAnnotationSearcher searches for image streams based on 'supports' annotations found in tagged images belonging to the stream
func (*ImageStreamByAnnotationSearcher) Search ¶
func (r *ImageStreamByAnnotationSearcher) Search(precise bool, terms ...string) (ComponentMatches, []error)
Search finds image stream images using their 'supports' annotation
func (*ImageStreamByAnnotationSearcher) Type ¶
func (r *ImageStreamByAnnotationSearcher) Type() string
type ImageStreamSearcher ¶
type ImageStreamSearcher struct { Client imagev1typedclient.ImageV1Interface Namespaces []string AllowMissingTags bool }
ImageStreamSearcher searches the openshift server image streams for images matching a particular name
func (ImageStreamSearcher) Search ¶
func (r ImageStreamSearcher) Search(precise bool, terms ...string) (ComponentMatches, []error)
Search will attempt to find imagestreams with names that match the passed in value
func (ImageStreamSearcher) Type ¶
func (r ImageStreamSearcher) Type() string
type MissingImageSearcher ¶
type MissingImageSearcher struct { }
MissingImageSearcher always returns an exact match for the item being searched for. It should be used with very high weight(weak priority) as a result of last resort when the user has indicated they want to allow missing images(not found in the docker registry or locally) to be used anyway.
func (MissingImageSearcher) Search ¶
func (r MissingImageSearcher) Search(precise bool, terms ...string) (ComponentMatches, []error)
Search always returns an exact match for the search terms.
func (MissingImageSearcher) Type ¶
func (r MissingImageSearcher) Type() string
type MultiSimpleSearcher ¶
type MultiSimpleSearcher []Searcher
MultiSimpleSearcher is a set of searchers
func (MultiSimpleSearcher) Search ¶
func (s MultiSimpleSearcher) Search(precise bool, terms ...string) (ComponentMatches, []error)
Search searches using all searchers it holds
func (MultiSimpleSearcher) Type ¶
func (s MultiSimpleSearcher) Type() string
type MultiWeightedSearcher ¶
type MultiWeightedSearcher []WeightedSearcher
MultiWeightedSearcher is a set of weighted searchers where lower weight has higher priority in search results
func (MultiWeightedSearcher) Search ¶
func (s MultiWeightedSearcher) Search(precise bool, terms ...string) (ComponentMatches, []error)
Search searches using all searchers it holds and score according to searcher height
func (MultiWeightedSearcher) Type ¶
func (s MultiWeightedSearcher) Type() string
type NameSuggester ¶
NameSuggester is an object that can suggest a name for itself
type NameSuggestions ¶
type NameSuggestions []NameSuggester
NameSuggestions suggests names from a collection of NameSuggesters
func (NameSuggestions) SuggestName ¶
func (s NameSuggestions) SuggestName() (string, bool)
SuggestName suggests a name given a collection of NameSuggesters
type Objects ¶
Objects is a set of runtime objects.
func AddServices ¶
AddServices sets up services for the provided objects.
type PerfectMatchWeightedResolver ¶
type PerfectMatchWeightedResolver []WeightedResolver
PerfectMatchWeightedResolver returns only matches from resolvers that are identified as exact (weight 0.0), and only matches from those resolvers that qualify as exact (score = 0.0). If no perfect matches exist, an ErrMultipleMatches is returned indicating the remaining candidate(s). Note that this method may resolve ErrMultipleMatches with a single match, indicating an error (no perfect match) but with only one candidate.
func (PerfectMatchWeightedResolver) Resolve ¶
func (r PerfectMatchWeightedResolver) Resolve(value string) (*ComponentMatch, error)
Resolve resolves the provided input and returns only exact matches
type Pipeline ¶
type Pipeline struct { Name string From string InputImage *ImageRef Build *BuildRef Image *ImageRef Deployment *DeploymentConfigRef Labels map[string]string }
Pipeline holds components.
func (*Pipeline) NeedsDeployment ¶
NeedsDeployment sets the pipeline for deployment.
type PipelineBuilder ¶
type PipelineBuilder interface { To(string) PipelineBuilder NewBuildPipeline(string, *ImageRef, *SourceRepository, bool) (*Pipeline, error) NewImagePipeline(string, *ImageRef) (*Pipeline, error) }
A PipelineBuilder creates Pipeline instances.
func NewPipelineBuilder ¶
func NewPipelineBuilder(name string, environment Environment, dockerStrategyOptions *buildv1.DockerStrategyOptions, outputDocker bool) PipelineBuilder
NewPipelineBuilder returns a PipelineBuilder using name as a base name. A PipelineBuilder always creates pipelines with unique names, so that the actual name of a pipeline (Pipeline.Name) might differ from the base name. The pipelines created with a PipelineBuilder will have access to the given environment. The boolean outputDocker controls whether builds will output to an image stream tag or docker image reference.
type PipelineGroup ¶
type PipelineGroup []*Pipeline
PipelineGroup is a group of Pipelines.
func (PipelineGroup) Reduce ¶
func (g PipelineGroup) Reduce() error
Reduce squashes all common components from the pipelines.
func (PipelineGroup) String ¶
func (g PipelineGroup) String() string
type PipelineResolver ¶
type PipelineResolver struct { }
PipelineResolver returns a dummy ComponentMatch for any value input. It is used to provide a dummy component for for the pipeline/Jenkinsfile strategy.
func (PipelineResolver) Resolve ¶
func (r PipelineResolver) Resolve(value string) (*ComponentMatch, error)
Resolve returns a dummy ComponentMatch for any value input.
type ReferenceBuilder ¶
type ReferenceBuilder struct {
// contains filtered or unexported fields
}
ReferenceBuilder is used for building all the necessary object references for an application
func (*ReferenceBuilder) AddComponents ¶
func (r *ReferenceBuilder) AddComponents(inputs []string, fn func(*ComponentInput) ComponentReference) ComponentReferences
AddComponents turns all provided component inputs into component references
func (*ReferenceBuilder) AddExistingSourceRepository ¶
func (r *ReferenceBuilder) AddExistingSourceRepository(source *SourceRepository)
func (*ReferenceBuilder) AddGroups ¶
func (r *ReferenceBuilder) AddGroups(inputs []string)
AddGroups adds group ids to groups of components
func (*ReferenceBuilder) AddSourceRepository ¶
func (r *ReferenceBuilder) AddSourceRepository(input string, strategy newapp.Strategy) (*SourceRepository, bool)
AddSourceRepository resolves the input to an actual source repository
func (*ReferenceBuilder) Result ¶
func (r *ReferenceBuilder) Result() (ComponentReferences, SourceRepositories, []error)
Result returns the result of the config conversion to object references
type Resolver ¶
type Resolver interface {
Resolve(value string) (*ComponentMatch, error)
}
Resolver is an interface for resolving provided input to component matches. A Resolver should return ErrMultipleMatches when more than one result can be constructed as a match. It should also set the score to 0.0 if this is a perfect match, and to higher values the less adequate the match is.
type ScoredComponentMatches ¶
type ScoredComponentMatches []*ComponentMatch
ScoredComponentMatches is a set of component matches grouped by score
func (ScoredComponentMatches) Exact ¶
func (m ScoredComponentMatches) Exact() []*ComponentMatch
Exact returns all the exact component matches
func (ScoredComponentMatches) Len ¶
func (m ScoredComponentMatches) Len() int
func (ScoredComponentMatches) Less ¶
func (m ScoredComponentMatches) Less(i, j int) bool
func (ScoredComponentMatches) Swap ¶
func (m ScoredComponentMatches) Swap(i, j int)
type Searcher ¶
type Searcher interface { Search(precise bool, terms ...string) (ComponentMatches, []error) Type() string }
Searcher is responsible for performing a search based on the given terms and return all results found as component matches. The component match score can be used to determine how precise a given match is, where 0.0 is an exact match. All errors encountered during search should be returned. The precise flag is a hint to the searchers that they may stop searching when they hit their first exact set of matches
func NewImageStreamByAnnotationSearcher ¶
func NewImageStreamByAnnotationSearcher(streamClient imagev1typedclient.ImageStreamsGetter, imageClient imagev1typedclient.ImageStreamImagesGetter, namespaces []string) Searcher
NewImageStreamByAnnotationSearcher creates a new ImageStreamByAnnotationSearcher
type SecretAccessor ¶
SecretAccessor is an interface for retrieving secrets from the calling context.
type SourceLanguageType ¶
SourceLanguageType contains info about the type of the language a source repository is built in
func (*SourceLanguageType) Term ¶
func (t *SourceLanguageType) Term() string
Term returns a search term for the given source language type the term will be in the form of language:version
type SourceRef ¶
type SourceRef struct { URL *s2igit.URL Dir string Name string ContextDir string Secrets []buildv1.SecretBuildSource ConfigMaps []buildv1.ConfigMapBuildSource SourceImage *ImageRef ImageSourcePath string ImageDestPath string DockerfileContents string Binary bool RequiresAuth bool }
SourceRef is a reference to a build source
func (*SourceRef) BuildSource ¶
func (r *SourceRef) BuildSource() (*buildv1.BuildSource, []buildv1.BuildTriggerPolicy)
BuildSource returns an OpenShift BuildSource from the SourceRef
func (*SourceRef) SuggestName ¶
SuggestName returns a name derived from the source URL
type SourceRepositories ¶
type SourceRepositories []*SourceRepository
SourceRepositories is a list of SourceRepository objects
func (SourceRepositories) NotUsed ¶
func (rr SourceRepositories) NotUsed() SourceRepositories
NotUsed returns the list of SourceRepositories that are not used
func (SourceRepositories) String ¶
func (rr SourceRepositories) String() string
type SourceRepository ¶
type SourceRepository struct {
// contains filtered or unexported fields
}
SourceRepository represents a code repository that may be the target of a build.
func NewBinarySourceRepository ¶
func NewBinarySourceRepository(strategy newapp.Strategy) *SourceRepository
NewBinarySourceRepository creates a source repository that is configured for binary input.
func NewImageSourceRepository ¶
func NewImageSourceRepository(compRef ComponentReference, from, to string) *SourceRepository
TODO: this doesn't really match the others - this should likely be a different type of object that is associated with a build or component.
func NewSourceRepository ¶
func NewSourceRepository(s string, strategy newapp.Strategy) (*SourceRepository, error)
NewSourceRepository creates a reference to a local or remote source code repository from a URL or path.
func NewSourceRepositoryForDockerfile ¶
func NewSourceRepositoryForDockerfile(contents string) (*SourceRepository, error)
NewSourceRepositoryForDockerfile creates a source repository that is set up to use the contents of a Dockerfile as the input of the build.
func NewSourceRepositoryWithDockerfile ¶
func NewSourceRepositoryWithDockerfile(s, dockerfilePath string) (*SourceRepository, error)
NewSourceRepositoryWithDockerfile creates a reference to a local source code repository with the provided relative Dockerfile path (defaults to "Dockerfile").
func (*SourceRepository) AddBuildConfigMaps ¶
func (r *SourceRepository) AddBuildConfigMaps(configMaps []string) error
AddBuildConfigMaps adds the defined configMaps into the build. The input format for the secrets is "<secretName>:<destinationDir>". The destinationDir is optional and when not specified the default is the current working directory.
func (*SourceRepository) AddBuildSecrets ¶
func (r *SourceRepository) AddBuildSecrets(secrets []string) error
AddBuildSecrets adds the defined secrets into a build. The input format for the secrets is "<secretName>:<destinationDir>". The destinationDir is optional and when not specified the default is the current working directory.
func (*SourceRepository) AddDockerfile ¶
func (r *SourceRepository) AddDockerfile(contents string) error
AddDockerfile adds the Dockerfile contents to the SourceRepository and configure it to build with Docker strategy. Returns an error if the contents are invalid.
func (*SourceRepository) ConfigMaps ¶
func (r *SourceRepository) ConfigMaps() []buildv1.ConfigMapBuildSource
ConfigMaps returns the configMap build sources
func (*SourceRepository) ContextDir ¶
func (r *SourceRepository) ContextDir() string
ContextDir returns the context directory of the source repository
func (*SourceRepository) Detect ¶
func (r *SourceRepository) Detect(d Detector, dockerStrategy bool) error
Detect clones source locally if not already local and runs code detection with the given detector.
func (*SourceRepository) DetectAuth ¶
func (r *SourceRepository) DetectAuth() error
DetectAuth returns an error if the source repository cannot be cloned without the current user's environment. The following changes are made to the environment:
- The HOME directory is set to a temporary dir to avoid loading any settings in .gitconfig
- The GIT_SSH variable is set to /dev/null so the regular SSH keys are not used (changing the HOME directory is not enough).
- GIT_CONFIG_NOSYSTEM prevents git from loading system-wide config
- GIT_ASKPASS to prevent git from prompting for a user/password
func (*SourceRepository) GetStrategy ¶
func (r *SourceRepository) GetStrategy() newapp.Strategy
GetStrategy returns the source repository strategy
func (*SourceRepository) InUse ¶
func (r *SourceRepository) InUse() bool
InUse checks if the source repository is in use
func (*SourceRepository) Info ¶
func (r *SourceRepository) Info() *SourceRepositoryInfo
Info returns the source repository info generated on code detection
func (*SourceRepository) LocalPath ¶
func (r *SourceRepository) LocalPath() (string, error)
LocalPath returns the local path of the source repository
func (*SourceRepository) Remote ¶
func (r *SourceRepository) Remote() bool
Remote checks whether the source repository is remote
func (*SourceRepository) RemoteURL ¶
func (r *SourceRepository) RemoteURL() (*s2igit.URL, bool, error)
RemoteURL returns the remote URL of the source repository
func (*SourceRepository) Secrets ¶
func (r *SourceRepository) Secrets() []buildv1.SecretBuildSource
Secrets returns the secret build sources
func (*SourceRepository) SetContextDir ¶
func (r *SourceRepository) SetContextDir(dir string)
SetContextDir sets the context directory to use for the source repository
func (*SourceRepository) SetInfo ¶
func (r *SourceRepository) SetInfo(info *SourceRepositoryInfo)
SetInfo sets the source repository info. This is to facilitate certain tests.
func (*SourceRepository) SetSourceImage ¶
func (r *SourceRepository) SetSourceImage(c ComponentReference)
SetSourceImage sets the source(input) image for a repository
func (*SourceRepository) SetSourceImagePath ¶
func (r *SourceRepository) SetSourceImagePath(source, dest string)
SetSourceImagePath sets the source/destination to use when copying from the SourceImage
func (*SourceRepository) SetStrategy ¶
func (r *SourceRepository) SetStrategy(strategy newapp.Strategy)
SetStrategy sets the source repository strategy
func (*SourceRepository) String ¶
func (r *SourceRepository) String() string
func (*SourceRepository) UsedBy ¶
func (r *SourceRepository) UsedBy(ref ComponentReference)
UsedBy sets up which component uses the source repository
type SourceRepositoryEnumerator ¶
type SourceRepositoryEnumerator struct { Detectors source.Detectors DockerfileTester newapp.Tester JenkinsfileTester newapp.Tester }
SourceRepositoryEnumerator implements the Detector interface
func (SourceRepositoryEnumerator) Detect ¶
func (e SourceRepositoryEnumerator) Detect(dir string, noSourceDetection bool) (*SourceRepositoryInfo, error)
Detect extracts source code information about the provided source repository
type SourceRepositoryInfo ¶
type SourceRepositoryInfo struct { Path string Types []SourceLanguageType Dockerfile Dockerfile Jenkinsfile bool }
SourceRepositoryInfo contains info about a source repository
func (*SourceRepositoryInfo) Terms ¶
func (info *SourceRepositoryInfo) Terms() []string
Terms returns which languages the source repository was built with
type TemplateFileSearcher ¶
TemplateFileSearcher resolves template files into template objects
func (*TemplateFileSearcher) Search ¶
func (r *TemplateFileSearcher) Search(precise bool, terms ...string) (ComponentMatches, []error)
Search attempts to read template files and transform it into template objects
func (*TemplateFileSearcher) Type ¶
func (r *TemplateFileSearcher) Type() string
type TemplateSearcher ¶
type TemplateSearcher struct { Client templatev1typedclient.TemplatesGetter Namespaces []string StopOnExactMatch bool }
TemplateSearcher resolves stored template arguments into template objects
func (TemplateSearcher) Search ¶
func (r TemplateSearcher) Search(precise bool, terms ...string) (ComponentMatches, []error)
Search searches for a template and returns matches with the object representation
func (TemplateSearcher) Type ¶
func (r TemplateSearcher) Type() string
type TokenInput ¶
type UniqueExactOrInexactMatchResolver ¶
type UniqueExactOrInexactMatchResolver struct {
Searcher Searcher
}
UniqueExactOrInexactMatchResolver takes search result returned by the searcher it holds. Returns the single exact match present, if more that one exact match is present, returns a ErrMultipleMatches. If no exact match is present, try with inexact ones, which must also be unique otherwise ErrMultipleMatches. A ErrNoMatch can happen if the searcher returns no exact or inexact matches.
func (UniqueExactOrInexactMatchResolver) Resolve ¶
func (r UniqueExactOrInexactMatchResolver) Resolve(value string) (*ComponentMatch, error)
Resolve resolves as the single exact or inexact match present.
type UniqueNameGenerator ¶
type UniqueNameGenerator interface {
Generate(NameSuggester) (string, error)
}
A UniqueNameGenerator is able to generate unique names from a given original name.
func NewUniqueNameGenerator ¶
func NewUniqueNameGenerator(name string) UniqueNameGenerator
NewUniqueNameGenerator creates a new UniqueNameGenerator with the given original name.
type WeightedResolver ¶
WeightedResolver is a resolver identified as exact or not, depending on its weight
type WeightedSearcher ¶
WeightedSearcher is a searcher identified as exact or not, depending on its weight