Skip to content

refactor(cloud/certificate): Migrate final errors to typed vars#2783

Open
robaa12 wants to merge 5 commits intounikraft:stagingfrom
robaa12:issue-102-errors-pr2-certificate
Open

refactor(cloud/certificate): Migrate final errors to typed vars#2783
robaa12 wants to merge 5 commits intounikraft:stagingfrom
robaa12:issue-102-errors-pr2-certificate

Conversation

@robaa12
Copy link
Copy Markdown
Contributor

@robaa12 robaa12 commented Apr 9, 2026

Prerequisite checklist

Description of changes

This PR is a scoped follow-up for #102 , focused on internal/cli/kraft/cloud/certificate/*.
It migrates non-wrapped final errors to typed package-level errors using errors.go per touched subpackage.

Updated subpackages:

  • internal/cli/kraft/cloud/certificate/list
  • internal/cli/kraft/cloud/certificate/get
  • internal/cli/kraft/cloud/certificate/remove
  • internal/cli/kraft/cloud/certificate/create

What changed:

  • Added package-level errors.go files in each subpackage above.
  • Replaced non-wrapped final fmt.Errorf("...") returns with typed errors.
  • Kept wrapped operational/contextual errors (...: %w) unchanged.
  • Preserved contextual details where appropriate by wrapping typed errors.

robaa12 added 4 commits April 9, 2026 12:43
Convert non-wrapped final output validation error to a
typed package-level error and preserve context via %w
wrapping.

Signed-off-by: robaa12 <arobaa23@gmail.com>
Convert non-wrapped final output validation error to a
typed package-level error and preserve context via %w
wrapping.

Signed-off-by: robaa12 <arobaa23@gmail.com>
Convert non-wrapped final validation errors in remove
to typed package-level errors while preserving existing
behavior and %w wrapping.

Signed-off-by: robaa12 <arobaa23@gmail.com>
Convert non-wrapped final validation and parse errors
to typed package-level errors and keep wrapped
operational errors unchanged.

Signed-off-by: robaa12 <arobaa23@gmail.com>
@craciunoiuc
Copy link
Copy Markdown
Member

Hmm, I meant per command block, so in this case cloud/certificate for example

@robaa12
Copy link
Copy Markdown
Contributor Author

robaa12 commented Apr 9, 2026

Got it , Just to confirm the implementation direction for both PRs (cloud/scale and cloud/certificate):

Would it be acceptable to centralize typed errors in a dedicated subpackage:

internal/cli/kraft/cloud/scale/scaleerr/errors.go
internal/cli/kraft/cloud/certificate/certerr/errors.go

The reason for a dedicated subpackage rather than a plain errors.go directly inside scale/certificate is to avoid Go import cycles , the command-block package already imports its subcommands, so subcommands can't import it back. A sibling scaleerr/certerr package sidesteps this cleanly.

If this looks good, I'll apply the refactor consistently across both PRs.

Move typed errors to a shared cloud/certificate error package
and update subcommands to import this central taxonomy.
This keeps errors consistent per command block without
introducing package import cycles.

Signed-off-by: robaa12 <arobaa23@gmail.com>
@robaa12
Copy link
Copy Markdown
Contributor Author

robaa12 commented Apr 12, 2026

Hey , @craciunoiuc
Done! Moved typed errors into internal/cli/kraft/cloud/certificate/certerr/errors.go and updated create/get/list/remove to use certerr.Err.... Removed all per-subcommand errors.go files.

Went with a certerr subpackage rather than package certificate directly to avoid import cycles while keeping everything centralized at the command-block level. Let me know if you'd like anything adjusted!

Could you please take another look and confirm this matches what you had in mind?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🧊 Icebox

Development

Successfully merging this pull request may close these issues.

2 participants