Commit Graph

41 Commits

Author SHA1 Message Date
renovate-rancher[bot] 7ac219ffda
Update dependency golangci/golangci-lint to v2 (main) (#841)
* Update dependency golangci/golangci-lint to v2

* Migrate the golangci config file.

* Fix golangci-lint-flagged problems

Most of them fall in these categories:

* stop ignoring returned errors from function calls

* Apply deMorgan's law to complex negative boolean expressions

* Delete unused local variables and struct fields

* Successfully get the linter to stop complaining about
  uncommented global names

* If one import in a block has an import prefix, all must

* Deal with deprecated code

* Prefer switch-blocks to if/else if/...

* Remove unnecessary intermediate struct fields.

* Orphans are now deleted only via propagation-policy

* Stop checking goimports on generated files.

* Remove unused field comment

---------

Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: Eric Promislow <epromislow@suse.com>
2025-09-18 11:39:45 -07:00
Sakala Venkata Krishna Rohit 9336245088
Add support for k8s 1.33 (#954)
* Add support for k8s 1.33

* Use unique ns for each test

The CI is failing with terminating namespaces with finalizer kubernetes. This has nothing to with the logic of integration tests
2025-06-23 11:04:11 -07:00
Pratik Jagrut 77ff369737
fix: add matchCondition to invoke mutation webhook only for cloud-credential secret (#912) 2025-05-28 08:14:40 -04:00
Jonathan Crowther be481b7632
Add checks for annotation to opt out of cluster owner RBAC (#511)
* Move common annotations to resources/common

* Add new annotation to opt out of creatorID

* Add comments and unit tests

* Fix integration test

* Update annotation name

* Add annotation check to project and cluster

* Move annotation check to create

* Fix unit tests
2024-10-04 10:18:01 -04:00
Eric Promislow a45967cffe I read the docs ... m.Require sets up a fatal context if the test fails. 2024-08-09 10:11:46 -07:00
Eric Promislow 57c24ae662 No need to loop while waiting for the CPC to be created. 2024-08-09 10:03:53 -07:00
Eric Promislow 9545ed63bb Simplify the loop. 2024-08-09 10:00:41 -07:00
Eric Promislow 32bf9370ed Use `m.Assert()...` to fail immediately on failed assertions.
Also fail if the object watcher fails in anyway.
2024-08-09 09:58:16 -07:00
Eric Promislow d5308b7e81 Verify the ClusterProxyConfig obj is created in the integration test.
Sometimes the test to verify only one CPC can be created at a time fails
when verifying that the attempted second-object creation returns an
error.  So we watch for that object to be created, and then continue the test.
2024-08-09 09:29:55 -07:00
Peter Matseykanets e732dfd16d
[v0.5] Set FailurePolicy to Ignore for settings validator (#446)
* Set FailurePolicy to Ignore for settings validator
* Add unit and integration tests

Ref: https://github.com/rancher/rancher/issues/45841
2024-08-01 15:38:22 -04:00
Eric Promislow 9f702b46ed Migrate webhook CI to GHA
- Misc. changes to CI caught during further testing:
1. There should be two shell variables, HELM_VERSION for pulling
   down the right version of helm, and HELM_CHART_VERSION, for identifying
   generated helm charts.

2. Similarly, `TAG` and `IMAGE_TAG` are two different things.

3. Stop using make/dapper: env vars get lost

4. Skip the RKE Machine config unit test on CI/arm64
   - Written up in issue 45837
2024-06-28 15:45:08 -07:00
Tom Lebreux 97679b88dd
Add k8s 1.30 support (#412) 2024-06-28 09:23:25 -04:00
Chad Roberts 8e3d96998f
Add validator for clusterproxyconfigs to make sure only one is ever created for a given cluster (#327)
* Add validator for clusterproxyconfigs to make sure only one is ever created for a given cluster
* Add integration test for clusterProxyConfigs
2024-04-03 12:02:30 -04:00
Vatsal Parekh a93553b631 Explicitly add Context
Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com>
2024-04-01 19:03:45 +05:30
Vatsal Parekh 9d7db6b376 Typo fix
Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com>
2024-04-01 17:52:21 +05:30
Vatsal Parekh e8da5e21b5 Rollback the change
Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com>
2024-04-01 17:52:21 +05:30
Vatsal Parekh b2c62c16b4 Make test more readable
Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com>
2024-04-01 17:52:21 +05:30
Vatsal Parekh 95e0d480de Add more descriptive err msg
Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com>
2024-04-01 17:52:21 +05:30
Vatsal Parekh b3bb9032b4 Add more info to the test
Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com>
2024-04-01 17:52:21 +05:30
Vatsal Parekh 6199da8a0e Add test for cluster-contexted roleTemplate
Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com>
2024-04-01 17:52:21 +05:30
Tom Lebreux 49160dee86
Add support for k8s 1.28 (#341) 2024-03-27 16:56:34 -04:00
Jonathan Crowther 8fe5a897de
Upgrade golangci-lint and fix all warnings/errors (#346) 2024-03-27 16:42:40 -04:00
Tom Lebreux 128b387a3c
Remove CAPI webhook (#338) 2024-03-19 13:24:29 -04:00
Andreas Kupries 142fd5c462 chore: ditto for global roles (previous was role templates) 2024-02-01 11:22:19 +01:00
Andreas Kupries 0b32a46225 chore: extended integration tests to cover the new checks for resources and api groups 2024-02-01 11:18:21 +01:00
Michael Bolot 749b8bd5fc Adding clusterName validation to crtbs
Adds a check to ensure the cluster referred to by clusterName exists
2023-09-25 13:56:35 -05:00
Michael Bolot 707f7876c7 Adding validation for cluster/projectName for prtb
Adds validation on clusterName and projectName for prtbs to make sure
they refer to existing projects/clusters and that the project refers to
the cluster in the spec
2023-09-25 13:56:30 -05:00
Michael Bolot 9d4951c711 Adding validation for clusterName to projects
Adds validation for the clusterName field for projects, and fixes and
unrelated error where error messages for globalRoleBindings indicated
their own name as the missing resource instead of the target GlobalRole
2023-09-22 16:35:31 -05:00
Jonathan Crowther 731edbadf5
Prevent CRTBs from being created with mismatching Namespace and ClusterName (#294)
* Fix 42754

* Update create error message to have consistent wording

* Update CRTB docs

* Address comments

* Update integration test
2023-09-15 15:48:11 -04:00
Max Sokolovsky 8937b3dee5 Don't allow PRTB namespace and the project ID of projectName to differ 2023-09-14 16:42:28 -04:00
Kevin Joiner 0f4e9854e8 Migrates GlobalRoles and GlobalRoleBinding.
Migrates Noramn validation done on GlobalRoles and GlobalRoleBinding
in Rancher to the webhook.
2023-09-08 12:59:35 -04:00
Colleen Murphy 6bd22de4df
Merge pull request #263 from cmurphy/validate-projects
Add validation and mutation for Projects
2023-08-17 14:13:08 -07:00
Colleen Murphy 16d548f8b9 Add validation and mutation for Projects
New validations:
- prohibit deleting the system project
- check that quota fields are consistent with one another and sufficient
  for existing quota usage

New mutations:
- adds creator-role-bindings annotation
2023-08-16 12:13:21 -07:00
Jonathan Crowther 11e65478af Add check for roleTemplate context in CRTBs 2023-08-02 10:28:33 -04:00
Max Sokolovsky 0cfa2c2b43
Merge pull request #228 from maxsokolovsky/port-norman-prtb-validation
Port remaining PRTB validation rules from Norman
2023-07-20 11:55:02 -04:00
Kevin Joiner 851f4cbdf6 Adds the ability to set custom ports for Webhook.
This commit also adds helm unittest and updates integration-test to run
K3s without Rancher.
2023-07-19 16:24:44 -04:00
Max Sokolovsky c004e823e1 Port remaining PRTB validation rules from Norman 2023-07-14 14:57:20 -04:00
Kevin Joiner 5506f400e3 Allows namespace webhook to provide multiple configurations.
This commit allows attempts to create the kube-system namespace
while the webhook is down to pass through rancher-webhook.
2023-03-17 14:12:20 -04:00
Jiaqi Luo 572ccd513e fix Drone failures 2023-01-03 15:49:47 -07:00
Chad Roberts 5495fda809
Add webhook handler for namespaces to govern PSA label editing 2022-12-19 15:39:51 -05:00
Kevin Joiner 008a16dc6c Add integration test 2022-11-29 13:28:06 -05:00