Skip to content

Commit

Permalink
call Internal() builder param
Browse files Browse the repository at this point in the history
  • Loading branch information
juanvallejo authored and deads2k committed Dec 7, 2017
1 parent ee9ba1a commit 6cc848c
Show file tree
Hide file tree
Showing 29 changed files with 43 additions and 14 deletions.
29 changes: 15 additions & 14 deletions pkg/api/graph/test/runtimeobject_nodebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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().
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/admin/migrate/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/admin/network/project_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func (p *ProjectOptions) GetProjects() ([]*projectapi.Project, error) {
}

r := p.Builder.
Internal().
ContinueOnError().
NamespaceParam(p.DefaultNamespace).
LabelSelectorParam(p.Selector).
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/admin/node/node_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func (n *NodeOptions) GetNodes() ([]*kapi.Node, error) {
}

r := n.Builder.
Internal().
ContinueOnError().
NamespaceParam(n.DefaultNamespace).
LabelSelectorParam(n.Selector).
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/admin/policy/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...).
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/admin/policy/subject_review.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...).
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/bootstrap/docker/openshift/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...).
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}).
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/expose.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")}).
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...).
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/idle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/rollout/cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...).
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/rollout/latest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]).
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/rollout/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...).
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/rsync/pathspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func resolveResourceKindPath(f kcmdutil.Factory, path, namespace string) (string
}

r := f.NewBuilder().
Internal().
NamespaceParam(namespace).
SingleResourceType().
ResourceNames("pods", podName).
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/set/buildhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/set/buildsecret.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/set/deploymenthook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/set/imagelookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/set/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/set/routebackends.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/set/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/cmd/set/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
1 change: 1 addition & 0 deletions pkg/oc/cli/secrets/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down

0 comments on commit 6cc848c

Please sign in to comment.