mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Merge pull request #23437 from DirectXMan12/bug/cannot-edit-across-gv
Automatic merge from submit-queue Make kubectl edit not convert GV on edits Previously, kubectl edit was using a decoder to load in edits that converted to the internal version. It would then re-encode this decoded value to produce a patch. However, if you were editing in the object in a GroupVersion that was not the internal version, this would cause the kubectl edit command to attempt to produce a patch which changed the GroupVersion, which would fail. Now, we use a plain deserializer instead, so no conversion or defaulting occurs when loading in the edited file. Ref #23378
This commit is contained in:
		@@ -146,7 +146,13 @@ func RunEdit(f *cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args
 | 
				
			|||||||
		ObjectTyper:  typer,
 | 
							ObjectTyper:  typer,
 | 
				
			||||||
		RESTMapper:   mapper,
 | 
							RESTMapper:   mapper,
 | 
				
			||||||
		ClientMapper: resource.ClientMapperFunc(f.ClientForMapping),
 | 
							ClientMapper: resource.ClientMapperFunc(f.ClientForMapping),
 | 
				
			||||||
		Decoder:      f.Decoder(true),
 | 
					
 | 
				
			||||||
 | 
							// NB: we use `f.Decoder(false)` to get a plain deserializer for
 | 
				
			||||||
 | 
							// the resourceMapper, since it's used to read in edits and
 | 
				
			||||||
 | 
							// we don't want to convert into the internal version when
 | 
				
			||||||
 | 
							// reading in edits (this would cause us to potentially try to
 | 
				
			||||||
 | 
							// compare two different GroupVersions).
 | 
				
			||||||
 | 
							Decoder: f.Decoder(false),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
 | 
						r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user