MCPcopy
hub / github.com/containerd/containerd / init

Function init

plugins/transfer/plugin.go:47–102  ·  view source on GitHub ↗

Register local transfer service plugin

()

Source from the content-addressed store, hash-verified

45
46// Register local transfer service plugin
47func 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
104func configureUnpackPlatforms(ic *plugin.InitContext, ms *metadata.DB, config *transferConfig, lc *local.TransferConfig) error {

Callers

nothing calls this directly

Calls 7

NewFunction · 0.92
NewTransferServiceFunction · 0.92
NewImageStoreFunction · 0.92
configureUnpackPlatformsFunction · 0.85
defaultConfigFunction · 0.70
RegisterMethod · 0.65
ContentStoreMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…