當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Factory.SuggestedPodTemplateResources方法代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/kubectl/cmd/util.Factory.SuggestedPodTemplateResources方法的典型用法代碼示例。如果您正苦於以下問題:Golang Factory.SuggestedPodTemplateResources方法的具體用法?Golang Factory.SuggestedPodTemplateResources怎麽用?Golang Factory.SuggestedPodTemplateResources使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在k8s/io/kubernetes/pkg/kubectl/cmd/util.Factory的用法示例。


在下文中一共展示了Factory.SuggestedPodTemplateResources方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: NewCmdResources

func NewCmdResources(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command {
	options := &ResourcesOptions{
		Out: out,
		Err: errOut,
	}

	resourceTypesWithPodTemplate := []string{}
	for _, resource := range f.SuggestedPodTemplateResources() {
		resourceTypesWithPodTemplate = append(resourceTypesWithPodTemplate, resource.Resource)
	}

	cmd := &cobra.Command{
		Use:     "resources (-f FILENAME | TYPE NAME)  ([--limits=LIMITS & --requests=REQUESTS]",
		Short:   "update resource requests/limits on objects with pod templates",
		Long:    fmt.Sprintf(resources_long, strings.Join(resourceTypesWithPodTemplate, ", ")),
		Example: resources_example,
		Run: func(cmd *cobra.Command, args []string) {
			cmdutil.CheckErr(options.Complete(f, cmd, args))
			cmdutil.CheckErr(options.Validate())
			cmdutil.CheckErr(options.Run())
		},
	}

	cmdutil.AddPrinterFlags(cmd)
	//usage := "Filename, directory, or URL to a file identifying the resource to get from the server"
	//kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
	usage := "identifying the resource to get from a server."
	cmdutil.AddFilenameOptionFlags(cmd, &options.FilenameOptions, usage)
	cmd.Flags().BoolVar(&options.All, "all", false, "select all resources in the namespace of the specified resource types")
	cmd.Flags().StringVarP(&options.Selector, "selector", "l", "", "Selector (label query) to filter on")
	cmd.Flags().StringVarP(&options.ContainerSelector, "containers", "c", "*", "The names of containers in the selected pod templates to change, all containers are selected by default - may use wildcards")
	cmd.Flags().BoolVar(&options.Local, "local", false, "If true, set resources will NOT contact api-server but run locally.")
	cmdutil.AddDryRunFlag(cmd)
	cmdutil.AddRecordFlag(cmd)
	cmd.Flags().StringVar(&options.Limits, "limits", options.Limits, "The resource requirement requests for this container.  For example, 'cpu=100m,memory=256Mi'.  Note that server side components may assign requests depending on the server configuration, such as limit ranges.")
	cmd.Flags().StringVar(&options.Requests, "requests", options.Requests, "The resource requirement requests for this container.  For example, 'cpu=100m,memory=256Mi'.  Note that server side components may assign requests depending on the server configuration, such as limit ranges.")
	return cmd
}
開發者ID:eljefedelrodeodeljefe,項目名稱:kubernetes,代碼行數:38,代碼來源:set_resources.go


注:本文中的k8s/io/kubernetes/pkg/kubectl/cmd/util.Factory.SuggestedPodTemplateResources方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。