()
| 60 | } |
| 61 | |
| 62 | func init() { |
| 63 | registry.Register(&plugin.Registration{ |
| 64 | Type: plugins.RuntimePluginV2, |
| 65 | ID: "task", |
| 66 | Requires: []plugin.Type{ |
| 67 | plugins.ShimPlugin, |
| 68 | plugins.MountManagerPlugin, |
| 69 | plugins.WarningPlugin, |
| 70 | }, |
| 71 | Config: &TaskConfig{ |
| 72 | Platforms: defaultPlatforms(), |
| 73 | }, |
| 74 | InitFn: func(ic *plugin.InitContext) (any, error) { |
| 75 | config := ic.Config.(*TaskConfig) |
| 76 | |
| 77 | supportedPlatforms, err := platforms.ParseAll(config.Platforms) |
| 78 | if err != nil { |
| 79 | return nil, err |
| 80 | } |
| 81 | ic.Meta.Platforms = supportedPlatforms |
| 82 | if ic.Meta.Exports == nil { |
| 83 | ic.Meta.Exports = make(map[string]string, 1) |
| 84 | } |
| 85 | ic.Meta.Exports["log-uri-schemes"] = strings.Join(supportedLogURISchemes(), ",") |
| 86 | |
| 87 | shimManagerI, err := ic.GetSingle(plugins.ShimPlugin) |
| 88 | if err != nil { |
| 89 | return nil, err |
| 90 | } |
| 91 | shimManager := shimManagerI.(*ShimManager) |
| 92 | |
| 93 | var mounts mount.Manager |
| 94 | if mountsI, err := ic.GetSingle(plugins.MountManagerPlugin); err == nil { |
| 95 | mounts = mountsI.(mount.Manager) |
| 96 | } else if !errors.Is(err, plugin.ErrPluginNotFound) { |
| 97 | return nil, err |
| 98 | } |
| 99 | root, state := ic.Properties[plugins.PropertyRootDir], ic.Properties[plugins.PropertyStateDir] |
| 100 | for _, d := range []string{root, state} { |
| 101 | // root: the parent of this directory is created as 0o700, not 0o711. |
| 102 | // state: the parent of this directory is created as 0o711 too, so as to support userns-remapped containers. |
| 103 | if err := os.MkdirAll(d, 0711); err != nil { |
| 104 | return nil, err |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | if err := shimManager.LoadExistingShims(ic.Context, state, root); err != nil { |
| 109 | return nil, fmt.Errorf("failed to load existing shims for task manager") |
| 110 | } |
| 111 | |
| 112 | warningsI, err := ic.GetSingle(plugins.WarningPlugin) |
| 113 | if err != nil { |
| 114 | return nil, err |
| 115 | } |
| 116 | warnings := warningsI.(warning.Service) |
| 117 | emitPlatformWarnings(ic.Context, warnings) |
| 118 | |
| 119 | return &TaskManager{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…