Skip to content

Commit

Permalink
Make sure we pass the live config to the conversion webhook
Browse files Browse the repository at this point in the history
This makes sure we pass the "live" configuration to the conversion
webhook. Without this, that controller doesn't see any changes on the
`feature-flags` configmap, and thus only uses the default value.

This is a relatively big problem if some part of the conversion
depends on it (which was the case for `embedded-status` for example)
as it would cause loss of data.

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
  • Loading branch information
vdemeester authored and tekton-robot committed Mar 29, 2023
1 parent 9ff6034 commit eae5c3a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ func newConversionController(ctx context.Context, cmw configmap.Watcher) *contro
resolutionv1alpha1GroupVersion = resolutionv1alpha1.SchemeGroupVersion.Version
resolutionv1beta1GroupVersion = resolutionv1beta1.SchemeGroupVersion.Version
)
// Decorate contexts with the current state of the config.
store := defaultconfig.NewStore(logging.FromContext(ctx).Named("config-store"))
store.WatchConfigs(cmw)
return conversion.NewConversionController(ctx,
// The path on which to serve the webhook
"/resource-conversion",
Expand Down Expand Up @@ -209,7 +212,7 @@ func newConversionController(ctx context.Context, cmw configmap.Watcher) *contro

// A function that infuses the context passed to ConvertTo/ConvertFrom/SetDefaults with custom metadata
func(ctx context.Context) context.Context {
return ctx
return store.ToContext(ctx)
},
)
}
Expand Down

0 comments on commit eae5c3a

Please sign in to comment.