Register local transfer service plugin
()
| 45 | |
| 46 | // Register local transfer service plugin |
| 47 | func init() { |
| 48 | registry.Register(&plugin.Registration{ |
| 49 | Type: plugins.TransferPlugin, |
| 50 | ID: "local", |
| 51 | Requires: []plugin.Type{ |
| 52 | plugins.LeasePlugin, |
| 53 | plugins.MetadataPlugin, |
| 54 | plugins.DiffPlugin, |
| 55 | plugins.ImageVerifierPlugin, |
| 56 | plugins.SnapshotPlugin, |
| 57 | }, |
| 58 | Config: defaultConfig(), |
| 59 | InitFn: func(ic *plugin.InitContext) (any, error) { |
| 60 | config := ic.Config.(*transferConfig) |
| 61 | m, err := ic.GetSingle(plugins.MetadataPlugin) |
| 62 | if err != nil { |
| 63 | return nil, err |
| 64 | } |
| 65 | ms := m.(*metadata.DB) |
| 66 | |
| 67 | var lc local.TransferConfig |
| 68 | |
| 69 | l, err := ic.GetSingle(plugins.LeasePlugin) |
| 70 | if err != nil { |
| 71 | return nil, err |
| 72 | } |
| 73 | lc.Leases = l.(leases.Manager) |
| 74 | |
| 75 | vps, err := ic.GetByType(plugins.ImageVerifierPlugin) |
| 76 | if err != nil && !errors.Is(err, plugin.ErrPluginNotFound) { |
| 77 | return nil, err |
| 78 | } |
| 79 | if len(vps) > 0 { |
| 80 | lc.Verifiers = make(map[string]imageverifier.ImageVerifier) |
| 81 | for name, vp := range vps { |
| 82 | lc.Verifiers[name] = vp.(imageverifier.ImageVerifier) |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | // Set configuration based on default or user input |
| 87 | lc.MaxConcurrentDownloads = config.MaxConcurrentDownloads |
| 88 | lc.ConcurrentLayerFetchBuffer = config.ConcurrentLayerFetchBuffer |
| 89 | |
| 90 | lc.MaxConcurrentUploadedLayers = config.MaxConcurrentUploadedLayers |
| 91 | lc.MaxConcurrentUnpacks = config.MaxConcurrentUnpacks |
| 92 | |
| 93 | if err := configureUnpackPlatforms(ic, ms, config, &lc); err != nil { |
| 94 | return nil, err |
| 95 | } |
| 96 | lc.RegistryConfigPath = config.RegistryConfigPath |
| 97 | lc.DuplicationSuppressor = kmutex.New() |
| 98 | |
| 99 | return local.NewTransferService(ms.ContentStore(), metadata.NewImageStore(ms), lc), nil |
| 100 | }, |
| 101 | }) |
| 102 | } |
| 103 | |
| 104 | func configureUnpackPlatforms(ic *plugin.InitContext, ms *metadata.DB, config *transferConfig, lc *local.TransferConfig) error { |
nothing calls this directly
no test coverage detected
searching dependent graphs…