FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ROX-18155: pg generic store: GetAll by janisz · Pull Request #6769 · stackrox/stackrox · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .go  (14) .tpl  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
      • store.go
      • store.go
      • store.go
      • store.go
      • store.go
      • store.go
      • store.go
      • store.go
      • store.go
      • store.go
    • store.go.tpl
      • store.go
      • store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions central/externalbackups/internal/store/postgres/store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions central/group/datastore/internal/store/postgres/store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions central/imageintegration/store/postgres/store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions central/logimbue/store/postgres/store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions central/policy/store/postgres/store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions central/policycategory/store/postgres/store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions central/policycategoryedge/store/postgres/store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions pkg/search/postgres/store.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,15 @@ func (s *GenericStore[T, PT]) Walk(ctx context.Context, fn func(obj PT) error) e
}
return nil
}

// GetAll retrieves all objects from the store.
func (s *GenericStore[T, PT]) GetAll(ctx context.Context) ([]PT, error) {
defer s.setPostgresOperationDurationTime(time.Now(), ops.GetAll)

var objs []PT
err := s.Walk(ctx, func(obj PT) error {
objs = append(objs, obj)
return nil
})
return objs, err
}
15 changes: 0 additions & 15 deletions tools/generate-helpers/pg-table-bindings/store.go.tpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -727,21 +727,6 @@ func (s *storeImpl) GetIDs(ctx context.Context) ([]{{$singlePK.Type}}, error) {
}
{{- end }}

{{- if .GetAll }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If not already done in the cleanup PR, make sure the get-all option is removed from the generator code as well as from the gen.go files that use it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The complete cleanup would impact:

  • the gen.go files next to the stores generated by this pull request
  • tools/generate-helpers/pg-table-bindings/migration.go.tpl (or the file could be removed completely, as well as the gen.go file in the migrator)
  • tools/generate-helpers/pg-table-bindings/store.go.tpl (but I think the current pull request already removes all occurrences)
  • tools/generate-helpers/pg-table-bindings/store_test.go.tpl (to let all stores test the GetAll function)
  • tools/generate-helpers/pg-table-bindings/main.go

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

So you think we should expose GetAll method to all stores? I wander what was the reason to have it as optin

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality


// GetAll retrieves all objects from the store.
func(s *storeImpl) GetAll(ctx context.Context) ([]*{{.Type}}, error) {
defer metrics.SetPostgresOperationDurationTime(time.Now(), ops.GetAll, "{{.TrimmedType}}")

var objs []*{{.Type}}
err := s.Walk(ctx, func(obj *{{.Type}}) error {
objs = append(objs, obj)
return nil
})
return objs, err
}
{{- end}}

//// Interface functions - END

//// Used for testing
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.


Back | FazBrowse Home | New Git URL