newProvider is used to create a new certificate provider plugin after validating the options, and hence does not return an error.
(o Options)
| 107 | // newProvider is used to create a new certificate provider plugin after |
| 108 | // validating the options, and hence does not return an error. |
| 109 | func newProvider(o Options) certprovider.Provider { |
| 110 | if o.RefreshDuration == 0 { |
| 111 | o.RefreshDuration = defaultCertRefreshDuration |
| 112 | } |
| 113 | |
| 114 | provider := &watcher{opts: o} |
| 115 | if o.CertFile != "" && o.KeyFile != "" { |
| 116 | provider.identityDistributor = newDistributor() |
| 117 | } |
| 118 | if o.RootFile != "" || o.SPIFFEBundleMapFile != "" { |
| 119 | provider.rootDistributor = newDistributor() |
| 120 | } |
| 121 | |
| 122 | ctx, cancel := context.WithCancel(context.Background()) |
| 123 | provider.cancel = cancel |
| 124 | go provider.run(ctx) |
| 125 | return provider |
| 126 | } |
| 127 | |
| 128 | // watcher is a certificate provider plugin that implements the |
| 129 | // certprovider.Provider interface. It watches a set of certificate and key |
no test coverage detected