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

feat: add shared tls package for reading TLS config from environment#3324

Merged
knative-prow[bot] merged 2 commits intoknative:mainknative/pkg:mainfrom
Fedosin:tls-optsFedosin/knative-pkg:tls-optsCopy head branch name to clipboard
Mar 2, 2026
Merged

feat: add shared tls package for reading TLS config from environment#3324
knative-prow[bot] merged 2 commits intoknative:mainknative/pkg:mainfrom
Fedosin:tls-optsFedosin/knative-pkg:tls-optsCopy head branch name to clipboard

Conversation

@Fedosin
Copy link
Copy Markdown
Contributor

@Fedosin Fedosin commented Feb 27, 2026

Changes

Extract TLS configuration parsing into a reusable knative.dev/pkg/tls package so that any Knative component (not just webhooks) can read TLS_MIN_VERSION, TLS_MAX_VERSION, TLS_CIPHER_SUITES, and TLS_CURVE_PREFERENCES from environment variables with an optional prefix.

The webhook package is updated to use the new tls package, extending env var support from just WEBHOOK_TLS_MIN_VERSION to all four WEBHOOK_TLS_* variables. Programmatic Options values continue to take precedence over environment variables.

/kind enhancement

Fixes #

Release Note

Add new `knative.dev/pkg/tls` package for shared TLS configuration. Webhook now supports `WEBHOOK_TLS_MAX_VERSION`, `WEBHOOK_TLS_CIPHER_SUITES`, and `WEBHOOK_TLS_CURVE_PREFERENCES` environment variables in addition to the existing `WEBHOOK_TLS_MIN_VERSION`.

Docs


