Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change "Unable to Load Boilerplate" Error to Warning #4507

Open
camilamacedo86 opened this issue Jan 19, 2025 · 2 comments · May be fixed by #4518
Open

Change "Unable to Load Boilerplate" Error to Warning #4507

camilamacedo86 opened this issue Jan 19, 2025 · 2 comments · May be fixed by #4518
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature.

Comments

@camilamacedo86
Copy link
Member

What do you want to happen?

A missing boilerplate file is a non-critical issue that does not prevent scaffolding from proceeding. Instead of halting execution, Kubebuilder could warn the user and offer clear instructions on resolving the issue. This change would improve the developer experience and reduce unnecessary friction.

Current Behavior:

When the hack/boilerplate.go.txt file is missing, Kubebuilder throws the following error:

unable to load boilerplate: open hack/boilerplate.go.txt: no such file or directory.

This halts the scaffolding process unnecessarily, even though the absence of the boilerplate file is not critical.

Proposed Solution:

  • Change the error to a warning:

    Warning: Boilerplate file 'hack/boilerplate.go.txt' not found.  
    Please ensure it exists or update project settings if needed.  
    
  • Update all references to the boilerplate file to handle this case gracefully.

  • Makefile Update for controller-gen:
    Modify the generate target in the Makefile to check for the presence of hack/boilerplate.go.txt and proceed accordingly:

    .PHONY: generate
    generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
      if [ -f hack/boilerplate.go.txt ]; then \
        $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."; \
      else \
        echo "Warning: hack/boilerplate.go.txt not found. Skipping boilerplate header."; \
        $(CONTROLLER_GEN) paths="./..."; \
      fi
    

References:

Motivation:

  • Improves Developer Experience: Reduces unnecessary halts during scaffolding and provides clear, actionable feedback to the user.

Extra Labels

No response

@camilamacedo86 camilamacedo86 added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 19, 2025
@camilamacedo86 camilamacedo86 added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. labels Jan 19, 2025
@Niharika0306
Copy link

/assign

@sarthaksarthak9
Copy link
Contributor

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants