Commit Graph

4 Commits

Author SHA1 Message Date
caliskanugur d3471575e7 Add rbac, cluster.cattle.io and batch controllers and to the new
context, add missing sessions for controllers
2025-02-21 10:58:09 -05:00
Daniel Newman b858dcea51 Add go fmt command to generator.go
The update includes a go fmt command in the generator.go file. This command automatically formats the code according to Go conventions, thereby improving the readability and maintainability of the codebase.

Remove redundant return statement in codegen

The change eliminates a redundant return statement from the main codegen function. This simplifies the function control flow and makes the code cleaner.

Refactor imports and improve test session handling in controllers

The commit addresses two core areas: First, it improves the import structure of the generated controllers throughout various packages, particularly in relation to specific wrangler package types. Secondly, it unifies test session handling for all dynamically generated controller paths, replacing individual controller-based processing functions with a universal implementation for added consistency and reduced redundancy.

Added documentation

Refactor test session related functions in codegen

The code has been refactored to generalize the function of adding test sessions to different controllers. The functions for importing test session in each controller were renamed and refactored into a unified function, which is now called inside each controller-specific function. This approach aims to reduce code repetition and complexity.

Add session to struct and function in generated files

Expanded the appendSessionToStructInFile function to appendNewlineToBlockInFile, which generalizes line additions to the end of any struct or function block. This update improves code reusability. Utilized this function to add a session to multiple generated interface files.

Add session to struct in management controllers

A new function has been implemented to append a session to a struct in the management controllers. The function reads a file, locates a given struct, and then adds a new session prior to the closing brace of the struct. This change will be beneficial for the management of sessions within the struct.

Refactor import addition function for error handling

Updated the addImport function in codegen/main.go to handle and return errors instead of triggering panic. This change also includes verification of the import path and logic adjustments for adding a new import to the parsed file. These updates ensure more robust and error-resistant code execution.

Add 'session' import to controller files

This commit introduces additional functions to automatically add 'session' imports into controller files. Functions have been added to process and add this import into management, apps, and core controller files specifically. The new functions will walk the respective directory's file-paths and add the specified import to all 'interface.go' files.

Refactor factory method parameter replacement in codegen

The factory methods in the code generator have been refactored. The parameters passed into these methods have been modified to include the timestamp (TS) option. Also, excess white space in the code has been removed to adhere to clean coding principles.
2024-07-23 19:43:19 -05:00
vardhaman22 3b57b936cc Update dependencies, fix generation issues, and clean up Go modules
- Skip setpodsecuritypolicytemplate resource action
- Upgrade wrangler from v2 to v3
- Update rancher/pkg/apis with custom fork
- Fix generation issues
- Run go generate
- Perform go mod tidy
2024-06-21 22:24:41 +05:30
Daniel Newman bc4c88e032 Added Apps interface to Wrangler context
Replace imports with shepherd packages and added test session

Generate k8s Apps/v1 controller

Fixed missing argument

Refactor package import paths and remove unused variable

The import paths for "controllers/core" and "controllers/core/v1" have been changed from "github.com/rancher/wrangler/v2/pkg/generated" to "github.com/rancher/shepherd/pkg/generated". Also, the unused variable `opt` has been removed from the file, and factory creation logic has been modified to use `opts` instead of the removed `opt`.

Add LimitRange and ResourceQuota interfaces and controllers

This commit introduced interfaces and controllers for LimitRange and ResourceQuota. It also updated the generated controllers for core API types including Event, Node, Namespace, Pod, Service, Secret, and more. The change is part of expanding the capability of the Dynamic REST Mapper by integrating these core Kubernetes resource types.

Generated core/v1 controllers

Added corev1 controller code generation

Temporarily commented out client generation code.
2024-06-12 21:34:08 -05:00