@@ -34,6 +34,7 @@ import (
34
34
cluster "k8s.io/kubectl/pkg/cmd/util"
35
35
"sigs.k8s.io/cli-utils/pkg/manifestreader"
36
36
"sigs.k8s.io/cli-utils/pkg/provider"
37
+ "sigs.k8s.io/cli-utils/pkg/util/factory"
37
38
)
38
39
39
40
func GetLiveCommand (ctx context.Context , _ , version string ) * cobra.Command {
@@ -79,8 +80,14 @@ func newFactory(cmd *cobra.Command, version string) cluster.Factory {
79
80
flags := cmd .PersistentFlags ()
80
81
kubeConfigFlags := genericclioptions .NewConfigFlags (true ).WithDeprecatedPasswordFlag ()
81
82
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
+ }
82
89
userAgentKubeConfigFlags := & cfgflags.UserAgentKubeConfigFlags {
83
- Delegate : kubeConfigFlags ,
90
+ Delegate : cachingConfigFlags ,
84
91
UserAgent : fmt .Sprintf ("kpt/%s" , version ),
85
92
}
86
93
cmd .PersistentFlags ().AddGoFlagSet (flag .CommandLine )
0 commit comments