mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #64134 from wgliang/master.remove-from-factory2
Automatic merge from submit-queue (batch tested with PRs 63232, 64257, 64183, 64266, 64134). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Move SuggestedPodTemplateResources from factory to set_resources **What this PR does / why we need it**: Move SuggestedPodTemplateResources from factory to set_resources **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #64106 **Special notes for your reviewer**: /cc @juanvallejo **Release note**: ```release-note NONE ```
This commit is contained in:
commit
a176a8b1b7
@ -18,11 +18,10 @@ package set
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
@ -108,16 +107,11 @@ func NewResourcesOptions(streams genericclioptions.IOStreams) *SetResourcesOptio
|
|||||||
func NewCmdResources(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
|
func NewCmdResources(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
|
||||||
o := NewResourcesOptions(streams)
|
o := NewResourcesOptions(streams)
|
||||||
|
|
||||||
resourceTypesWithPodTemplate := []string{}
|
|
||||||
for _, resource := range f.SuggestedPodTemplateResources() {
|
|
||||||
resourceTypesWithPodTemplate = append(resourceTypesWithPodTemplate, resource.Resource)
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "resources (-f FILENAME | TYPE NAME) ([--limits=LIMITS & --requests=REQUESTS]",
|
Use: "resources (-f FILENAME | TYPE NAME) ([--limits=LIMITS & --requests=REQUESTS]",
|
||||||
DisableFlagsInUseLine: true,
|
DisableFlagsInUseLine: true,
|
||||||
Short: i18n.T("Update resource requests/limits on objects with pod templates"),
|
Short: i18n.T("Update resource requests/limits on objects with pod templates"),
|
||||||
Long: fmt.Sprintf(resources_long, strings.Join(resourceTypesWithPodTemplate, ", ")),
|
Long: fmt.Sprintf(resources_long, cmdutil.SuggestApiResources("kubectl")),
|
||||||
Example: resources_example,
|
Example: resources_example,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cmdutil.CheckErr(o.Complete(f, cmd, args))
|
cmdutil.CheckErr(o.Complete(f, cmd, args))
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
"k8s.io/client-go/dynamic"
|
"k8s.io/client-go/dynamic"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
restclient "k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
@ -74,9 +73,6 @@ type ClientAccessFactory interface {
|
|||||||
// and which implements the common patterns for CLI interactions with generic resources.
|
// and which implements the common patterns for CLI interactions with generic resources.
|
||||||
NewBuilder() *resource.Builder
|
NewBuilder() *resource.Builder
|
||||||
|
|
||||||
// SuggestedPodTemplateResources returns a list of resource types that declare a pod template
|
|
||||||
SuggestedPodTemplateResources() []schema.GroupResource
|
|
||||||
|
|
||||||
// Returns the default namespace to use in cases where no
|
// Returns the default namespace to use in cases where no
|
||||||
// other namespace is specified and whether the namespace was
|
// other namespace is specified and whether the namespace was
|
||||||
// overridden.
|
// overridden.
|
||||||
|
@ -116,16 +116,6 @@ func (f *ring0Factory) RESTClient() (*restclient.RESTClient, error) {
|
|||||||
return restclient.RESTClientFor(clientConfig)
|
return restclient.RESTClientFor(clientConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *ring0Factory) SuggestedPodTemplateResources() []schema.GroupResource {
|
|
||||||
return []schema.GroupResource{
|
|
||||||
{Resource: "replicationcontroller"},
|
|
||||||
{Resource: "deployment"},
|
|
||||||
{Resource: "daemonset"},
|
|
||||||
{Resource: "job"},
|
|
||||||
{Resource: "replicaset"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *ring0Factory) DefaultNamespace() (string, bool, error) {
|
func (f *ring0Factory) DefaultNamespace() (string, bool, error) {
|
||||||
return f.clientGetter.ToRawKubeConfigLoader().Namespace()
|
return f.clientGetter.ToRawKubeConfigLoader().Namespace()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user