docgen

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidPluginType is returned when the resolved plugin is not
	// of the allowed types.
	ErrInvalidPluginType = errors.New(
		"invalid plugin type for plugin instance, plugin must implement one of the " +
			"`provider.Provider` or `transform.SpecTransformer` interfaces",
	)

	// ErrPluginMetadataNotFound is returned when the plugin metadata
	// could not be found in the plugin manager.
	ErrPluginMetadataNotFound = errors.New(
		"plugin metadata not found, this is required to produce documentation",
	)
)

Functions

This section is empty.

Types

type AttributeType

type AttributeType struct {
	ValueTypeDefinition
	Nullable bool `json:"nullable"`
}

type FunctionDefinition

type FunctionDefinition struct {
	Parameters []*FunctionParameter `json:"parameters"`
	Return     *FunctionReturn      `json:"return"`
}

type FunctionParameter

type FunctionParameter struct {
	ParamType      string `json:"paramType"`
	Name           string `json:"name,omitempty"`
	Label          string `json:"label,omitempty"`
	Description    string `json:"description,omitempty"`
	AllowNullValue bool   `json:"allowNullValue"`
	Optional       bool   `json:"optional"`

	// This should only be present for scalar, object, function and variadic parameters.
	ValueTypeDefinition *ValueTypeDefinition `json:"valueTypeDefinition,omitempty"`

	// This should only be present for list parameters.
	ElementValueTypeDefinition *ValueTypeDefinition `json:"elementValueTypeDefinition,omitempty"`

	// This should only be present for map parameters.
	MapValueTypeDefinition *ValueTypeDefinition `json:"mapValueTypeDefinition,omitempty"`

	// This should only be present for "any" parameters that are union types.
	UnionValueTypeDefinitions []*ValueTypeDefinition `json:"unionValueTypeDefinitions,omitempty"`

	// The following fields should only present for variadic parameters.
	VariadicSingleType bool `json:"singleType,omitempty"`
	VariadicNamed      bool `json:"named,omitempty"`
}

type FunctionReturn

type FunctionReturn struct {
	ReturnType  string `json:"returnType"`
	Description string `json:"description,omitempty"`

	// This should only be present for scalar, object, function return types.
	ValueTypeDefinition *ValueTypeDefinition `json:"valueTypeDefinition,omitempty"`

	// This should only be present for list return types.
	ElementValueTypeDefinition *ValueTypeDefinition `json:"elementValueTypeDefinition,omitempty"`

	// This should only be present for map return types.
	MapValueTypeDefinition *ValueTypeDefinition `json:"mapValueTypeDefinition,omitempty"`

	// This should only be present for "any" return types that are union types.
	UnionValueTypeDefinitions []*ValueTypeDefinition `json:"unionValueTypeDefinitions,omitempty"`
}

type PluginDocResourceSpec

type PluginDocResourceSpec struct {
	Schema              *PluginDocResourceSpecSchema `json:"schema"`
	IDField             string                       `json:"idField"`
	TaggingSupport      string                       `json:"taggingSupport,omitempty"`
	DestroyBeforeCreate bool                         `json:"destroyBeforeCreate,omitempty"`
}

type PluginDocResourceSpecSchema

type PluginDocResourceSpecSchema struct {
	Type         string              `json:"type"`
	Label        string              `json:"label"`
	Description  string              `json:"description"`
	Nullable     bool                `json:"nullable"`
	Computed     bool                `json:"computed"`
	MustRecreate bool                `json:"mustRecreate"`
	Default      *core.MappingNode   `json:"default,omitempty"`
	Examples     []*core.MappingNode `json:"examples,omitempty"`

	// Validation constraints
	Minimum       *core.ScalarValue   `json:"minimum,omitempty"`
	Maximum       *core.ScalarValue   `json:"maximum,omitempty"`
	MinLength     int                 `json:"minLength,omitempty"`
	MaxLength     int                 `json:"maxLength,omitempty"`
	Pattern       string              `json:"pattern,omitempty"`
	AllowedValues []*core.MappingNode `json:"allowedValues,omitempty"`

	// Behavior flags
	Sensitive        bool   `json:"sensitive,omitempty"`
	IgnoreDrift      bool   `json:"ignoreDrift,omitempty"`
	TrackDrift       bool   `json:"trackDrift,omitempty"`
	SortArrayByField string `json:"sortArrayByField,omitempty"`

	// Required for "object" types, should be empty for other types.
	Attributes map[string]*PluginDocResourceSpecSchema `json:"attributes,omitempty"`
	// Required for "object" types, should be empty for other types.
	// This is a list of required attributes.
	Required []string `json:"required,omitempty"`

	// Required for "map" types, should be empty for other types.
	MapValues *PluginDocResourceSpecSchema `json:"mapValues,omitempty"`

	// Required for "array" types, should be empty for other types.
	Items *PluginDocResourceSpecSchema `json:"listValues,omitempty"`

	// Required for "union" types, should be empty for other types.
	OneOf []*PluginDocResourceSpecSchema `json:"oneOf,omitempty"`
}

type PluginDocs

type PluginDocs struct {
	ID               string                   `json:"id"`
	DisplayName      string                   `json:"displayName"`
	Version          string                   `json:"version"`
	ProtocolVersions []string                 `json:"protocolVersions"`
	Description      string                   `json:"description"`
	Author           string                   `json:"author"`
	Repository       string                   `json:"repository"`
	Config           *PluginDocsVersionConfig `json:"config"`

	// Required for providers, should be empty for transformers.
	Resources []*PluginDocsResource `json:"resources,omitempty"`
	// Required for providers, should be empty for transformers.
	Links []*PluginDocsLink `json:"links,omitempty"`
	// Required for providers, should be empty for transformers.
	DataSources []*PluginDocsDataSource `json:"dataSources,omitempty"`
	// Required for providers, should be empty for transformers.
	CustomVarTypes []*PluginDocsCustomVarType `json:"customVarTypes,omitempty"`
	// Required for providers, should be empty for transformers.
	Functions []*PluginDocsFunction `json:"functions,omitempty"`

	// Required for transformers, should be empty for providers.
	TransformName string `json:"transformName,omitempty"`
	// Required for transformers, should be empty for providers.
	AbstractResources []*PluginDocsResource `json:"abstractResources,omitempty"`
	// Required for transformers, should be empty for providers.
	AbstractLinks []*PluginDocsLink `json:"abstractLinks,omitempty"`
}

PluginDocs is a struct that holds the JSON representation of the plugin documentation.

func GeneratePluginDocs

func GeneratePluginDocs(
	pluginID string,
	pluginInstance any,
	manager pluginservicev1.Manager,
	envConfig *env.Config,
) (*PluginDocs, error)

GenerateProviderDocs generates documentation for a provider or transformer plugin.

type PluginDocsCustomVarType

type PluginDocsCustomVarType struct {
	Type        string                                    `json:"type"`
	Label       string                                    `json:"label"`
	Summary     string                                    `json:"summary"`
	Description string                                    `json:"description"`
	Options     map[string]*PluginDocsCustomVarTypeOption `json:"options"`
	Examples    []string                                  `json:"examples,omitempty"`
}

type PluginDocsCustomVarTypeOption

type PluginDocsCustomVarTypeOption struct {
	Label       string `json:"label"`
	Description string `json:"value"`
}

type PluginDocsDataSource

type PluginDocsDataSource struct {
	Type          string                    `json:"type"`
	Label         string                    `json:"label"`
	Summary       string                    `json:"summary"`
	Description   string                    `json:"description"`
	Specification *PluginDocsDataSourceSpec `json:"specification"`
	Examples      []string                  `json:"examples,omitempty"`
}

type PluginDocsDataSourceFieldSpec

type PluginDocsDataSourceFieldSpec struct {
	Type        string `json:"type"`
	Description string `json:"description"`
	Nullable    bool   `json:"nullable"`
	Filterable  bool   `json:"filterable"`
	Sensitive   bool   `json:"sensitive,omitempty"`
}

type PluginDocsDataSourceFilterFieldSpec