@knative-prow knative-prow Bot requested review from Cali0707 and skonto February 27, 2026 09:37
@knative-prow knative-prow Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Feb 27, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.87%. Comparing base (b239e96) to head (9243d2e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3324      +/-   ##
==========================================
+ Coverage   74.63%   74.87%   +0.24%     
==========================================
  Files         188      189       +1     
  Lines        8219     8299      +80     
==========================================
+ Hits         6134     6214      +80     
  Misses       1844     1844              
  Partials      241      241              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Fedosin Fedosin force-pushed the tls-opts branch 5 times, most recently from 62d1981 to 554c259 Compare February 27, 2026 11:26
Extract TLS configuration parsing into a reusable knative.dev/pkg/tls
package so that any Knative component (not just webhooks) can read
TLS_MIN_VERSION, TLS_MAX_VERSION, TLS_CIPHER_SUITES, and
TLS_CURVE_PREFERENCES from environment variables with an optional prefix.

The webhook package is updated to use the new tls package, extending env
var support from just WEBHOOK_TLS_MIN_VERSION to all four WEBHOOK_TLS_*
variables. Programmatic Options values continue to take precedence over
environment variables.

Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>
Copy link
Copy Markdown
Contributor

@twoGiants twoGiants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job @Fedosin ! 👍

See my comments below.

webhook_test.go is not yet reviewed. Will do after lunch 🥘 😺

Comment thread tls/config_test.go
Comment thread tls/config_test.go
Comment thread webhook/env.go Outdated
Comment thread tls/config.go Outdated
Comment thread webhook/webhook.go
Comment thread webhook/webhook.go
Copy link
Copy Markdown
Contributor

@twoGiants twoGiants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, done. Tests are great!

See my few comments.

Comment thread webhook/webhook_test.go Outdated
Comment thread webhook/webhook_test.go Outdated
Reduce the public API surface of the tls package by unexporting
ParseVersion, ParseCipherSuites, and ParseCurvePreferences since they
are implementation details of NewConfigFromEnv.

Also validate that TLS max version is not smaller than min version in
webhook.New(), document the Options TLS field precedence
(programmatic > env vars > defaults), and broaden TestConfig_TLSConfig
to exercise the full NewConfigFromEnv → TLSConfig path.

Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>
Copy link
Copy Markdown
Contributor

@twoGiants twoGiants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve
/lgtm

@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Mar 2, 2026
Copy link
Copy Markdown
Member

@Cali0707 Cali0707 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented Mar 2, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Cali0707, Fedosin, twoGiants

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 2, 2026
@knative-prow knative-prow Bot merged commit f62171b into knative:main Mar 2, 2026
38 checks passed
@Fedosin Fedosin deleted the tls-opts branch March 2, 2026 14:18
@dprotaso
Copy link
Copy Markdown
Member

dprotaso commented Mar 8, 2026

Can we move this package under knative.dev/pkg/network/tls ?

Fedosin added a commit to Fedosin/knative-pkg that referenced this pull request Mar 18, 2026
…native#3324)

* feat: add shared tls package for reading TLS config from environment

Extract TLS configuration parsing into a reusable knative.dev/pkg/tls
package so that any Knative component (not just webhooks) can read
TLS_MIN_VERSION, TLS_MAX_VERSION, TLS_CIPHER_SUITES, and
TLS_CURVE_PREFERENCES from environment variables with an optional prefix.

The webhook package is updated to use the new tls package, extending env
var support from just WEBHOOK_TLS_MIN_VERSION to all four WEBHOOK_TLS_*
variables. Programmatic Options values continue to take precedence over
environment variables.

Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>

* fix: address review feedback on tls package

Reduce the public API surface of the tls package by unexporting
ParseVersion, ParseCipherSuites, and ParseCurvePreferences since they
are implementation details of NewConfigFromEnv.

Also validate that TLS max version is not smaller than min version in
webhook.New(), document the Options TLS field precedence
(programmatic > env vars > defaults), and broaden TestConfig_TLSConfig
to exercise the full NewConfigFromEnv → TLSConfig path.

Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>

---------

Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>
knative-prow Bot pushed a commit that referenced this pull request Mar 19, 2026
* feat: add shared tls package for reading TLS config from environment (#3324)

* feat: add shared tls package for reading TLS config from environment

Extract TLS configuration parsing into a reusable knative.dev/pkg/tls
package so that any Knative component (not just webhooks) can read
TLS_MIN_VERSION, TLS_MAX_VERSION, TLS_CIPHER_SUITES, and
TLS_CURVE_PREFERENCES from environment variables with an optional prefix.

The webhook package is updated to use the new tls package, extending env
var support from just WEBHOOK_TLS_MIN_VERSION to all four WEBHOOK_TLS_*
variables. Programmatic Options values continue to take precedence over
environment variables.

Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>

* fix: address review feedback on tls package

Reduce the public API surface of the tls package by unexporting
ParseVersion, ParseCipherSuites, and ParseCurvePreferences since they
are implementation details of NewConfigFromEnv.

Also validate that TLS max version is not smaller than min version in
webhook.New(), document the Options TLS field precedence
(programmatic > env vars > defaults), and broaden TestConfig_TLSConfig
to exercise the full NewConfigFromEnv → TLSConfig path.

Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>

---------

Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>

* Replace NewConfigFromEnv with DefaultConfigFromEnv (#3328)

DefaultConfigFromEnv replaces NewConfigFromEnv by returning a full
default tls.Config with overrides from env vars. This avoids specifying
e.g. the TLS MinVersion explicitely.

* Move tls package to network/tls, keep aliases for backward compatibility (#3331)

The TLS configuration package is moved from tls/ to network/tls/ to
co-locate it with the rest of the networking code. The old tls/ package
now re-exports all public symbols as deprecated aliases so that existing
consumers continue to compile without changes. The webhook package is
updated to import from the new location directly.

Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>

* remove deprecated TLS package (#3333)

---------

Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>
Co-authored-by: Vincent Link <linkvt@users.noreply.github.com>
Co-authored-by: Dave Protasowski <dprotaso@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/enhancement lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

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