Skip to content

Commit 4dc08a4

Browse files
authored
Fix issue with multiple RESTMappers for live (#2375)
* Fix issue with multiple RESTMappers for live * Address comments
1 parent 49a252e commit 4dc08a4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

commands/livecmd.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
cluster "k8s.io/kubectl/pkg/cmd/util"
3535
"sigs.k8s.io/cli-utils/pkg/manifestreader"
3636
"sigs.k8s.io/cli-utils/pkg/provider"
37+
"sigs.k8s.io/cli-utils/pkg/util/factory"
3738
)
3839

3940
func GetLiveCommand(ctx context.Context, _, version string) *cobra.Command {
@@ -79,8 +80,14 @@ func newFactory(cmd *cobra.Command, version string) cluster.Factory {
7980
flags := cmd.PersistentFlags()
8081
kubeConfigFlags := genericclioptions.NewConfigFlags(true).WithDeprecatedPasswordFlag()
8182
kubeConfigFlags.AddFlags(flags)
83+
// Use the CachingRESTClientGetter to make sure the same RESTMapper is shared
84+
// across all kpt live functionality. This is needed to properly invalidate the
85+
// RESTMapper cache when CRDs have been installed in the cluster.
86+
cachingConfigFlags := &factory.CachingRESTClientGetter{
87+
Delegate: kubeConfigFlags,
88+
}
8289
userAgentKubeConfigFlags := &cfgflags.UserAgentKubeConfigFlags{
83-
Delegate: kubeConfigFlags,
90+
Delegate: cachingConfigFlags,
8491
UserAgent: fmt.Sprintf("kpt/%s", version),
8592
}
8693
cmd.PersistentFlags().AddGoFlagSet(flag.CommandLine)

internal/cmdfndoc/cmdfndoc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import (
2323
"os/exec"
2424

2525
"github.com/GoogleContainerTools/kpt/internal/docs/generated/fndocs"
26-
"github.com/GoogleContainerTools/kpt/internal/printer"
2726
"github.com/GoogleContainerTools/kpt/internal/fnruntime"
27+
"github.com/GoogleContainerTools/kpt/internal/printer"
2828
"github.com/GoogleContainerTools/kpt/internal/util/cmdutil"
2929
"github.com/spf13/cobra"
3030
)

0 commit comments

Comments
 (0)