MCPcopy
hub / github.com/kubernetes/kubectl / AddFlags

Method AddFlags

pkg/cmd/apply/apply.go:226–241  ·  view source on GitHub ↗

AddFlags registers flags for a cli

(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

224
225// AddFlags registers flags for a cli
226func (flags *ApplyFlags) AddFlags(cmd *cobra.Command) {
227 // bind flag structs
228 flags.DeleteFlags.AddFlags(cmd)
229 flags.RecordFlags.AddFlags(cmd)
230 flags.PrintFlags.AddFlags(cmd)
231
232 cmdutil.AddValidateFlags(cmd)
233 cmdutil.AddDryRunFlag(cmd)
234 cmdutil.AddServerSideApplyFlags(cmd)
235 cmdutil.AddFieldManagerFlagVar(cmd, &flags.FieldManager, FieldManagerClientSideApply)
236 cmdutil.AddLabelSelectorFlagVar(cmd, &flags.Selector)
237 cmdutil.AddPruningFlags(cmd, &flags.Prune, &flags.PruneAllowlist, &flags.All, &flags.ApplySetRef)
238 cmd.Flags().BoolVar(&flags.Overwrite, "overwrite", flags.Overwrite, "Automatically resolve conflicts between the modified and live configuration by using values from the modified configuration")
239 cmd.Flags().BoolVar(&flags.OpenAPIPatch, "openapi-patch", flags.OpenAPIPatch, "If true, use openapi to calculate diff when the openapi presents and the resource can be found in the openapi spec. Otherwise, fall back to use baked-in types.")
240 cmdutil.AddSubresourceFlags(cmd, &flags.Subresource, "If specified, apply will operate on the subresource of the requested object. Only allowed when using --server-side.")
241}
242
243// ToOptions converts from CLI inputs to runtime inputs
244func (flags *ApplyFlags) ToOptions(f cmdutil.Factory, cmd *cobra.Command, baseName string, args []string) (*ApplyOptions, error) {

Callers 7

TestApplyExtraArgsFailFunction · 0.95
TestAlphaEnablementFunction · 0.95
TestApplyFlagValidationFunction · 0.95
TestLoadObjectsFunction · 0.95
TestApplyWithPruneV2Function · 0.95
NewCmdApplyFunction · 0.95

Calls 1

AddFlagsMethod · 0.65

Tested by 6

TestApplyExtraArgsFailFunction · 0.76
TestAlphaEnablementFunction · 0.76
TestApplyFlagValidationFunction · 0.76
TestLoadObjectsFunction · 0.76
TestApplyWithPruneV2Function · 0.76