Commit Graph

352 Commits

Author SHA1 Message Date
Felipe C. Gehrke 670648da81 reverting back 2024-10-09 15:48:18 -03:00
Felipe C. Gehrke 62427bff02 adjusting error message 2024-10-09 15:39:30 -03:00
Felipe C. Gehrke fef01c524d fixing client generator 2024-10-09 15:22:41 -03:00
Felipe C. Gehrke 0f27e53f7c changed openapi comment to be dependent on flag 2024-10-05 00:07:55 -03:00
Felipe C. Gehrke 432899a5aa removed exp/maps 2024-10-02 18:49:02 -03:00
Felipe C. Gehrke 433b7d1214 addressing comments from tomleb 2024-09-30 14:50:39 -03:00
Felipe C. Gehrke 2317fcbd24 updated to add openapi dependencies + another fix 2024-09-26 18:17:42 -03:00
Felipe C. Gehrke 39d89c60f8 added openapi codegen 2024-09-24 15:52:01 -03:00
Alejandro Ruiz 10b40ce223 Add small help to the README 2024-09-10 09:00:46 +02:00
Alejandro Ruiz e9fb3665ee Switch to maintained gomock fork 2024-09-05 17:35:36 +02:00
Alejandro Ruiz a31c883469 debug(signals): print received signals 2024-07-02 16:17:43 +02:00
Jonathan Crowther 652f4c907e
Add unit tests and comments to the name package (#424)
* Add unit tests and comments to the package

* Add more tests and comments
2024-05-10 09:58:31 -04:00
Tom Lebreux f3b392ada2
Move to wrangler v3 (#427) 2024-05-02 10:06:30 -04:00
Tom Lebreux 8886c2677b
K8s 1.30 (#425)
* Use goimports instead of k8s.io/code-generator

* Upgrade k8s.io to 1.30

* Fix deepcopy-gen generator

* Migrate client-gen to gengo/v2

* Migrate listers generator to gengo/v2

* Migrate informers to gengo/v2

* Update setGenClient middleware to gengo/v2

* Migrate custom generators

---------

Co-authored-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>
2024-05-01 16:16:56 -04:00
Michael Bolot 5527d17b82
Merge pull request #321 from cmurphy/get-value-arrays
Add support for getting array index in GetValue
2024-04-09 15:56:16 -05:00
Alejandro Ruiz 06dfe879fc
Merge branch 'master' into remove-event-handlers 2024-03-04 10:53:06 +01:00
Michael Bolot 53fba45d47 Restoring GetValue
Restores GetValue to it's original interface to avoid breaking changes.
2024-02-23 11:24:50 -06:00
Alejandro Ruiz 5a201f0488 fix: go 1.20 compatibility 2024-02-15 17:44:06 +01:00
Alejandro Ruiz afd01a1c89 fix(relatedresource): remove event handler when context is closed 2024-02-15 16:50:21 +01:00
Michael Bolot 1592712122 Adding package comments for data package
Adds package comments and extra test cases
2024-02-06 12:35:09 -06:00
Chirayu Kapoor b7956feb44
implement CustomResourceDefinitionInterface using mockgen
Signed-off-by: Chirayu Kapoor <chirayu.kapoor@suse.com>
2024-01-23 22:31:16 +05:30
Alejandro Ruiz f5d32fe214
Allow GeneratingHandlers to skip Apply if resource version didn't change (#341)
* Allow GeneratingHandlers to skip Apply if resource version didn't change

* Run go generate

* Add call count to FakeApply

* Add test for UniqueApplyForResourceVersion

* Simplify error handling

Co-authored-by: Kevin Joiner <10265309+KevinJoiner@users.noreply.github.com>

* Make generated code more readable

Co-authored-by: Kevin Joiner <10265309+KevinJoiner@users.noreply.github.com>

* Rename constant

* Rename seenResourceVersion to storeResourceVersion

* go generate

* Add comments to code generator

* Run go generate

* Upgrade golangci-lint GitHub action, since it always fails now

---------

Co-authored-by: Kevin Joiner <10265309+KevinJoiner@users.noreply.github.com>
2023-12-22 13:57:51 -05:00
Alejandro Ruiz 3040716d42
Use indexer when listing cached types by hash (#326)
* Add indexer by hash for cached types

* Upgrade golangci-lint GitHub action, since it always fails now
2023-12-22 13:56:56 -05:00
Brad Davidson 3032665ca5 Fix printer column generation for struct fields that are serialized as strings
Kubernetes types like metav1.Time and resource.Quantity are serialized
as strings, but the column tag extraction did not handle this properly.
Fix this by using the OpenAPISchemaType helper function to get the type.

Ref: https://github.com/kubernetes/kube-openapi/blob/master/pkg/generators/README.md#custom-openapi-type-definitions

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2023-10-12 14:07:14 -07:00
Colleen Murphy 63eb31bb73 Add support for getting array index in GetValue
Add the ability to use an index number to get an item out of a slice.

The number will still be a string representation of an integer. For
example, to get the last element from a nested slice like:

```
data := map[string]interface{}{
    "data": []interface{}{
        "first",
        "second",
        "third",
    },
}
```

Use keys like

```
val := GetValues(data, "data", "2")
```
2023-10-09 13:00:34 -05:00
Colleen Murphy fa1a98735b Add unit test for data.GetValue 2023-10-09 13:00:27 -05:00
Ricardo Weir 0a0c449686
Merge pull request #317 from rmweir/update-v2
Update v2
2023-09-06 15:46:18 -07:00
Ricardo Weir ac51d2631c Comment regarding package fields 2023-09-06 10:11:11 -07:00
Ricardo Weir d4a7d13cee Update module to v2 and update paths 2023-09-01 17:51:39 -07:00
Ricardo Weir b9331c2ef0 Add ImportPath for v2 2023-09-01 16:46:22 -07:00
Silvio Moioli ef1a21e4a1
make test ordering-robust
Signed-off-by: Silvio Moioli <silvio@moioli.net>
2023-08-30 10:25:31 +02:00
Silvio Moioli 05cbd3a361
leaderelection: refactoring: extract env keys as consts
Signed-off-by: Silvio Moioli <silvio@moioli.net>
2023-08-28 16:14:15 +02:00
Silvio Moioli 7c35dd2b17
leaderelection: add unit tests for timeout setting function
Signed-off-by: Silvio Moioli <silvio@moioli.net>
2023-08-28 11:40:19 +02:00
Silvio Moioli d6f57f5eff
leaderelection: refactoring: extract timeout configuration setting into separate function
Signed-off-by: Silvio Moioli <silvio@moioli.net>
2023-08-28 11:39:47 +02:00
Silvio Moioli 5a322a4795
leaderelection: configure all timeouts via environment variables
Signed-off-by: Silvio Moioli <silvio@moioli.net>
2023-08-28 11:39:38 +02:00
galal-hussein 288095854c update client-go to 0.28 and update resource lease lock
Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>
2023-08-16 02:29:59 +03:00
Ricardo Weir 35cb42e6a9
Merge pull request #289 from KevinJoiner/remove-git
Removes git pkg.
2023-08-07 11:20:02 -07:00
Caleb Bron 201b4da5bd
Merge pull request #310 from KevinJoiner/crd-generation
Crd generation
2023-07-05 15:36:03 -07:00
Kevin Joiner aec16a862a Add batch creation of CRDs from api structs. 2023-07-05 15:09:55 -04:00
Kevin Joiner 2c6c574aca Adds generic YAML to JSON Unmarshaling. 2023-06-30 13:16:59 -04:00
Kevin Joiner 294dad04db Reduce generated clients/controllers.
The Generated Client, Controller, and Cache interfaces are now entirely
implemented by the generic Interfaces. These changes greatly reduce the
amount of generated code needed and allows users to use the mocks
directly with controllers without having to wrap them as an embedded
object.
2023-06-29 16:24:29 -04:00
Kevin Joiner 8110ecfc32 Update fakes to create valid mock controllers.
Generates the fakes package so that the mocks completely implement the
Controllers, Clients and Cache interfaces.
2023-06-29 16:24:29 -04:00
Kevin Joiner 423d848a8f Adds impersonation for clients.
This commit imports new lasso changes to allow users to create a new
client that impersonates requests for specified user.
2023-06-29 16:24:29 -04:00
Brad Davidson 80fdf092be Fix schema generation for IntOrString
The IntOrString type is currently generated as a string, which is
incorrect. It should use the XIntOrString bool to specify that either
integer or string values are allowed.

Ref:
* https://github.com/kubernetes/apiextensions-apiserver/blob/v0.24.0/pkg/apis/apiextensions/v1/types_jsonschema.go#L107-L120

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2023-04-19 10:35:38 -07:00
Mario Manno 837dadbbbc Add documentation to name.Limit
* The func will crash with a runtime error for count <= 5.
* If count is 6, the result will have a leading dash.
* If len(string) == count, it will not return the original string, instead
it appends a hash.
2023-03-29 17:37:46 +02:00
Kevin Joiner 03000c9308 Removes git pkg. 2023-03-29 07:48:14 -04:00
Kevin Joiner 01ecd49211 Add test to Controller implemented Client methods. 2023-03-08 10:07:39 -05:00
Kevin Joiner fc1fea5cad Add fake package for creating generic mocks for controllers, Clients, and Caches.
To support easy mocking generic interfaces were added for controllers and caches.
And generated code now uses these interfaces instead of the generic structure.
This commit also adds code comments to the generated interfaces, and a README for the fake package.
2023-03-03 12:25:50 -05:00
Kevin Joiner 8a99fb5ad2 Refactor generated controllers and caches to call the generic functions.
Moved Controler and Cache implmentations from template strings in ype_go.go
to generic/controller.go and generic/cache.go. The generation
of type specific interface was left so that dependent packages do not
experince any breaking changes.
2023-03-03 12:15:32 -05:00
Kevin Joiner eb2b386988 Code cleanup.
Removes unused member variables
`InformersPackage` `ClientsPackage` & `ListersPackage` from pkg/args.Group.
These variables were previously used to create import statements in our generated code.
Though the refactor in #85 made the variables obsolete.

Removes the generated function DeepCopy<type>OnChange.
This function is unused by our rancher products and does not work as initially intended.
This function's original intent was to be a helper function that creates
a Handler that modifies a copy of the provided object and then
updates the object if the modification produces a change.
This function was modified in 2044a7b2bb
so that it no longer returns a handler.
2023-03-03 12:15:32 -05:00