MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / NewTLSConfigForContext

Function NewTLSConfigForContext

pkg/certs/tls.go:116–127  ·  view source on GitHub ↗

NewTLSConfigForContext creates a tls.Config from the given options and stores it in the returned context.

(ctx context.Context, opts TLSConfigOptions)

Source from the content-addressed store, hash-verified

114// NewTLSConfigForContext creates a tls.Config from the given options and stores it
115// in the returned context.
116func NewTLSConfigForContext(ctx context.Context, opts TLSConfigOptions) (context.Context, error) {
117 conf, err := newTLSConfigFromSecret(ctx, opts)
118 if err != nil {
119 return ctx, err
120 }
121
122 if opts.ClientCert != nil {
123 conf.Certificates = []tls.Certificate{*opts.ClientCert}
124 }
125
126 return context.WithValue(ctx, contextKeyTLSConfig, conf), nil
127}
128
129// GetTLSConfigFromContext returns the *tls.Config contained by the context or any error encountered
130func GetTLSConfigFromContext(ctx context.Context) (*tls.Config, error) {

Callers 3

reconcileMethod · 0.92
ReconcileMethod · 0.92
statusSubCommandFunction · 0.92

Calls 1

newTLSConfigFromSecretFunction · 0.85

Tested by

no test coverage detected