Fix unused Secret export logic.
The strategy used for the secret store defined custom export logic, and had accompanying unit tests. However the secret storage did not actually wire this up by setting an ExportStrategy and thus the code was never used in the real world. This change fixes the missing assignment and adds testing at a higher level to ensure any uses of the generic registry.Store that we expect to have an ExportStrategy do, and no others. Several other strategies in the RBAC package also appeared to have unwired Export logic, however their implementations were all empty leading me to believe that these are not considered exportable. The empty methods have now been removed. Kubernetes-commit: 855a1c17131f92fca6de33279a02eca3893ca374
This commit is contained in:
		
							parent
							
								
									7e2b09280d
								
							
						
					
					
						commit
						f2bea1dce9
					
				|  | @ -52,6 +52,14 @@ import ( | |||
| // object.
 | ||||
| type ObjectFunc func(obj runtime.Object) error | ||||
| 
 | ||||
| // GenericStore interface can be used for type assertions when we need to access the underlying strategies.
 | ||||
| type GenericStore interface { | ||||
| 	GetCreateStrategy() rest.RESTCreateStrategy | ||||
| 	GetUpdateStrategy() rest.RESTUpdateStrategy | ||||
| 	GetDeleteStrategy() rest.RESTDeleteStrategy | ||||
| 	GetExportStrategy() rest.RESTExportStrategy | ||||
| } | ||||
| 
 | ||||
| // Store implements pkg/api/rest.StandardStorage. It's intended to be
 | ||||
| // embeddable and allows the consumer to implement any non-generic functions
 | ||||
| // that are required. This object is intended to be copyable so that it can be
 | ||||
|  | @ -177,6 +185,7 @@ type Store struct { | |||
| var _ rest.StandardStorage = &Store{} | ||||
| var _ rest.Exporter = &Store{} | ||||
| var _ rest.TableConvertor = &Store{} | ||||
| var _ GenericStore = &Store{} | ||||
| 
 | ||||
| const OptimisticLockErrorMsg = "the object has been modified; please apply your changes to the latest version and try again" | ||||
| 
 | ||||
|  | @ -233,6 +242,26 @@ func (e *Store) NewList() runtime.Object { | |||
| 	return e.NewListFunc() | ||||
| } | ||||
| 
 | ||||
| // GetCreateStrategy implements GenericStore.
 | ||||
| func (e *Store) GetCreateStrategy() rest.RESTCreateStrategy { | ||||
| 	return e.CreateStrategy | ||||
| } | ||||
| 
 | ||||
| // GetUpdateStrategy implements GenericStore.
 | ||||
| func (e *Store) GetUpdateStrategy() rest.RESTUpdateStrategy { | ||||
| 	return e.UpdateStrategy | ||||
| } | ||||
| 
 | ||||
| // GetDeleteStrategy implements GenericStore.
 | ||||
| func (e *Store) GetDeleteStrategy() rest.RESTDeleteStrategy { | ||||
| 	return e.DeleteStrategy | ||||
| } | ||||
| 
 | ||||
| // GetExportStrategy implements GenericStore.
 | ||||
| func (e *Store) GetExportStrategy() rest.RESTExportStrategy { | ||||
| 	return e.ExportStrategy | ||||
| } | ||||
| 
 | ||||
| // List returns a list of items matching labels and field according to the
 | ||||
| // store's PredicateFunc.
 | ||||
| func (e *Store) List(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (runtime.Object, error) { | ||||
|  |  | |||
|  | @ -86,7 +86,9 @@ type Lister interface { | |||
| 	List(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (runtime.Object, error) | ||||
| } | ||||
| 
 | ||||
| // Exporter is an object that knows how to strip a RESTful resource for export
 | ||||
| // Exporter is an object that knows how to strip a RESTful resource for export. A store should implement this interface
 | ||||
| // if export is generally supported for that type. Errors can still be returned during the actual Export when certain
 | ||||
| // instances of the type are not exportable.
 | ||||
| type Exporter interface { | ||||
| 	// Export an object.  Fields that are not user specified (e.g. Status, ObjectMeta.ResourceVersion) are stripped out
 | ||||
| 	// Returns the stripped object.  If 'exact' is true, fields that are specific to the cluster (e.g. namespace) are
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue