1
0
mirror of https://github.com/rancher/steve.git synced 2025-08-31 15:11:31 +00:00
Commit Graph

571 Commits

Author SHA1 Message Date
renovate-rancher[bot]
078ddfe47d chore(deps): update module github.com/rancher/saml to v0.4.14 (#496)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-23 10:59:59 -08:00
Sakala Venkata Krishna Rohit
0c73b199be Update renovate.json to ignore packages (#516)
* Rancher 2.7 is EOL, so removing release/v0.1

* Ignore dependencies for steve renovate

* Ignore major, minor bumps of rancher deps

* test
2025-02-21 10:37:19 -08:00
Eric Promislow
c906c36bc3 support unwatchables in vai (#458)
* Create and use a synthetic watcher for non-watchable resources.

* Write unit tests for the synthetic watcher.

* Make the refresh interval for synthetic watchers configurable.

The default is to call `client.List(...)` every 5 seconds for each unwatchable GVK.

There are currently only 3 such GVKs right now so this will be informative
enough but not really noticeable.

* Pass the context into the synthetic watch func.

* Restore changes lost in rebasing.

---------

Co-authored-by: Tom Lebreux <tom.lebreux@suse.com>
v0.5.7
2025-02-20 12:45:58 -08:00
Alejandro Ruiz
6559fa9ad7 Fix "Unable to cancel request for *client.addQuery" warnings (#512) 2025-02-20 12:03:03 -05:00
renovate-rancher[bot]
d7746fd993 chore(deps): update module modernc.org/sqlite to v1.35.0 (#454)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-14 09:05:49 -08:00
Chad Roberts
5b5db5c40f [main&2.10.3] Add schema links and resource methods for resource verb patch (#450)
* Show patch link on the API resource when patch permission is present and add patch ResourceMethod to the schema.

* Added tests for new functionality and corrected disallowed method for patch
2025-02-14 06:12:17 -05:00
renovate-rancher[bot]
f51f89196c chore(deps): update module golang.org/x/sync to v0.11.0 (#487)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-13 10:07:08 -08:00
Chad Roberts
ccbadbd75f Update to k8s 1.32 libraries (#491)
* Rebase

* Update dynamiclistener to v0.6.2-rc.3
2025-02-12 13:26:58 -05:00
renovate-rancher[bot]
36b97a97fb chore(deps): update actions/checkout action to v4.2.2 (#339)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-12 09:26:50 -08:00
Richard Cox
eab91bb3d3 Fix code blocks in README (#490)
- an errant set of backticks broke quotes below
2025-02-12 09:26:25 -08:00
renovate-rancher[bot]
f664022933 chore(deps): update module github.com/rancher/dynamiclistener to v0.6.1 (#334)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-12 09:20:45 -08:00
renovate-rancher[bot]
d314442a42 chore(deps): update module github.com/urfave/cli/v2 to v2.27.5 (#336)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-12 09:20:20 -08:00
renovate-rancher[bot]
b72a24c0bc chore(deps): update module github.com/google/gnostic-models to v0.6.9 (#372)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-12 09:17:27 -08:00
Silvio Moioli
3350323f91 sql: propagate and use contexts (#465)
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
2025-02-12 09:46:10 +01:00
renovate-rancher[bot]
e71f8c455d chore(deps): update module github.com/rancher/wrangler/v3 to v3.1.0 (#344)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-11 13:04:45 -08:00
renovate-rancher[bot]
b4551c5472 chore(deps): update module go.uber.org/mock to v0.5.0 (#345)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-11 13:03:15 -08:00
renovate-rancher[bot]
cab3ff10b5 chore(deps): update golangci/golangci-lint-action action to v6.3.2 (#341)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-11 12:54:07 -08:00
renovate-rancher[bot]
ac1e70719e chore(deps): update actions/setup-go action to v5.3.0 (#340)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-11 12:53:45 -08:00
renovate-rancher[bot]
747284103a chore(deps): update module github.com/urfave/cli to v1.22.16 (#335)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-11 12:53:19 -08:00
renovate-rancher[bot]
b826f74af2 chore(deps): update module github.com/adrg/xdg to v0.5.3 (#332)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-11 12:52:43 -08:00
renovate-rancher[bot]
8c96897309 chore(deps): update dependency go to v1.23.6 (#331)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-11 12:52:20 -08:00
renovate-rancher[bot]
4768bba63b chore(deps): update module github.com/gorilla/websocket to v1.5.3 (#333)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-11 12:52:00 -08:00
renovate-rancher[bot]
43f0f7cf62 Add initial Renovate configuration (#457)
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
2025-02-11 12:27:15 -08:00
Silvio Moioli
9139e492e0 vai: do not discard closing statement errors (#462) 2025-02-07 08:31:08 +01:00
Silvio Moioli
772dc7577e sql: use a closure to wrap transactions (#469)
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
2025-02-05 10:05:52 +01:00
Silvio Moioli
6a46a1e091 sql: encrypt Tokens by default (#467)
Co-authored-by: Eric Promislow <epromislow@suse.com>
v0.5.6
2025-02-03 09:12:02 +01:00
Eric Promislow
d794bfe4e8 Index arbitrary labels (#317)
* Add more fields to index when sql-caching is on.

* Restore the gvkKey helper, add event fields.

The UI team wasn't sure whether the event fields should go in the empty-string group or in 'events.k8s.io',
so let's go with both until/unless specified otherwise.

* More fixes to the fields to index:

- Remove the erroneously added management.cattle.io.nodes fields
- Use the builtin Event class, not events.k8s.io (by looking at the dashboard client code)

* Start on the virtual-field work.

* Map `Event.type` to `Event._type` for indexing.

* Add a unit test for field replacement for Event.type

* Add label processing.

* Don't test for transformation of event objects in the common module.

* Parse metadata.label queries differently.

* Improve a variable name that turned out to not be temporary.

* No need to specifically cache certain labels, as all are now cached.

* Add a test to verify simple label (m.labels.foo=blah) queries work.

* 'addLabelFields' never returns an error.

* Delete superseded function.

* Was calling 'addLabelFields' one time too many.

* Start using k8s ParseToRequirements

* Pull in the k8s parser.

* Successfully test for quotation marks.

* Add quoted strings to the lexer.

* Move to a forked k8s label lexer to include non-label tests.

* Improve and test the way quoted strings in the query are detected.

* Reinstate the original Apache license in the derived code.

Following clause 4.3 of the Apache license:
"You must cause any modified files to carry prominent notices stating that You changed the files..."

* Ignore case for operators.

* Test IN multiple-target-values

* Test the not-in operator.

* Ignore case for operators.

SQL is case-insensitive on field names and values, so this just adds consistency.

* Added tests for parsing EXISTS and NOT-EXISTS queries.

* Parse less-than and greater-than ops

* Lasso's `CacheFor` now takes a `watchable` argument.

* Support 'gt' and 'lt' as synonyms for '<' and '>'.

I see both types of operators being bandied about -- it's easy to support the aliases.

* typo fix

* Have the filter parser allow exist tests only on labels.

Also reduce the case where there's no namespace function.

* Specify hard-wired fields to index alphabetically.

* Remove unused variable.

* Parser: 'metadata.labels[FIELD]' is valid

* Pull in new gvk fields from main (and keep in alpha order).

* Fixed a couple of drops done during the last rebase.

* Add a reminder to keep the entries in alpha order.

* Test TransformLabels

* Remove TransformLabels

* Remove unused/unneeded code.

* Describe diffs between our label-selector parser and upstream's.

* Use the merged lasso 46333 work.

* Drop unused field.

* Tighten up the code.

* Specify which commit the label selector parser is based on.

* Allow both single-quoted and double-quoted value matching, doc difference.

* More review-driven changes:

- Stricter processing of m.l.name keys:
  Require ending close-bracket for a start-bracket

- Comment fix

- Moving sql processing from lasso to steve: some changes missed in rebase

* Drop support for double-quotes for string values.

For now on only single-quotes (or none where possible) are allowed.

* Renaming and dropping an init block.

* Quoted strings are dropped from the filter queries

In particular, label values have a specific syntax: they must
start and end with a letter, and their innards may contain
only alnums '.', '-' and '_'.  So there's no need for quoting.

And that means now that `=` and `==` do exact matches,
and the `~` operator does a partial match.

`!=` and `!~` negate -- note that `!~` is a stricter operation than `!=`,
in that given a set of possible string values, `!=` will accept more
of them than `!~`. Maybe I shouldn't have gone here, but these operators
reminded me of learning about `nicht durfen` and `nicht sollen` in German,
or something like that.

* Move a constant definition to the module level.

* Remove commented-out code.

* Remove unused func and adjacent redundant comment.
2025-01-30 11:57:23 -08:00
Vatsal Parekh
7da1377c89 [main] Upgrade go version to 1.23 (#446)
* Upgrade go version to 1.23

Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com>

* Upgrade golangci-lint to 1.63.4

Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com>

---------

Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com>
2025-01-29 09:05:04 -05:00
Alejandro Ruiz
8ae74491e7 Fix race in accessstore test (#466) 2025-01-28 20:35:24 -05:00
Josh Meranda
5cdbd29ebe Imperative api pls (#434)
* Add aggregation layer support

* prefer testing.Cleanup

* add sni certs to server opts

* test cleanup

* append snicerts instead of overwriting

---------

Co-authored-by: Tom Lebreux <tom.lebreux@suse.com>
Co-authored-by: joshmeranda <joshua.meranda@gmail.com>
v0.5.5
2025-01-28 09:08:20 -05:00
Silvio Moioli
ae4153b712 vai: document resync period (#463) 2025-01-28 09:02:38 +01:00
Eric Promislow
c1805696ce SQLite backed cache: Support sorting mgmt clusters on value in a specific condition (#447)
* Replace primary/secondary sort fields with an array of sort directives.

* Allow more than 2 sort-params in a search query.

* Add a virtual 'status.ready' field to clusters.

* Rename status.ready -> status.connected

* Set virtual field 'spec.internal' <- spec.displayName == 'local'

* Need to declare all virtual fields to index.

* Ready clusters have condition[type==Ready && status=True]

* Update the README to reflect generalized sorting.

* Bump lasso to get revised sort directives.

* Review-driven changes, mostly comments and drop unneeded code.

* Add unit tests to verify sort-order stringification.

* Ignore empty-string sort components.

* Fix a rebase mishap.

* Drop unneeded commented-out code.

* Clusters have a 'spec.internal' field, no need to synthesize one.

* Added a note on square-brackets for label references.

This should be added to the README for filter queries in the PR for 46333.

* Bump to latest sqlcache-free lasso
2025-01-27 11:55:09 -08:00
Tom Lebreux
809e927a0c Update extension apiserver documentation (#456) 2025-01-21 11:04:13 -05:00
Tom Lebreux
469208d806 Fix sort field parsing (#455) v0.5.4 2025-01-21 10:38:23 +01:00
Tom Lebreux
9dd9b0f625 Move lasso SQL cache in Steve (#452)
* Copy pkg/cache/sql from lasso to pkg/sqlcache

* Rename import from github.com/rancher/lasso/pkg/cache/sql to github.com/rancher/steve/pkg/sqlcache

* Fix filter.Match -> filter.Matches

* go mod tidy

* Fix lint errors

* Remove lasso SQL cache mentions

* Fix more CI lint errors

* fix goimports

Signed-off-by: Silvio Moioli <silvio@moioli.net>

* fix tests (Match -> Matches)

Signed-off-by: Silvio Moioli <silvio@moioli.net>

* Fix Sort order

---------

Signed-off-by: Silvio Moioli <silvio@moioli.net>
Co-authored-by: Silvio Moioli <silvio@moioli.net>
2025-01-17 09:34:48 -05:00
Tom Lebreux
d05a48f9cf Fix overriding update and remove links with the wrong link (#451) v0.5.3 2025-01-15 11:15:47 -08:00
Tom Lebreux
fdf2ef8e93 Partial extension API server store + control over printed columns (#432)
* Checkpoint

* Add support for custom columns

* Remove old Store and Delegate abstraction

* Fix nits and rewording

* Remove unused mock file

* Update documentation for extension api server

* Remove the need for scheme for ConvertListOptions

* Rename store to utils

* fixup! Remove the need for scheme for ConvertListOptions

* Move watch helper to tests

* Add convertError at a few places

* Ignore misspell on creater

* Fix comments and remove unused params

* Add convertError to missing error returns

* Fix watcher implementation

* Document request.UserFrom and request.NamespaceFrom
v0.5.2
2025-01-15 12:41:44 -05:00
Tom Lebreux
4477e2c1c4 Add indexed field Event.involvedObject.uid (#439) 2025-01-14 08:33:44 +01:00
Silvio Moioli
e70d03d6ce sort typeSpecificIndexedFields lexicographically (#437) 2025-01-11 12:26:44 +01:00
Tom Lebreux
8666ce1f54 Update indexed fields (#433)
* Update indexed fields

* Add .status.currentReplicas
v0.5.1
2025-01-09 09:35:49 -05:00
Eric Promislow
d3269c91eb Finish the AccessSet changes to the main formatter. (#308)
The original PR, steve/pull/158 drifted too far from changes
in main, so it's easier to create a new PR:

* Bring in and update DefaultSchemaTemplatesForStore
* Move from based on `master` to `main`
* Update k8s version
2025-01-07 12:20:26 -08:00
Silvio Moioli
5e15f22b0d SQLite backed cache: indexed fields round #4 (#430)
* Change indexed fields according to https://github.com/rancher/rancher/issues/48256wq

Signed-off-by: Silvio Moioli <silvio@moioli.net>

* Fix typo

---------

Signed-off-by: Silvio Moioli <silvio@moioli.net>
v0.5.0
2024-12-19 11:01:09 -05:00
Silvio Moioli
58f2264f16 sql: silence informer errors on unwatchable resources (#284)
* bump lasso to include pull #111

Signed-off-by: Silvio Moioli <silvio@moioli.net>

* Make IsListWatchable public to be reused in other packages

Signed-off-by: Silvio Moioli <silvio@moioli.net>

* Let lasso know whether a type is watchable upon requesting a cache

Signed-off-by: Silvio Moioli <silvio@moioli.net>

* Adapt existing tests

Signed-off-by: Silvio Moioli <silvio@moioli.net>

* Add a test to check watchability is detected correctly

Signed-off-by: Silvio Moioli <silvio@moioli.net>

---------

Signed-off-by: Silvio Moioli <silvio@moioli.net>
2024-12-19 04:53:10 -05:00
Silvio Moioli
65129458a7 cache/sql: add more indexed fields (#400)
Signed-off-by: Silvio Moioli <silvio@moioli.net>
2024-12-06 15:59:02 -08:00
Josh Meranda
61e80cffc8 Implement versioning ADR (#321)
* update renovate

* add release workflow

* document versioning

---------

Co-authored-by: joshmeranda <joshua.meranda@gmail.com>
2024-11-15 10:29:32 -05:00
Felipe Gehrke
ea177193f1 #47568 - Added delegateError + Improve delegate Test Coverage (#318)
* added delegate error / improve delegate coverage / add new mocks

* fixing ci lint

* addressing comments from @ericpromislow

* addressing comments from @tomleb

* fixing apistatus type casting assert
2024-11-14 16:34:35 -03:00
Felipe Gehrke
6ee8201c8d #47483 - Adding NonResourceURLs support to AccessStore (#299)
* adding NonResourceURLs support to access_store

* added tests to AccessSet NonResourceURLs handling

* change on test script suggested by @tomleb + go mod tidy

* added nonresource to ext api authorization

* added NonResourceURLs implementation in Authorizes + test

* removed non-resource-url tests from the main test

* added new tests for non-resource-urls

* removed unused test data

* changed nonResourceKey to point to struct{}

* addressed comments from @tomleb

* addressed more comments

* fixing typo

* check for empty accessSet
2024-11-04 23:47:48 -03:00
nflynt
2175e090fe Refactor ID based partitioning, add unit tests (#309)
* Refactor ID based partitioning, add unit tests

This resolves an issue where the requested namespace filter was not
always honored.

* Correct naming issues to appease the linter
2024-10-29 09:27:12 -04:00
Diogo Souza
b2f2bab3c4 Helm data formatter (#305)
* changing secret and configmap formatters to return decoded helm data if includeHelmData query parameter is present

* adding tests for gzip magic header
2024-10-28 15:55:36 -05:00
Alejandro Ruiz
fd9a516ecb refactor(accesscontrol): deterministic cache key hashing (#292)
* refactor(accesscontrol): make addAccess directly accept PolicyRules

* refactor(accesscontrol): add new types for encapsulating all needed data

* refactor(accesscontrol): make getRules return resource version

* refactor(accesscontrol): add new getRoleRefs to policyRuleIndex

* refactor(accesscontrol): make accessStore use the new types and method

* cleanup(accesscontrol): remove unused code

* cleanup(accesscontrol): adapt tests

* cleanup(accesscontrol): add some comments and remove unused function

* refactor(accesscontrol): rework indexer to make it more readable and testable

* Fix typo

* test: consistent use of t.Error

* test: refactor policyRulesMock to just use a map

* misc: rename toUserInfo function

* refactor: consistent sort by UID
2024-10-28 09:35:59 +01:00