func setupAppConfig(f *clientcmd.Factory, out io.Writer, c *cobra.Command, args []string, config *newcmd.AppConfig) error { namespace, _, err := f.DefaultNamespace() if err != nil { return err } dockerClient, _, err := dockerutil.NewHelper().GetClient() if err == nil { if err = dockerClient.Ping(); err == nil { config.SetDockerClient(dockerClient) } } if err != nil { glog.V(2).Infof("No local Docker daemon detected: %v", err) } osclient, _, err := f.Clients() if err != nil { return err } config.SetOpenShiftClient(osclient, namespace) config.Out = out config.ErrOut = c.Out() unknown := config.AddArguments(args) if len(unknown) != 0 { return cmdutil.UsageError(c, "Did not recognize the following arguments: %v", unknown) } if config.AllowMissingImages && config.AsSearch { return cmdutil.UsageError(c, "--allow-missing-images and --search are mutually exclusive.") } return nil }
func setupAppConfig(f *clientcmd.Factory, out io.Writer, c *cobra.Command, args []string, config *newcmd.AppConfig) error { namespace, _, err := f.DefaultNamespace() if err != nil { return err } dockerClient, _, err := dockerutil.NewHelper().GetClient() if err == nil { if err = dockerClient.Ping(); err == nil { config.SetDockerClient(dockerClient) } else { glog.V(4).Infof("Docker client did not respond to a ping: %v", err) } } if err != nil { glog.V(2).Infof("No local Docker daemon detected: %v", err) } osclient, kclient, err := f.Clients() if err != nil { return err } config.KubeClient = kclient config.SetOpenShiftClient(osclient, namespace) // Only output="" should print descriptions of intermediate steps. Everything // else should print only some specific output (json, yaml, go-template, ...) output := cmdutil.GetFlagString(c, "output") if len(output) == 0 { config.Out = out } else { config.Out = ioutil.Discard } config.ErrOut = c.Out() if config.AllowSecretUse { cfg, err := f.OpenShiftClientConfig.ClientConfig() if err != nil { return err } config.SecretAccessor = newConfigSecretRetriever(cfg) } unknown := config.AddArguments(args) if len(unknown) != 0 { return cmdutil.UsageError(c, "Did not recognize the following arguments: %v", unknown) } if config.AllowMissingImages && config.AsSearch { return cmdutil.UsageError(c, "--allow-missing-images and --search are mutually exclusive.") } if len(config.SourceImage) != 0 && len(config.SourceImagePath) == 0 { return cmdutil.UsageError(c, "--source-image-path must be specified when --source-image is specified.") } if len(config.SourceImage) == 0 && len(config.SourceImagePath) != 0 { return cmdutil.UsageError(c, "--source-image must be specified when --source-image-path is specified.") } return nil }