-
Notifications
You must be signed in to change notification settings - Fork 139
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
Adopt Kubernetes style TLS Secret #597
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to include a makefile that generates this and the other files in this directory.
Similar to https://github.com/fluxcd/source-controller/blob/aa370f284db70e09d8acb49d5bed4e42908b8cb3/internal/controller/testdata/certs/Makefile#L17-L20 .
@@ -178,7 +178,7 @@ func (r *AlertReconciler) isProviderReady(ctx context.Context, alert *apiv1beta2 | |||
providerName := types.NamespacedName{Namespace: alert.Namespace, Name: alert.Spec.ProviderRef.Name} | |||
if err := r.Get(ctx, providerName, provider); err != nil { | |||
// log not found errors since they get filtered out | |||
ctrl.LoggerFrom(ctx).Error(err, "failed to get provider %s", providerName.String()) | |||
ctrl.LoggerFrom(ctx).Error(err, fmt.Sprintf("failed to get provider '%s'", providerName.String())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In favor of structured logging I suggest:
ctrl.LoggerFrom(ctx).Error(err, fmt.Sprintf("failed to get provider '%s'", providerName.String())) | |
ctrl.LoggerFrom(ctx).Error(err, "failed to get provider", "provider", providerName.String()) |
return fmt.Errorf("no caFile found in secret %s", provider.Spec.CertSecretRef.Name) | ||
caFile, ok = secret.Data["caFile"] | ||
if !ok { | ||
return fmt.Errorf("no `ca.crt` key found in secret '%s'", provider.Spec.CertSecretRef.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Errorf("no `ca.crt` key found in secret '%s'", provider.Spec.CertSecretRef.Name) | |
return fmt.Errorf("no 'ca.crt' nor 'caFile' key found in secret", "secret", provider.Spec.CertSecretRef.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if we want to add the deprecated key caFile
to the log so as not to encourage users to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, had the same thought. Up to you.
if !ok { | ||
return fmt.Errorf("no `ca.crt` key found in secret '%s'", provider.Spec.CertSecretRef.Name) | ||
} | ||
log.Info("warning: specifying CA cert via `caFile` is deprecated, please use `ca.crt` instead") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Info("warning: specifying CA cert via `caFile` is deprecated, please use `ca.crt` instead") | |
log.Info("warning: specifying CA cert via 'caFile' is deprecated, please use 'ca.crt' instead") |
internal/server/event_handlers.go
Outdated
continue | ||
caFile, ok = secret.Data["caFile"] | ||
if !ok { | ||
alertLogger.Error(nil, "no `ca.crt` key found in secret '%s'", provider.Spec.CertSecretRef.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alertLogger.Error(nil, "no `ca.crt` key found in secret '%s'", provider.Spec.CertSecretRef.Name) | |
alertLogger.Error(nil, "no 'ca.crt' nor 'caFile' key found in secret", "secret", provider.Spec.CertSecretRef.Name) |
@@ -1042,7 +1042,7 @@ Secret in the same namespace as the Provider, containing the TLS CA certificate. | |||
#### Example | |||
|
|||
To enable notification-controller to communicate with a provider API over HTTPS | |||
using a self-signed TLS certificate, set the `caFile` like so: | |||
using a self-signed TLS certificate, set the `ca.crt` like so: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also need to add a deprecation notice for the caFile
key like the one here: https://github.com/fluxcd/source-controller/blob/main/docs/spec/v1beta2/helmrepositories.md#secret-reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad, skipped it somehow but the same goes for the API docs
015ebc4
to
0ac4494
Compare
docs/spec/v1beta2/providers.md
Outdated
**Note:** Support for the `caFile` key have been | ||
deprecated. If you have any Secrets using these keys, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**Note:** Support for the `caFile` key have been | |
deprecated. If you have any Secrets using these keys, | |
**Warning:** Support for the `caFile` key has been | |
deprecated. If you have any Secrets using this key, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, maybe mention the types of Secret that's allowed in the above section, not part of this warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Signed-off-by: Somtochi Onyekwere <[email protected]>
794d100
to
23e733b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @somtochiama 🏅
Deprecate the usage of
caFile
for the.spec.certSecretRef
secret in Provider. BothcaFile
andca.crt
keys are supported for Provider with the latter taking precedence.Part of: fluxcd/flux2#4137