Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove useless code and fix typo error #653

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/storage/internalstorage/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
// for better defense against SQL injection.
//
// Use either single whereSQLStatement field, a pair of whereSQLStatement with whereSQLParam, or
// whereSQLStatement with whereSQLJSONParams to pass the SQL it self and parameters.
// whereSQLStatement with whereSQLJSONParams to pass the SQL itself and parameters.
//
// owner: @nekomeowww
// alpha: v0.8.0
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/internalstorage/resource_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (s *ResourceStorage) Update(ctx context.Context, cluster string, obj runtim
return InterpretResourceDBError(cluster, metaobj.GetName(), result.Error)
}

func (c *ResourceStorage) ConvertDeletedObject(obj interface{}) (runtime.Object, error) {
func (s *ResourceStorage) ConvertDeletedObject(obj interface{}) (runtime.Object, error) {
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
if err != nil {
return nil, err
Expand Down Expand Up @@ -188,7 +188,7 @@ func (s *ResourceStorage) Get(ctx context.Context, cluster, namespace, name stri
return err
}
if obj != into {
return fmt.Errorf("Failed to decode resource, into is %T", into)
return fmt.Errorf("failed to decode resource, into is %T", into)
}
return nil
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/storage/internalstorage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func (s *StorageFactory) NewCollectionResourceStorage(cr *internal.CollectionRes
return nil, fmt.Errorf("not support collection resource: %s", cr.Name)
}

func (f *StorageFactory) GetResourceVersions(ctx context.Context, cluster string) (map[schema.GroupVersionResource]map[string]interface{}, error) {
func (s *StorageFactory) GetResourceVersions(ctx context.Context, cluster string) (map[schema.GroupVersionResource]map[string]interface{}, error) {
var resources []Resource
result := f.db.WithContext(ctx).Select("group", "version", "resource", "namespace", "name", "resource_version").
result := s.db.WithContext(ctx).Select("group", "version", "resource", "namespace", "name", "resource_version").
Where(map[string]interface{}{"cluster": cluster}).
Find(&resources)
if result.Error != nil {
Expand All @@ -66,8 +66,8 @@ func (f *StorageFactory) GetResourceVersions(ctx context.Context, cluster string
return resourceversions, nil
}

func (f *StorageFactory) CleanCluster(ctx context.Context, cluster string) error {
result := f.db.WithContext(ctx).Where(map[string]interface{}{"cluster": cluster}).Delete(&Resource{})
func (s *StorageFactory) CleanCluster(ctx context.Context, cluster string) error {
result := s.db.WithContext(ctx).Where(map[string]interface{}{"cluster": cluster}).Delete(&Resource{})
return InterpretDBError(cluster, result.Error)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/internalstorage/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func applyListOptionsToQuery(query *gorm.DB, opts *internal.ListOptions, applyFn
query,
opts.URLQuery,
utilfeature.DefaultMutableFeatureGate.Enabled(AllowRawSQLQuery),
utilfeature.DefaultMutableFeatureGate.Enabled((AllowParameterizedSQLQuery)),
utilfeature.DefaultMutableFeatureGate.Enabled(AllowParameterizedSQLQuery),
)
if err != nil {
return 0, nil, nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/memorystorage/memory_resource_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (s *ResourceStorage) ConvertDeletedObject(obj interface{}) (runobj runtime.
if obj, ok := obj.(runtime.Object); ok {
return obj, nil
}
return nil, fmt.Errorf("Invalid Type(%T): couldn't convert deleted object", obj)
return nil, fmt.Errorf("invalid Type(%T): couldn't convert deleted object", obj)
}

func (s *ResourceStorage) Delete(ctx context.Context, cluster string, obj runtime.Object) error {
Expand Down Expand Up @@ -135,7 +135,7 @@ func (s *ResourceStorage) Get(ctx context.Context, cluster, namespace, name stri
}

if obj != into {
return fmt.Errorf("Failed to decode resource, into is %T", into)
return fmt.Errorf("failed to decode resource, into is %T", into)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewStorageFactory(name, configPath string) (StorageFactory, error) {

storagefactory, err := provider(configPath)
if err != nil {
return nil, fmt.Errorf("Failed to init storage: %w", err)
return nil, fmt.Errorf("failed to init storage: %w", err)
}
return storagefactory, nil
}
Loading