Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Consolidate TLS secret fetching into clientutil and simplify handlers#206

Open
felix-kaestner wants to merge 1 commit intomainironcore-dev/network-operator:mainfrom
refactor/provisioning-serverironcore-dev/network-operator:refactor/provisioning-serverCopy head branch name to clipboard
Open

Consolidate TLS secret fetching into clientutil and simplify handlers#206
felix-kaestner wants to merge 1 commit intomainironcore-dev/network-operator:mainfrom
refactor/provisioning-serverironcore-dev/network-operator:refactor/provisioning-serverCopy head branch name to clipboard

Conversation

@felix-kaestner
Copy link
Contributor

The provisioning HTTP handlers duplicated Kubernetes secret-fetching logic that already existed in the clientutil package. Additionally, HandleProvisioningRequest called deviceutil.GetDeviceConnection to obtain credentials, which unnecessarily loads TLS certificates when only BasicAuth username and password are needed.

Introduce a lower-level TLSSecretPEM() method in clientutil that returns raw PEM bytes (tls.crt, tls.key, and optionally ca.crt) from a TLS secret, and refactor the existing Certificate() method to use it internally. This layered approach avoids breaking existing callers while enabling the provisioning handlers to access raw PEM data without parsing into tls.Certificate.

Replace manual secret fetching in GetDeviceCertificate and GetMTLSClientCA with calls to TLSSecretPEM(). Replace the GetDeviceConnection call in HandleProvisioningRequest with a direct BasicAuth() call, adding a nil guard for the optional SecretRef pointer.

The provisioning HTTP handlers duplicated Kubernetes secret-fetching
logic that already existed in the clientutil package. Additionally,
HandleProvisioningRequest called deviceutil.GetDeviceConnection to
obtain credentials, which unnecessarily loads TLS certificates when
only BasicAuth username and password are needed.

Introduce a lower-level TLSSecretPEM() method in clientutil that
returns raw PEM bytes (tls.crt, tls.key, and optionally ca.crt) from
a TLS secret, and refactor the existing Certificate() method to use
it internally. This layered approach avoids breaking existing callers
while enabling the provisioning handlers to access raw PEM data
without parsing into tls.Certificate.

Replace manual secret fetching in GetDeviceCertificate and
GetMTLSClientCA with calls to TLSSecretPEM(). Replace the
GetDeviceConnection call in HandleProvisioningRequest with a direct
BasicAuth() call, adding a nil guard for the optional SecretRef
pointer.
@felix-kaestner felix-kaestner requested a review from a team as a code owner March 4, 2026 22:24
@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Merging this branch changes the coverage (1 decrease, 1 increase)

Impacted Packages Coverage Δ 🤖
github.com/ironcore-dev/network-operator/internal/clientutil 90.91% (+1.87%) 👍
github.com/ironcore-dev/network-operator/internal/provisioning 76.79% (-1.25%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/ironcore-dev/network-operator/internal/clientutil/clientutil.go 90.91% (+1.87%) 77 (+4) 70 (+5) 7 (-1) 👍
github.com/ironcore-dev/network-operator/internal/provisioning/http.go 76.79% (-1.25%) 237 (-18) 182 (-17) 55 (-1) 👎

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/ironcore-dev/network-operator/internal/clientutil/clientutil_test.go
  • github.com/ironcore-dev/network-operator/internal/provisioning/http_test.go

@felix-kaestner felix-kaestner enabled auto-merge (rebase) March 4, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.