// validate converts all of the arguments on the config into references to objects, or returns an error func (c *AppConfig) validate() (app.ComponentReferences, app.SourceRepositories, cmdutil.Environment, cmdutil.Environment, error) { b := c.refBuilder c.addReferenceBuilderComponents(b) b.AddGroups(c.Groups) refs, repos, errs := b.Result() if len(repos) > 0 { repos[0].SetContextDir(c.ContextDir) if len(repos) > 1 { glog.Warningf("You have specified more than one source repository and a context directory. "+ "The context directory will be applied to the first repository: %q", repos[0]) } } if len(c.Strategy) != 0 && len(repos) == 0 { errs = append(errs, fmt.Errorf("when --strategy is specified you must provide at least one source code location")) } env, duplicateEnv, envErrs := cmdutil.ParseEnvironmentArguments(c.Environment) for _, s := range duplicateEnv { glog.V(1).Infof("The environment variable %q was overwritten", s) } errs = append(errs, envErrs...) parms, duplicateParms, parmsErrs := cmdutil.ParseEnvironmentArguments(c.TemplateParameters) for _, s := range duplicateParms { glog.V(1).Infof("The template parameter %q was overwritten", s) } errs = append(errs, parmsErrs...) return refs, repos, env, parms, errors.NewAggregate(errs) }
// validate converts all of the arguments on the config into references to objects, or returns an error func (c *AppConfig) validate() (app.ComponentReferences, app.SourceRepositories, cmdutil.Environment, cmdutil.Environment, error) { b := c.refBuilder c.addReferenceBuilderComponents(b) b.AddGroups(c.Groups) refs, repos, errs := b.Result() if len(c.Strategy) != 0 && len(repos) == 0 { errs = append(errs, fmt.Errorf("when --strategy is specified you must provide at least one source code location")) } if c.BinaryBuild && (len(repos) > 0 || refs.HasSource()) { errs = append(errs, fmt.Errorf("specifying binary builds and source repositories at the same time is not allowed")) } env, duplicateEnv, envErrs := cmdutil.ParseEnvironmentArguments(c.Environment) for _, s := range duplicateEnv { glog.V(1).Infof("The environment variable %q was overwritten", s) } errs = append(errs, envErrs...) parms, duplicateParms, parmsErrs := cmdutil.ParseEnvironmentArguments(c.TemplateParameters) for _, s := range duplicateParms { glog.V(1).Infof("The template parameter %q was overwritten", s) } errs = append(errs, parmsErrs...) return refs, repos, env, parms, errors.NewAggregate(errs) }
// validate converts all of the arguments on the config into references to objects, or returns an error func (c *AppConfig) validate() (app.ComponentReferences, app.SourceRepositories, cmdutil.Environment, cmdutil.Environment, error) { b := c.refBuilder b.AddComponents(c.DockerImages, func(input *app.ComponentInput) app.ComponentReference { input.Argument = fmt.Sprintf("--docker-image=%q", input.From) input.Resolver = c.dockerResolver return input }) b.AddComponents(c.ImageStreams, func(input *app.ComponentInput) app.ComponentReference { input.Argument = fmt.Sprintf("--image=%q", input.From) input.Resolver = c.imageStreamResolver return input }) b.AddComponents(c.Templates, func(input *app.ComponentInput) app.ComponentReference { input.Argument = fmt.Sprintf("--template=%q", input.From) input.Resolver = c.templateResolver return input }) b.AddComponents(c.TemplateFiles, func(input *app.ComponentInput) app.ComponentReference { input.Argument = fmt.Sprintf("--file=%q", input.From) input.Resolver = c.templateFileResolver return input }) b.AddComponents(c.Components, func(input *app.ComponentInput) app.ComponentReference { input.Resolver = app.PerfectMatchWeightedResolver{ app.WeightedResolver{Resolver: c.imageStreamResolver, Weight: 0.0}, app.WeightedResolver{Resolver: c.templateResolver, Weight: 0.0}, app.WeightedResolver{Resolver: c.templateFileResolver, Weight: 0.0}, app.WeightedResolver{Resolver: c.dockerResolver, Weight: 2.0}, } return input }) b.AddGroups(c.Groups) refs, repos, errs := b.Result() if len(repos) > 0 { repos[0].SetContextDir(c.ContextDir) if len(repos) > 1 { glog.Warningf("You have specified more than one source repository and a context directory. "+ "The context directory will be applied to the first repository: %q", repos[0]) } } if len(c.Strategy) != 0 && len(repos) == 0 { errs = append(errs, fmt.Errorf("when --strategy is specified you must provide at least one source code location")) } env, duplicateEnv, envErrs := cmdutil.ParseEnvironmentArguments(c.Environment) for _, s := range duplicateEnv { glog.V(1).Infof("The environment variable %q was overwritten", s) } errs = append(errs, envErrs...) parms, duplicateParms, parmsErrs := cmdutil.ParseEnvironmentArguments(c.TemplateParameters) for _, s := range duplicateParms { glog.V(1).Infof("The template parameter %q was overwritten", s) } errs = append(errs, parmsErrs...) return refs, repos, env, parms, errors.NewAggregate(errs) }
func (o *DockerbuildOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args []string) error { paths, envArgs, ok := cmdutil.SplitEnvironmentFromResources(args) if !ok { return kcmdutil.UsageError(cmd, "context directory must be specified before environment changes: %s", strings.Join(args, " ")) } if len(paths) != 2 { return kcmdutil.UsageError(cmd, "the directory to build and tag must be specified") } o.Arguments, _, _ = cmdutil.ParseEnvironmentArguments(envArgs) o.Directory = paths[0] o.Tag = paths[1] if len(o.DockerfilePath) == 0 { o.DockerfilePath = filepath.Join(o.Directory, "Dockerfile") } var mounts []dockerbuilder.Mount for _, s := range o.MountSpecs { segments := strings.Split(s, ":") if len(segments) != 2 { return kcmdutil.UsageError(cmd, "--mount must be of the form SOURCE:DEST") } mounts = append(mounts, dockerbuilder.Mount{SourcePath: segments[0], DestinationPath: segments[1]}) } o.Mounts = mounts client, err := docker.NewClientFromEnv() if err != nil { return err } o.Client = client o.Keyring = credentialprovider.NewDockerKeyring() return nil }
func (c *AppConfig) validate() (cmdutil.Environment, cmdutil.Environment, error) { var errs []error env, duplicateEnv, envErrs := cmdutil.ParseEnvironmentArguments(c.Environment) for _, s := range duplicateEnv { fmt.Fprintf(c.ErrOut, "warning: The environment variable %q was overwritten", s) } errs = append(errs, envErrs...) params, duplicateParams, paramsErrs := cmdutil.ParseEnvironmentArguments(c.TemplateParameters) for _, s := range duplicateParams { fmt.Fprintf(c.ErrOut, "warning: The template parameter %q was overwritten", s) } errs = append(errs, paramsErrs...) return env, params, kutilerrors.NewAggregate(errs) }
func (o *DockerbuildOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args []string) error { paths, envArgs, ok := cmdutil.SplitEnvironmentFromResources(args) if !ok { return kcmdutil.UsageError(cmd, "context directory must be specified before environment changes: %s", strings.Join(args, " ")) } if len(paths) != 2 { return kcmdutil.UsageError(cmd, "the directory to build and tag must be specified") } o.Arguments, _, _ = cmdutil.ParseEnvironmentArguments(envArgs) o.Directory = paths[0] o.Tag = paths[1] if len(o.DockerfilePath) == 0 { o.DockerfilePath = filepath.Join(o.Directory, "Dockerfile") } client, err := docker.NewClientFromEnv() if err != nil { return err } o.Client = client o.Keyring = credentialprovider.NewDockerKeyring() return nil }