From 6cc848caa78687d43bde1630862b906bf84c086a Mon Sep 17 00:00:00 2001 From: juanvallejo Date: Thu, 7 Dec 2017 16:41:01 -0500 Subject: [PATCH] call Internal() builder param --- .../graph/test/runtimeobject_nodebuilder.go | 29 ++++++++++--------- pkg/oc/admin/migrate/migrator.go | 1 + pkg/oc/admin/network/project_options.go | 1 + pkg/oc/admin/node/node_options.go | 1 + pkg/oc/admin/policy/review.go | 1 + pkg/oc/admin/policy/subject_review.go | 1 + pkg/oc/bootstrap/docker/openshift/import.go | 1 + pkg/oc/cli/cmd/debug.go | 1 + pkg/oc/cli/cmd/deploy.go | 1 + pkg/oc/cli/cmd/export.go | 1 + pkg/oc/cli/cmd/expose.go | 1 + pkg/oc/cli/cmd/extract.go | 1 + pkg/oc/cli/cmd/idle.go | 1 + pkg/oc/cli/cmd/logs.go | 1 + pkg/oc/cli/cmd/process.go | 1 + pkg/oc/cli/cmd/rollback.go | 1 + pkg/oc/cli/cmd/rollout/cancel.go | 1 + pkg/oc/cli/cmd/rollout/latest.go | 1 + pkg/oc/cli/cmd/rollout/retry.go | 1 + pkg/oc/cli/cmd/rsync/pathspec.go | 1 + pkg/oc/cli/cmd/set/buildhook.go | 1 + pkg/oc/cli/cmd/set/buildsecret.go | 1 + pkg/oc/cli/cmd/set/deploymenthook.go | 1 + pkg/oc/cli/cmd/set/imagelookup.go | 1 + pkg/oc/cli/cmd/set/probe.go | 1 + pkg/oc/cli/cmd/set/routebackends.go | 1 + pkg/oc/cli/cmd/set/triggers.go | 1 + pkg/oc/cli/cmd/set/volume.go | 1 + pkg/oc/cli/secrets/options.go | 1 + 29 files changed, 43 insertions(+), 14 deletions(-) diff --git a/pkg/api/graph/test/runtimeobject_nodebuilder.go b/pkg/api/graph/test/runtimeobject_nodebuilder.go index fce0d5907b7e..b80d89d5c7a7 100644 --- a/pkg/api/graph/test/runtimeobject_nodebuilder.go +++ b/pkg/api/graph/test/runtimeobject_nodebuilder.go @@ -5,13 +5,13 @@ import ( "path/filepath" "reflect" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/kubernetes/pkg/api/legacyscheme" + kapi "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/apis/autoscaling" - kapi "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/kubectl/categories" "k8s.io/kubernetes/pkg/kubectl/resource" - "k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" osgraph "github.com/openshift/origin/pkg/api/graph" _ "github.com/openshift/origin/pkg/api/install" @@ -131,25 +131,26 @@ func BuildGraph(path string) (osgraph.Graph, []runtime.Object, error) { return g, objs, err } - mapper := legacyscheme.Registry.RESTMapper() + mapper := kapi.Registry.RESTMapper() + typer := kapi.Scheme + clientMapper := resource.ClientMapperFunc(func(mapping *meta.RESTMapping) (resource.RESTClient, error) { + return nil, nil + }) - builder := resource.NewBuilder( + r := resource.NewBuilder( &resource.Mapper{ RESTMapper: mapper, - ObjectTyper: legacyscheme.Scheme, - ClientMapper: resource.DisabledClientForMapping{}, - Decoder: legacyscheme.Codecs.UniversalDecoder(), + ObjectTyper: typer, + ClientMapper: clientMapper, + Decoder: kapi.Codecs.UniversalDecoder(), }, &resource.Mapper{ RESTMapper: mapper, - ObjectTyper: legacyscheme.Scheme, - ClientMapper: resource.DisabledClientForMapping{}, + ObjectTyper: typer, + ClientMapper: clientMapper, Decoder: unstructured.UnstructuredJSONScheme, }, - categories.SimpleCategoryExpander{}, - ) - - r := builder. + categories.SimpleCategoryExpander{}). Internal(). FilenameParam(false, &resource.FilenameOptions{Recursive: false, Filenames: []string{abspath}}). Flatten(). diff --git a/pkg/oc/admin/migrate/migrator.go b/pkg/oc/admin/migrate/migrator.go index dd6f6b098ffc..3474325c41af 100644 --- a/pkg/oc/admin/migrate/migrator.go +++ b/pkg/oc/admin/migrate/migrator.go @@ -218,6 +218,7 @@ func (o *ResourceOptions) Complete(f *clientcmd.Factory, c *cobra.Command) error } o.Builder = f.NewBuilder(). + Internal(). AllNamespaces(allNamespaces). FilenameParam(false, &resource.FilenameOptions{Recursive: false, Filenames: o.Filenames}). ContinueOnError(). diff --git a/pkg/oc/admin/network/project_options.go b/pkg/oc/admin/network/project_options.go index f60097839f27..99fbb3ca1c80 100644 --- a/pkg/oc/admin/network/project_options.go +++ b/pkg/oc/admin/network/project_options.go @@ -108,6 +108,7 @@ func (p *ProjectOptions) GetProjects() ([]*projectapi.Project, error) { } r := p.Builder. + Internal(). ContinueOnError(). NamespaceParam(p.DefaultNamespace). LabelSelectorParam(p.Selector). diff --git a/pkg/oc/admin/node/node_options.go b/pkg/oc/admin/node/node_options.go index 949bb8b2c95f..91da9e8d84e4 100644 --- a/pkg/oc/admin/node/node_options.go +++ b/pkg/oc/admin/node/node_options.go @@ -135,6 +135,7 @@ func (n *NodeOptions) GetNodes() ([]*kapi.Node, error) { } r := n.Builder. + Internal(). ContinueOnError(). NamespaceParam(n.DefaultNamespace). LabelSelectorParam(n.Selector). diff --git a/pkg/oc/admin/policy/review.go b/pkg/oc/admin/policy/review.go index a459d36c4784..8d98242d87a2 100644 --- a/pkg/oc/admin/policy/review.go +++ b/pkg/oc/admin/policy/review.go @@ -129,6 +129,7 @@ func (o *sccReviewOptions) Complete(f *clientcmd.Factory, args []string, cmd *co func (o *sccReviewOptions) Run(args []string) error { r := o.builder. + Internal(). NamespaceParam(o.namespace). FilenameParam(o.enforceNamespace, &o.FilenameOptions). ResourceTypeOrNameArgs(true, args...). diff --git a/pkg/oc/admin/policy/subject_review.go b/pkg/oc/admin/policy/subject_review.go index a2d96210ee94..09adf0e11b39 100644 --- a/pkg/oc/admin/policy/subject_review.go +++ b/pkg/oc/admin/policy/subject_review.go @@ -134,6 +134,7 @@ func (o *sccSubjectReviewOptions) Run(args []string) error { userOrSA = o.serviceAccount } r := o.builder. + Internal(). NamespaceParam(o.namespace). FilenameParam(o.enforceNamespace, &o.FilenameOptions). ResourceTypeOrNameArgs(true, args...). diff --git a/pkg/oc/bootstrap/docker/openshift/import.go b/pkg/oc/bootstrap/docker/openshift/import.go index 972c7b51e146..07d23f083eb6 100644 --- a/pkg/oc/bootstrap/docker/openshift/import.go +++ b/pkg/oc/bootstrap/docker/openshift/import.go @@ -25,6 +25,7 @@ func ImportObjects(f *clientcmd.Factory, ns, location string) error { } glog.V(8).Infof("Importing data:\n%s\n", string(data)) r := f.NewBuilder(). + Internal(). Schema(schema). ContinueOnError(). NamespaceParam(ns). diff --git a/pkg/oc/cli/cmd/debug.go b/pkg/oc/cli/cmd/debug.go index 126e45c5489c..a923c64e8e96 100644 --- a/pkg/oc/cli/cmd/debug.go +++ b/pkg/oc/cli/cmd/debug.go @@ -223,6 +223,7 @@ func (o *DebugOptions) Complete(cmd *cobra.Command, f *clientcmd.Factory, args [ mapper, _ := f.Object() b := f.NewBuilder(). + Internal(). NamespaceParam(cmdNamespace).DefaultNamespace(). SingleResourceType(). ResourceNames("pods", resources...). diff --git a/pkg/oc/cli/cmd/deploy.go b/pkg/oc/cli/cmd/deploy.go index 5f5d7f1d2fd5..8b71faf45abd 100644 --- a/pkg/oc/cli/cmd/deploy.go +++ b/pkg/oc/cli/cmd/deploy.go @@ -197,6 +197,7 @@ func (o DeployOptions) Validate() error { func (o DeployOptions) RunDeploy() error { r := o.builder. + Internal(). NamespaceParam(o.namespace). ResourceNames("deploymentconfigs", o.deploymentConfigName). SingleResourceType(). diff --git a/pkg/oc/cli/cmd/export.go b/pkg/oc/cli/cmd/export.go index a720c9ea9c79..1459903c668a 100644 --- a/pkg/oc/cli/cmd/export.go +++ b/pkg/oc/cli/cmd/export.go @@ -111,6 +111,7 @@ func RunExport(f *clientcmd.Factory, exporter Exporter, in io.Reader, out io.Wri } b := f.NewBuilder(). + Internal(). Unstructured(). NamespaceParam(cmdNamespace).DefaultNamespace().AllNamespaces(allNamespaces). FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: filenames}). diff --git a/pkg/oc/cli/cmd/expose.go b/pkg/oc/cli/cmd/expose.go index 52753ecee328..f8beaebc4428 100644 --- a/pkg/oc/cli/cmd/expose.go +++ b/pkg/oc/cli/cmd/expose.go @@ -94,6 +94,7 @@ func validate(cmd *cobra.Command, f *clientcmd.Factory, args []string) error { } r := f.NewBuilder(). + Internal(). ContinueOnError(). NamespaceParam(namespace).DefaultNamespace(). FilenameParam(enforceNamespace, &resource.FilenameOptions{Recursive: false, Filenames: kcmdutil.GetFlagStringSlice(cmd, "filename")}). diff --git a/pkg/oc/cli/cmd/extract.go b/pkg/oc/cli/cmd/extract.go index 896b003ff3ef..c571e206dbe3 100644 --- a/pkg/oc/cli/cmd/extract.go +++ b/pkg/oc/cli/cmd/extract.go @@ -99,6 +99,7 @@ func (o *ExtractOptions) Complete(f *clientcmd.Factory, in io.Reader, out io.Wri } b := f.NewBuilder(). + Internal(). NamespaceParam(cmdNamespace).DefaultNamespace(). FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: o.Filenames}). ResourceNames("", args...). diff --git a/pkg/oc/cli/cmd/idle.go b/pkg/oc/cli/cmd/idle.go index 5cabec0bf408..68a4de350f32 100644 --- a/pkg/oc/cli/cmd/idle.go +++ b/pkg/oc/cli/cmd/idle.go @@ -116,6 +116,7 @@ func (o *IdleOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args [] } o.svcBuilder = f.NewBuilder(). + Internal(). ContinueOnError(). NamespaceParam(namespace).DefaultNamespace().AllNamespaces(o.allNamespaces). Flatten(). diff --git a/pkg/oc/cli/cmd/logs.go b/pkg/oc/cli/cmd/logs.go index 9b10d52d03f3..ddcd6a60b06c 100644 --- a/pkg/oc/cli/cmd/logs.go +++ b/pkg/oc/cli/cmd/logs.go @@ -127,6 +127,7 @@ func (o *OpenShiftLogsOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command podLogOptions := o.KubeLogOptions.Options.(*kapi.PodLogOptions) infos, err := f.NewBuilder(). + Internal(). NamespaceParam(o.Namespace).DefaultNamespace(). ResourceNames("pods", args...). SingleResourceType().RequireObject(false). diff --git a/pkg/oc/cli/cmd/process.go b/pkg/oc/cli/cmd/process.go index 64ca38203b81..e56b26c474c3 100644 --- a/pkg/oc/cli/cmd/process.go +++ b/pkg/oc/cli/cmd/process.go @@ -223,6 +223,7 @@ func RunProcess(f *clientcmd.Factory, in io.Reader, out, errout io.Writer, cmd * infos = append(infos, &resource.Info{Object: templateObj}) } else { infos, err = f.NewBuilder(). + Internal(). LocalParam(local). FilenameParam(explicit, &resource.FilenameOptions{Recursive: false, Filenames: []string{filename}}). Do(). diff --git a/pkg/oc/cli/cmd/rollback.go b/pkg/oc/cli/cmd/rollback.go index 34abbcb04b5a..03c1e31da47f 100644 --- a/pkg/oc/cli/cmd/rollback.go +++ b/pkg/oc/cli/cmd/rollback.go @@ -310,6 +310,7 @@ func (o *RollbackOptions) findResource(targetName string) (runtime.Object, error var obj runtime.Object for _, name := range candidates { r := o.getBuilder(). + Internal(). NamespaceParam(o.Namespace). ResourceTypeOrNameArgs(false, name). SingleResourceType(). diff --git a/pkg/oc/cli/cmd/rollout/cancel.go b/pkg/oc/cli/cmd/rollout/cancel.go index a78eb4f1d5e3..d9c61c549cd8 100644 --- a/pkg/oc/cli/cmd/rollout/cancel.go +++ b/pkg/oc/cli/cmd/rollout/cancel.go @@ -90,6 +90,7 @@ func (o *CancelOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, out i } r := f.NewBuilder(). + Internal(). NamespaceParam(cmdNamespace).DefaultNamespace(). FilenameParam(enforceNamespace, &o.FilenameOptions). ResourceTypeOrNameArgs(true, args...). diff --git a/pkg/oc/cli/cmd/rollout/latest.go b/pkg/oc/cli/cmd/rollout/latest.go index 57a7338e5d4c..f6ef4756d15c 100644 --- a/pkg/oc/cli/cmd/rollout/latest.go +++ b/pkg/oc/cli/cmd/rollout/latest.go @@ -108,6 +108,7 @@ func (o *RolloutLatestOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command o.mapper, o.typer = f.Object() o.infos, err = f.NewBuilder(). + Internal(). ContinueOnError(). NamespaceParam(namespace). ResourceNames("deploymentconfigs", args[0]). diff --git a/pkg/oc/cli/cmd/rollout/retry.go b/pkg/oc/cli/cmd/rollout/retry.go index 22b0cfddb6e8..fc4b3888da6c 100644 --- a/pkg/oc/cli/cmd/rollout/retry.go +++ b/pkg/oc/cli/cmd/rollout/retry.go @@ -91,6 +91,7 @@ func (o *RetryOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, out io } r := f.NewBuilder(). + Internal(). NamespaceParam(cmdNamespace).DefaultNamespace(). FilenameParam(enforceNamespace, &o.FilenameOptions). ResourceTypeOrNameArgs(true, args...). diff --git a/pkg/oc/cli/cmd/rsync/pathspec.go b/pkg/oc/cli/cmd/rsync/pathspec.go index 3551ed72a7a0..416520a28e2d 100644 --- a/pkg/oc/cli/cmd/rsync/pathspec.go +++ b/pkg/oc/cli/cmd/rsync/pathspec.go @@ -93,6 +93,7 @@ func resolveResourceKindPath(f kcmdutil.Factory, path, namespace string) (string } r := f.NewBuilder(). + Internal(). NamespaceParam(namespace). SingleResourceType(). ResourceNames("pods", podName). diff --git a/pkg/oc/cli/cmd/set/buildhook.go b/pkg/oc/cli/cmd/set/buildhook.go index 501f03e5552f..ebee693aa2af 100644 --- a/pkg/oc/cli/cmd/set/buildhook.go +++ b/pkg/oc/cli/cmd/set/buildhook.go @@ -138,6 +138,7 @@ func (o *BuildHookOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, ar mapper, _ := f.Object() o.Builder = f.NewBuilder(). + Internal(). LocalParam(o.Local). ContinueOnError(). NamespaceParam(cmdNamespace).DefaultNamespace(). diff --git a/pkg/oc/cli/cmd/set/buildsecret.go b/pkg/oc/cli/cmd/set/buildsecret.go index f7b99ceed175..d33385925d50 100644 --- a/pkg/oc/cli/cmd/set/buildsecret.go +++ b/pkg/oc/cli/cmd/set/buildsecret.go @@ -122,6 +122,7 @@ 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(). + Internal(). LocalParam(o.Local). NamespaceParam(namespace).DefaultNamespace(). RequireObject(false). diff --git a/pkg/oc/cli/cmd/set/deploymenthook.go b/pkg/oc/cli/cmd/set/deploymenthook.go index 49c2d711c7ad..aa0a85a72246 100644 --- a/pkg/oc/cli/cmd/set/deploymenthook.go +++ b/pkg/oc/cli/cmd/set/deploymenthook.go @@ -157,6 +157,7 @@ func (o *DeploymentHookOptions) Complete(f *clientcmd.Factory, cmd *cobra.Comman mapper, _ := f.Object() o.Builder = f.NewBuilder(). + Internal(). LocalParam(o.Local). ContinueOnError(). NamespaceParam(cmdNamespace).DefaultNamespace(). diff --git a/pkg/oc/cli/cmd/set/imagelookup.go b/pkg/oc/cli/cmd/set/imagelookup.go index 4cc911a00d81..7284b84802e6 100644 --- a/pkg/oc/cli/cmd/set/imagelookup.go +++ b/pkg/oc/cli/cmd/set/imagelookup.go @@ -165,6 +165,7 @@ func (o *ImageLookupOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, mapper, _ := f.Object() o.Builder = f.NewBuilder(). + Internal(). LocalParam(o.Local). ContinueOnError(). NamespaceParam(cmdNamespace).DefaultNamespace(). diff --git a/pkg/oc/cli/cmd/set/probe.go b/pkg/oc/cli/cmd/set/probe.go index b8c67900b340..81f5975cd012 100644 --- a/pkg/oc/cli/cmd/set/probe.go +++ b/pkg/oc/cli/cmd/set/probe.go @@ -183,6 +183,7 @@ func (o *ProbeOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args [ mapper, _ := f.Object() o.Builder = f.NewBuilder(). + Internal(). LocalParam(o.Local). ContinueOnError(). NamespaceParam(cmdNamespace).DefaultNamespace(). diff --git a/pkg/oc/cli/cmd/set/routebackends.go b/pkg/oc/cli/cmd/set/routebackends.go index 67cf0aed377e..c866d0697219 100644 --- a/pkg/oc/cli/cmd/set/routebackends.go +++ b/pkg/oc/cli/cmd/set/routebackends.go @@ -162,6 +162,7 @@ func (o *BackendsOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, arg mapper, _ := f.Object() o.Builder = f.NewBuilder(). + Internal(). LocalParam(o.Local). ContinueOnError(). NamespaceParam(cmdNamespace).DefaultNamespace(). diff --git a/pkg/oc/cli/cmd/set/triggers.go b/pkg/oc/cli/cmd/set/triggers.go index 10cd7935cc7f..8c79acd8af06 100644 --- a/pkg/oc/cli/cmd/set/triggers.go +++ b/pkg/oc/cli/cmd/set/triggers.go @@ -221,6 +221,7 @@ func (o *TriggersOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, arg mapper, _ := f.Object() o.Builder = f.NewBuilder(). + Internal(). LocalParam(o.Local). ContinueOnError(). NamespaceParam(cmdNamespace).DefaultNamespace(). diff --git a/pkg/oc/cli/cmd/set/volume.go b/pkg/oc/cli/cmd/set/volume.go index 2e4cfdd3e4bc..65c4822947e9 100644 --- a/pkg/oc/cli/cmd/set/volume.go +++ b/pkg/oc/cli/cmd/set/volume.go @@ -430,6 +430,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(). + Internal(). LocalParam(v.Local). ContinueOnError(). NamespaceParam(v.DefaultNamespace).DefaultNamespace(). diff --git a/pkg/oc/cli/secrets/options.go b/pkg/oc/cli/secrets/options.go index 5f6f63688cf3..9c13e4842bc6 100644 --- a/pkg/oc/cli/secrets/options.go +++ b/pkg/oc/cli/secrets/options.go @@ -85,6 +85,7 @@ func (o SecretOptions) Validate() error { // GetServiceAccount Retrieve the service account object specified by the command func (o SecretOptions) GetServiceAccount() (*kapi.ServiceAccount, error) { r := o.BuilderFunc(). + Internal(). NamespaceParam(o.Namespace). ResourceNames("serviceaccounts", o.TargetName). SingleResourceType().