type PluginDocsDataSourceFilterFieldSpec struct {
	Type               string   `json:"type"`
	Description        string   `json:"description"`
	SupportedOperators []string `json:"supportedOperators,omitempty"`
	ConflictsWith      []string `json:"conflictsWith,omitempty"`
}

type PluginDocsDataSourceSpec

type PluginDocsDataSourceSpec struct {
	Fields       map[string]*PluginDocsDataSourceFieldSpec       `json:"fields"`
	FilterFields map[string]*PluginDocsDataSourceFilterFieldSpec `json:"filterFields,omitempty"`
}

type PluginDocsFunction

type PluginDocsFunction struct {
	FunctionDefinition
	Name        string `json:"name"`
	Summary     string `json:"summary"`
	Description string `json:"description"`
	Internal    bool   `json:"internal,omitempty"`
}
type PluginDocsLink struct {
	Type                  string                                         `json:"type"`
	Summary               string                                         `json:"summary"`
	Description           string                                         `json:"description"`
	AnnotationDefinitions map[string]*PluginDocsLinkAnnotationDefinition `json:"annotationDefinitions"`
	CardinalityA          *PluginDocsLinkCardinality                     `json:"cardinalityA,omitempty"`
	CardinalityB          *PluginDocsLinkCardinality                     `json:"cardinalityB,omitempty"`
}

type PluginDocsLinkAnnotationDefinition

type PluginDocsLinkAnnotationDefinition struct {
	Name          string              `json:"name"`
	Label         string              `json:"label"`
	Type          string              `json:"type"`
	Description   string              `json:"description"`
	Default       *core.ScalarValue   `json:"default,omitempty"`
	AllowedValues []*core.ScalarValue `json:"allowedValues,omitempty"`
	Examples      []*core.ScalarValue `json:"examples,omitempty"`
	Required      bool                `json:"required"`
	AppliesTo     string              `json:"appliesTo,omitempty"`
}

type PluginDocsLinkCardinality

type PluginDocsLinkCardinality struct {
	Min int `json:"min"`
	Max int `json:"max"`
}

type PluginDocsResource

type PluginDocsResource struct {
	Type          string                 `json:"type"`
	Label         string                 `json:"label"`
	Summary       string                 `json:"summary"`
	Description   string                 `json:"description"`
	Specification *PluginDocResourceSpec `json:"specification"`
	Examples      []string               `json:"examples"`
}

type PluginDocsVersionConfig

type PluginDocsVersionConfig struct {
	Fields                map[string]*PluginDocsVersionConfigField `json:"fields"`
	AllowAdditionalFields bool                                     `json:"allowAdditionalFields"`
}

type PluginDocsVersionConfigField

type PluginDocsVersionConfigField struct {
	Type          string              `json:"type"`
	Label         string              `json:"label"`
	Description   string              `json:"description"`
	Required      bool                `json:"required"`
	Default       *core.ScalarValue   `json:"default,omitempty"`
	AllowedValues []*core.ScalarValue `json:"allowedValues,omitempty"`
	Secret        bool                `json:"secret"`
	Examples      []*core.ScalarValue `json:"examples,omitempty"`
}

type ValueTypeDefinition

type ValueTypeDefinition struct {
	Type        string `json:"type"`
	Label       string `json:"label,omitempty"`
	Description string `json:"description,omitempty"`

	// This should only be present for "string" scalar types.
	StringChoices []string `json:"stringChoices,omitempty"`

	// This should only be present for list types.
	ElementValueTypeDefinition *ValueTypeDefinition `json:"elementValueTypeDefinition,omitempty"`

	// This should only be present for map types.
	MapValueTypeDefinition *ValueTypeDefinition `json:"mapValueTypeDefinition,omitempty"`

	// This should only be present for object types.
	AttributeValueTypeDefinitions map[string]*AttributeType `json:"attributeValueTypeDefinitions,omitempty"`

	// This should only be present for function types.
	FunctionDefinition *FunctionDefinition `json:"functionDefinition,omitempty"`

	// This should only be present for "any" types that are union types.
	UnionValueTypeDefinitions []*ValueTypeDefinition `json:"unionValueTypeDefinitions,omitempty"`
}

Jump to

Keyboard shortcuts

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