File: plugin.go

package info (click to toggle)
apptainer 1.4.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,748 kB
  • sloc: sh: 3,321; ansic: 1,706; awk: 414; python: 103; makefile: 54
file content (68 lines) | stat: -rw-r--r-- 2,490 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) Contributors to the Apptainer project, established as
//   Apptainer a Series of LF Projects LLC.
//   For website terms of use, trademark policy, privacy policy and other
//   project policies see https://lfprojects.org/policies
// Copyright (c) 2018-2022, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the URIs of this project regarding your
// rights to use or distribute this software.

package plugin

// PluginRootDirSymbol is the name of a variable of type string which
// a plugin may define if it want to obtain the plugin root directory.
// Concatenated with the manifest name it allows to retrieve the path
// where the plugin is currently installed.
const PluginRootDirSymbol = "PluginRootDir"

// PluginSymbol is the name of a variable of type plugin.Plugin which all
// plugin implementations MUST define.
const PluginSymbol = "Plugin"

// Plugin is the "meta-type" which encompasses the plugins
// implementation through Callbacks and a Manifest
// (potentially more to be added). The plugin implementation must
// have an exported symbol named "Plugin" of this type.
//
// An example of how this will look from the plugin main package:
//
//	package main
//
//	import (
//	    clicallback "github.com/apptainer/apptainer/pkg/callback/cli"
//	    pluginapi "github.com/apptainer/apptainer/pkg/plugin"
//	)
//
//	var Plugin = pluginapi.Plugin{
//	    Manifest: pluginapi.Manifest{
//	        Name:        "PluginExample",
//	        Author:      "Sylabs Team",
//	        Version:     "v0.0.1",
//	        Description: "This is an example plugin",
//	    },
//	    Callbacks: []pluginapi.Callback{
//	        (clicallback.Command)(callbackRegisterCmd),
//	    },
//	}
//
//	func callbackRegisterCmd(manager *cmdline.CommandManager) {
//	    // Do command registration
//	}
type Plugin struct {
	// Manifest contains the plugin manifest holding
	// basic information about the plugin.
	Manifest
	// Callbacks contains plugin callbacks to be called
	// by Apptainer.
	Callbacks []Callback
	// Install is a function called during apptainer
	// plugin install, the function take the directory
	// where plugin object will reside and can be used
	// to store configuration files/data needed by a
	// plugin.
	Install func(string) error
}

// Callback defines a plugin callback. Available callbacks are
// defined in pkg/plugin/callback.
type Callback interface{}