Skip to content

Commit

Permalink
add Local and Unstructured builder attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
juanvallejo committed Nov 20, 2017
1 parent a4b81e7 commit 445ad72
Show file tree
Hide file tree
Showing 29 changed files with 60 additions and 40 deletions.
2 changes: 1 addition & 1 deletion pkg/oc/admin/migrate/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (o *ResourceOptions) Complete(f *clientcmd.Factory, c *cobra.Command) error
break
}

o.Builder = f.NewBuilder(true).
o.Builder = f.NewBuilder().
AllNamespaces(allNamespaces).
FilenameParam(false, &resource.FilenameOptions{Recursive: false, Filenames: o.Filenames}).
ContinueOnError().
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/admin/network/project_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (p *ProjectOptions) Complete(f *clientcmd.Factory, c *cobra.Command, args [
return err
}

p.Builder = f.NewBuilder(true)
p.Builder = f.NewBuilder()
p.DefaultNamespace = defaultNamespace
p.Oclient = networkClient
p.Kclient = kc
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/admin/node/node_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (n *NodeOptions) Complete(f *clientcmd.Factory, c *cobra.Command, args []st
}
mapper, typer := f.Object()

n.Builder = f.NewBuilder(true)
n.Builder = f.NewBuilder()
n.DefaultNamespace = defaultNamespace
n.ExternalKubeClient = externalkc
n.KubeClient = kc
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/admin/policy/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (o *sccReviewOptions) Complete(f *clientcmd.Factory, args []string, cmd *co
return fmt.Errorf("unable to obtain client: %v", err)
}
o.client = securityClient.Security()
o.builder = f.NewBuilder(true)
o.builder = f.NewBuilder()
o.RESTClientFactory = f.ClientForMapping

output := kcmdutil.GetFlagString(cmd, "output")
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/admin/policy/subject_review.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (o *sccSubjectReviewOptions) Complete(f *clientcmd.Factory, args []string,
}
o.sccSubjectReviewClient = securityClient.Security()
o.sccSelfSubjectReviewClient = securityClient.Security()
o.builder = f.NewBuilder(true)
o.builder = f.NewBuilder()
o.RESTClientFactory = f.ClientForMapping

output := kcmdutil.GetFlagString(cmd, "output")
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/bootstrap/docker/openshift/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func ImportObjects(f *clientcmd.Factory, ns, location string) error {
return err
}
glog.V(8).Infof("Importing data:\n%s\n", string(data))
r := f.NewBuilder(true).
r := f.NewBuilder().
Schema(schema).
ContinueOnError().
NamespaceParam(ns).
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (o *DebugOptions) Complete(cmd *cobra.Command, f *clientcmd.Factory, args [
}

mapper, _ := f.Object()
b := f.NewBuilder(true).
b := f.NewBuilder().
NamespaceParam(cmdNamespace).DefaultNamespace().
SingleResourceType().
ResourceNames("pods", resources...).
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (o *DeployOptions) Complete(f *clientcmd.Factory, args []string, out io.Wri
return err
}

o.builder = f.NewBuilder(true)
o.builder = f.NewBuilder()
o.out = out

if len(args) > 0 {
Expand Down
8 changes: 2 additions & 6 deletions pkg/oc/cli/cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,13 @@ func RunExport(f *clientcmd.Factory, exporter Exporter, in io.Reader, out io.Wri
return err
}

builder, err := f.NewUnstructuredBuilder(true)
if err != nil {
return err
}

mapper, typer, err := f.UnstructuredObject()
if err != nil {
return err
}

b := builder.
b := f.NewBuilder().
Unstructured(f.UnstructuredClientForMapping, mapper, typer).
NamespaceParam(cmdNamespace).DefaultNamespace().AllNamespaces(allNamespaces).
FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: filenames}).
SelectorParam(selector).
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/expose.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func validate(cmd *cobra.Command, f *clientcmd.Factory, args []string) error {
return err
}

r := f.NewBuilder(true).
r := f.NewBuilder().
ContinueOnError().
NamespaceParam(namespace).DefaultNamespace().
FilenameParam(enforceNamespace, &resource.FilenameOptions{Recursive: false, Filenames: kcmdutil.GetFlagStringSlice(cmd, "filename")}).
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (o *ExtractOptions) Complete(f *clientcmd.Factory, in io.Reader, out io.Wri
return err
}

b := f.NewBuilder(true).
b := f.NewBuilder().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: o.Filenames}).
ResourceNames("", args...).
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/idle.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (o *IdleOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args []
return fmt.Errorf("resource names, selectors, and the all flag may not be be specified if a filename is specified")
}

o.svcBuilder = f.NewBuilder(true).
o.svcBuilder = f.NewBuilder().
ContinueOnError().
NamespaceParam(namespace).DefaultNamespace().AllNamespaces(o.allNamespaces).
Flatten().
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (o *OpenShiftLogsOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command

podLogOptions := o.KubeLogOptions.Options.(*kapi.PodLogOptions)

infos, err := f.NewBuilder(true).
infos, err := f.NewBuilder().
NamespaceParam(o.Namespace).DefaultNamespace().
ResourceNames("pods", args...).
SingleResourceType().RequireObject(false).
Expand Down
10 changes: 8 additions & 2 deletions pkg/oc/cli/cmd/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,14 @@ func RunProcess(f *clientcmd.Factory, in io.Reader, out, errout io.Writer, cmd *
templateObj.CreationTimestamp = metav1.Now()
infos = append(infos, &resource.Info{Object: templateObj})
} else {
infos, err = f.NewBuilder(!local).
FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: []string{filename}}).
b := f.NewBuilder().
FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: []string{filename}})

if local {
b = b.Local(f.ClientForMapping)
}

infos, err = b.
Do().
Infos()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (o *RollbackOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, arg

// Set up client based support.
o.getBuilder = func() *resource.Builder {
return f.NewBuilder(true)
return f.NewBuilder()
}

kClient, err := f.ClientSet()
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/rollout/cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (o *CancelOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, out i
return err
}

r := f.NewBuilder(true).
r := f.NewBuilder().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, &o.FilenameOptions).
ResourceTypeOrNameArgs(true, args...).
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/rollout/latest.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (o *RolloutLatestOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command
o.appsClient = appsClient.Apps()

o.mapper, o.typer = f.Object()
o.infos, err = f.NewBuilder(true).
o.infos, err = f.NewBuilder().
ContinueOnError().
NamespaceParam(namespace).
ResourceNames("deploymentconfigs", args[0]).
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/rollout/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (o *RetryOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, out io
return err
}

r := f.NewBuilder(true).
r := f.NewBuilder().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, &o.FilenameOptions).
ResourceTypeOrNameArgs(true, args...).
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/rsync/pathspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func resolveResourceKindPath(f kcmdutil.Factory, path, namespace string) (string
podName = podSegs[1]
}

r := f.NewBuilder(true).
r := f.NewBuilder().
NamespaceParam(namespace).
SingleResourceType().
ResourceNames("pods", podName).
Expand Down
4 changes: 3 additions & 1 deletion pkg/oc/cli/cmd/set/buildhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (o *BuildHookOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, ar
o.Cmd = cmd

mapper, _ := f.Object()
o.Builder = f.NewBuilder(!o.Local).
o.Builder = f.NewBuilder().
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: o.Filenames}).
Expand All @@ -159,6 +159,8 @@ func (o *BuildHookOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, ar
if len(resources) > 0 {
return resource.LocalResourceError
}

o.Builder = o.Builder.Local(f.ClientForMapping)
}

o.Output = kcmdutil.GetFlagString(cmd, "output")
Expand Down
6 changes: 4 additions & 2 deletions pkg/oc/cli/cmd/set/buildsecret.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func NewCmdBuildSecret(fullName string, f *clientcmd.Factory, out, errOut io.Wri
var supportedBuildTypes = []string{"buildconfigs"}

func (o *BuildSecretOptions) secretFromArg(f *clientcmd.Factory, mapper meta.RESTMapper, typer runtime.ObjectTyper, namespace, arg string) (string, error) {
builder := f.NewBuilder(!o.Local).
builder := f.NewBuilder().
NamespaceParam(namespace).DefaultNamespace().
RequireObject(false).
ContinueOnError().
Expand Down Expand Up @@ -173,7 +173,7 @@ func (o *BuildSecretOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command,
return err
}
}
o.Builder = f.NewBuilder(!o.Local).
o.Builder = f.NewBuilder().
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: o.Filenames}).
Expand All @@ -195,6 +195,8 @@ func (o *BuildSecretOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command,
if len(resources) > 0 {
return resource.LocalResourceError
}

o.Builder = o.Builder.Local(f.ClientForMapping)
}

o.Output = kcmdutil.GetFlagString(cmd, "output")
Expand Down
4 changes: 3 additions & 1 deletion pkg/oc/cli/cmd/set/deploymenthook.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (o *DeploymentHookOptions) Complete(f *clientcmd.Factory, cmd *cobra.Comman
o.Cmd = cmd

mapper, _ := f.Object()
o.Builder = f.NewBuilder(!o.Local).
o.Builder = f.NewBuilder().
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: o.Filenames}).
Expand All @@ -177,6 +177,8 @@ func (o *DeploymentHookOptions) Complete(f *clientcmd.Factory, cmd *cobra.Comman
if len(resources) > 0 {
return resource.LocalResourceError
}

o.Builder = o.Builder.Local(f.ClientForMapping)
}

o.Output = kcmdutil.GetFlagString(cmd, "output")
Expand Down
8 changes: 6 additions & 2 deletions pkg/oc/cli/cmd/set/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (o *EnvOptions) RunEnv(f *clientcmd.Factory) error {
}

if len(o.From) != 0 {
b := f.NewBuilder(!o.Local).
b := f.NewBuilder().
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: o.Filenames}).
Expand All @@ -235,6 +235,8 @@ func (o *EnvOptions) RunEnv(f *clientcmd.Factory) error {
b = b.
SelectorParam(o.Selector).
ResourceTypeOrNameArgs(o.All, o.From)
} else {
b = b.Local(f.ClientForMapping)
}

one := false
Expand Down Expand Up @@ -287,7 +289,7 @@ func (o *EnvOptions) RunEnv(f *clientcmd.Factory) error {
}
}

b := f.NewBuilder(!o.Local).
b := f.NewBuilder().
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: o.Filenames}).
Expand All @@ -304,6 +306,8 @@ func (o *EnvOptions) RunEnv(f *clientcmd.Factory) error {
if len(o.Resources) > 0 {
return resource.LocalResourceError
}

b = b.Local(f.ClientForMapping)
}

one := false
Expand Down
4 changes: 2 additions & 2 deletions pkg/oc/cli/cmd/set/imagelookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (o *ImageLookupOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command,
o.PrintTable = (len(args) == 0 && !o.All) || o.List

mapper, _ := f.Object()
o.Builder = f.NewBuilder(!o.Local).
o.Builder = f.NewBuilder().
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: o.Filenames}).
Expand All @@ -175,7 +175,7 @@ func (o *ImageLookupOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command,
return kcmdutil.UsageErrorf(cmd, "Pass files with -f when using --local")
case o.Local:
// perform no lookups on the server
// TODO: discovery still requires a running server, doesn't fall back correctly
o.Builder = o.Builder.Local(f.ClientForMapping)
case len(args) == 0 && len(o.Filenames) == 0:
o.Builder = o.Builder.
SelectorParam(o.Selector).
Expand Down
4 changes: 3 additions & 1 deletion pkg/oc/cli/cmd/set/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (o *ProbeOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args [
o.Cmd = cmd

mapper, _ := f.Object()
o.Builder = f.NewBuilder(!o.Local).
o.Builder = f.NewBuilder().
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: o.Filenames}).
Expand All @@ -198,6 +198,8 @@ func (o *ProbeOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args [
if len(resources) > 0 {
return resource.LocalResourceError
}

o.Builder = o.Builder.Local(f.ClientForMapping)
}

o.Output = kcmdutil.GetFlagString(cmd, "output")
Expand Down
4 changes: 3 additions & 1 deletion pkg/oc/cli/cmd/set/routebackends.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (o *BackendsOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, arg
o.Cmd = cmd

mapper, _ := f.Object()
o.Builder = f.NewBuilder(!o.Local).
o.Builder = f.NewBuilder().
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: o.Filenames}).
Expand All @@ -182,6 +182,8 @@ func (o *BackendsOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, arg
if len(resources) > 0 {
return resource.LocalResourceError
}

o.Builder = o.Builder.Local(f.ClientForMapping)
}

o.Output = kcmdutil.GetFlagString(cmd, "output")
Expand Down
4 changes: 3 additions & 1 deletion pkg/oc/cli/cmd/set/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (o *TriggersOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, arg
}

mapper, _ := f.Object()
o.Builder = f.NewBuilder(!o.Local).
o.Builder = f.NewBuilder().
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: o.Filenames}).
Expand All @@ -237,6 +237,8 @@ func (o *TriggersOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, arg
if len(args) > 0 {
return resource.LocalResourceError
}

o.Builder = o.Builder.Local(f.ClientForMapping)
}

o.Output = kcmdutil.GetFlagString(cmd, "output")
Expand Down
4 changes: 3 additions & 1 deletion pkg/oc/cli/cmd/set/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ func (v *VolumeOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, out,
}

func (v *VolumeOptions) RunVolume(args []string, f *clientcmd.Factory) error {
b := f.NewBuilder(!v.Local).
b := f.NewBuilder().
ContinueOnError().
NamespaceParam(v.DefaultNamespace).DefaultNamespace().
FilenameParam(v.ExplicitNamespace, &resource.FilenameOptions{Recursive: false, Filenames: v.Filenames}).
Expand All @@ -444,6 +444,8 @@ func (v *VolumeOptions) RunVolume(args []string, f *clientcmd.Factory) error {
if len(args) > 0 {
return resource.LocalResourceError
}

b = b.Local(f.ClientForMapping)
}

singleItemImplied := false
Expand Down
Loading

0 comments on commit 445ad72

Please sign in to comment.