* Capture type info so numeric values sort correctly.
* Replace conditional string prefixing with strings.TrimPrefix
* Add tabular data for other metadata.fields to sort numerically.
The issue is that some fields are not numeric, but are represented
in an entry in metadata.fields with a numeric indicator. Like
with secrets, metadata.fields[2] gives the number of actual keys
in the stored secret.
* Index more fields round 7, part 1
Add status.{allocatable,requested}.{cpus,pods,memory,memoryRaw}
* Add a converter to convert the annotated strings to float64's
* Fold the 'builtinIntTable' into the prepopulated 'typeGuidanceTable'.
- More test tweaking - verify the status.available fields work when not specified.
* Correction: 'status.available' should be 'status.requested'.
* Add the 'memoryRaw' field to status.A/R
* golint change, but the sql function uses underscores
* Fix decoding problems.
* Remove redundant type registering for GOB
* We no longer need to process this type because everything is 'map[string]any'.
* Remove commented-out debug helpers
* Use k8s library quantity-parser over ours.
Our unit tests pass as if with this change, looks good.
* SQL codegen: map the SortAsIP option to the 'inet_aton' function call
* Implement and test sorting IP addresses by their underlying int64 value.
* Implement parsing 'ip(x)' as an IP-sort directive.
* Fix a change rebasing missed.
* On Reset, remove all the sqlite files, not just the main one.
* Avoid resetting the database and cache when not needed.
Avoid resetting when a change doesn't bring in new schema fields.
Always reset when a CRD is deleted.
* Force a database reset when a new CRD is added.
* Improve code readability. No functional change.
* More error wrapping for SQL cache
* Use context.Context instead of stopCh
* Move CacheFor to Info log level
* Implement time-based GC
* Set default GC param when running standalone steve
* Continue rebasing.
* Wrote unit tests for external associations.
* Fix the generated SQL.
Some syntactic sugar (capitalizing the keywords), but use the 'ON' syntax on JOINs.
* whitespace fix post rebase
* We want "management.cattle.io.projects:spec.displayName" not "...spec.clusterName"
* Fix the database calls: drop the key
* Fix breakage during automatic rebase merging gone wrong.
* ws fix - NFC
* Post rebase-merge fixes
* Fix rebase-driven merge.
* Fix rebase breakage.
* go-uber v0.5.2 prefers real arg names to '<argN>'
* Run tests using sqlite DB in a temp directory.
I was running into write-file errors which happens when two sqlite processes try to update the DB at the same time.
* Implement and test the extractBarredValue custom SQL function.
* Explain the DB path constants better.
* Re-order SQL event hooks so events are last
* Add QueryRowContext for single line queries
* Add test case for unknown resource version
* Properly check rows and close it
* More accurate error message when context.Context is canceled
* Re-order test check
Previous SQLite-related code used context.Background() and context.TODO() because it was not developed with context awareness.
This commit propagates the main Steve context so that it can be used when interacting with SQL context-aware functions.
This PR removes all production-code use of context.Background() and context.TODO() and replaces test-code use of TODO with Background.
Contributes to rancher/rancher#47825
This introduces the a `WithTransaction` function, which is then used for all transactional work in Steve.
Because `WithTransaction` takes care of all `Begin`s, `Commit`s and `Rollback`s, it eliminates the problem where forgotten open transactions can block all other operations (with long stalling and `SQLITE_BUSY` errors).
This also:
- merges together the disparate `DBClient` interfaces in one only `db.Client` interface with one unexported non-test implementation. I found this much easier to follow
- refactors the transaction package in order to make it as minimal as possible, and as close to the wrapped `sql.Tx` and `sql.Stmt` functions as possible, in order to reduce cognitive load when working with this part of the codebase
- simplifies tests accordingly
- adds a couple of known files to `.gitignore`
Credits to @tomleb for suggesting the approach: https://github.com/rancher/lasso/pull/121#pullrequestreview-2515872507