(ic *plugin.InitContext, ms *metadata.DB, config *transferConfig, lc *local.TransferConfig)
| 102 | } |
| 103 | |
| 104 | func configureUnpackPlatforms(ic *plugin.InitContext, ms *metadata.DB, config *transferConfig, lc *local.TransferConfig) error { |
| 105 | // If UnpackConfiguration is not defined, set the default. |
| 106 | // If UnpackConfiguration is defined and empty, ignore. |
| 107 | if config.UnpackConfiguration == nil { |
| 108 | config.UnpackConfiguration = defaultUnpackConfig() |
| 109 | } |
| 110 | for _, uc := range config.UnpackConfiguration { |
| 111 | p, err := platforms.Parse(uc.Platform) |
| 112 | if err != nil { |
| 113 | return fmt.Errorf("%s: platform configuration %v invalid", plugins.TransferPlugin, uc.Platform) |
| 114 | } |
| 115 | |
| 116 | sn := ms.Snapshotter(uc.Snapshotter) |
| 117 | if sn == nil { |
| 118 | if uc.Optional { |
| 119 | continue |
| 120 | } |
| 121 | return fmt.Errorf("snapshotter %q not found: %w", uc.Snapshotter, errdefs.ErrNotFound) |
| 122 | } |
| 123 | var ( |
| 124 | snExports map[string]string |
| 125 | snCapabilities []string |
| 126 | ) |
| 127 | if p := ic.Plugins().Get(plugins.SnapshotPlugin, uc.Snapshotter); p != nil { |
| 128 | snExports = p.Meta.Exports |
| 129 | snCapabilities = p.Meta.Capabilities |
| 130 | } |
| 131 | |
| 132 | applier, skip, err := getApplier(ic, uc, p) |
| 133 | if err != nil { |
| 134 | return err |
| 135 | } |
| 136 | if skip { |
| 137 | continue |
| 138 | } |
| 139 | if applier == nil { |
| 140 | if uc.Optional { |
| 141 | continue |
| 142 | } |
| 143 | return fmt.Errorf("no matching diff plugins: %w", errdefs.ErrNotFound) |
| 144 | } |
| 145 | |
| 146 | target := platforms.Only(p) |
| 147 | // If CheckPlatformSupported is false, platforms.OnlyOS() is applied |
| 148 | if !config.CheckPlatformSupported { |
| 149 | target = platforms.OnlyOS(p) |
| 150 | } |
| 151 | |
| 152 | up := unpack.Platform{ |
| 153 | Platform: target, |
| 154 | SnapshotterKey: uc.Snapshotter, |
| 155 | Snapshotter: sn, |
| 156 | SnapshotterExports: snExports, |
| 157 | SnapshotterCapabilities: snCapabilities, |
| 158 | Applier: applier, |
| 159 | ConfigType: uc.ConfigType, |
| 160 | LayerTypes: uc.LayerTypes, |
| 161 | } |
searching dependent graphs…