plugin

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2024 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const PluginRootDirSymbol = "PluginRootDir"

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.

View Source
const PluginSymbol = "Plugin"

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

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback interface{}

Callback defines a plugin callback. Available callbacks are defined in pkg/plugin/callback.

type Manifest

type Manifest struct {
	// Name is, by convention, a fully-qualified domain name which uniquely identifies a plugin.
	// This convention is not enforced, but rather is best practice.
	//
	// Good Names:
	//     - sylabs.io/test-plugin
	//     - github.com/user/repo
	//
	// Bad Names:
	//     - test-plugin
	Name string `json:"name"`
	// Author of the plugin.
	Author string `json:"author"`
	// Version describes the SemVer of the plugin.
	Version string `json:"version"`
	// Description describes the plugin.
	Description string `json:"description"`
}

Manifest is the plugin manifest, stored as a data object in the plugin SIF.

type Plugin

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
}

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
}

Directories

Path Synopsis
callback
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL