Skip to content

Commit

Permalink
Adopt breaking change of Kubernetes PR 117102
Browse files Browse the repository at this point in the history
Signed-off-by: RainbowMango <[email protected]>
  • Loading branch information
RainbowMango committed Jul 25, 2023
1 parent 466998e commit 2ff237c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/karmadactl/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var metadataAccessor = meta.NewAccessor()
type CommandApplyOptions struct {
// apply flags
KubectlApplyFlags *kubectlapply.ApplyFlags
UtilFactory util.Factory
AllClusters bool
Clusters []string

Expand Down Expand Up @@ -66,7 +67,8 @@ var (
// NewCmdApply creates the `apply` command
func NewCmdApply(f util.Factory, parentCommand string, streams genericclioptions.IOStreams) *cobra.Command {
o := &CommandApplyOptions{
KubectlApplyFlags: kubectlapply.NewApplyFlags(nil, streams),
KubectlApplyFlags: kubectlapply.NewApplyFlags(streams),
UtilFactory: f,
}
cmd := &cobra.Command{
Use: "apply (-f FILENAME | -k DIRECTORY)",
Expand Down Expand Up @@ -105,8 +107,7 @@ func (o *CommandApplyOptions) Complete(f util.Factory, cmd *cobra.Command, paren
return err
}
o.karmadaClient = karmadaClient
o.KubectlApplyFlags.Factory = f
kubectlApplyOptions, err := o.KubectlApplyFlags.ToOptions(cmd, parentCommand, args)
kubectlApplyOptions, err := o.KubectlApplyFlags.ToOptions(f, cmd, parentCommand, args)
if err != nil {
return err
}
Expand Down Expand Up @@ -171,7 +172,7 @@ func (o *CommandApplyOptions) generateAndInjectPolices() error {
if err != nil {
return fmt.Errorf("unable to recognize resource: %v", err)
}
client, err := o.KubectlApplyFlags.Factory.UnstructuredClientForMapping(mapping)
client, err := o.UtilFactory.UnstructuredClientForMapping(mapping)
if err != nil {
return fmt.Errorf("unable to connect to a server to handle %q: %v", mapping.Resource, err)
}
Expand Down

0 comments on commit 2ff237c

Please sign in to comment.