Help us shape the future of Go! Take the 2026 Go Developer Survey

template

package
v2.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: BSD-3-Clause Imports: 45 Imported by: 0

Documentation

Overview

Package template owns compose templates and the template HTTP surface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterTemplates

func RegisterTemplates(api huma.API, templateService *TemplateService)

RegisterTemplates registers all template management endpoints.

Types

type ComposeTemplate added in v2.8.1

type ComposeTemplate struct {
	database.BaseModel

	Name        string                   `json:"name" unorm:"nfc" trim:"true" minLength:"1"`
	Description string                   `json:"description" unorm:"nfc" trim:"true"`
	Content     string                   `json:"content" gorm:"type:text"`
	EnvContent  *string                  `json:"envContent,omitempty" gorm:"type:text"`
	IsCustom    bool                     `json:"isCustom"`
	IsRemote    bool                     `json:"isRemote"`
	RegistryID  *string                  `json:"registryId,omitempty"`
	Registry    *TemplateRegistry        `json:"registry,omitempty" gorm:"foreignKey:RegistryID;references:ID"`
	Metadata    *ComposeTemplateMetadata `json:"metadata,omitempty" gorm:"embedded;embeddedPrefix:meta_"`
}

func (ComposeTemplate) TableName added in v2.8.1

func (ComposeTemplate) TableName() string

type ComposeTemplateMetadata added in v2.8.1

type ComposeTemplateMetadata struct {
	Version          *string  `json:"version,omitempty"`
	Author           *string  `json:"author,omitempty"`
	Tags             []string `json:"tags,omitempty" gorm:"serializer:json"`
	RemoteURL        *string  `json:"remoteUrl,omitempty"`
	EnvURL           *string  `json:"envUrl,omitempty"`
	DocumentationURL *string  `json:"documentationUrl,omitempty"`
	IconURL          *string  `json:"iconUrl,omitempty"`
	RegistryIconURL  *string  `json:"registryIconUrl,omitempty"`
}

type CreateTemplateInput

type CreateTemplateInput struct {
	Body template.CreateRequest
}

type CreateTemplateRegistryInput

type CreateTemplateRegistryInput struct {
	Body template.CreateRegistryRequest
}

type DeleteTemplateInput

type DeleteTemplateInput struct {
	ID string `path:"id" doc:"Template ID"`
}

type DeleteTemplateRegistryInput

type DeleteTemplateRegistryInput struct {
	ID string `path:"id" doc:"Registry ID"`
}

type DownloadTemplateInput

type DownloadTemplateInput struct {
	ID string `path:"id" doc:"Template ID"`
}

type FetchTemplateRegistryInput

type FetchTemplateRegistryInput struct {
	URL string `query:"url" required:"true" doc:"Registry URL"`
}

type GetAllTemplatesInput

type GetAllTemplatesInput struct{}

type GetDefaultTemplatesInput

type GetDefaultTemplatesInput struct{}

type GetTemplateContentInput

type GetTemplateContentInput struct {
	ID string `path:"id" doc:"Template ID"`
}

type GetTemplateInput

type GetTemplateInput struct {
	ID string `path:"id" doc:"Template ID"`
}

type GetTemplateRegistriesInput

type GetTemplateRegistriesInput struct{}

type ListTemplatesInput

type ListTemplatesInput struct {
	Search string `query:"search" doc:"Search query"`
	Sort   string `query:"sort" doc:"Column to sort by"`
	Order  string `query:"order" default:"asc" doc:"Sort direction"`
	Start  int    `query:"start" default:"0" doc:"Start index"`
	Limit  int    `query:"limit" default:"20" doc:"Items per page"`
	Type   string `query:"type" doc:"Filter by template type (comma-separated: false,true)"`
}

type Module

type Module struct {
	// contains filtered or unexported fields
}

func New

func New(service *TemplateService) *Module

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(api huma.API)

func (*Module) Service

func (m *Module) Service() *TemplateService

type SaveDefaultTemplatesInput

type SaveDefaultTemplatesInput struct {
	Body template.SaveDefaultTemplatesRequest
}

type TemplateHandler

type TemplateHandler struct {
	// contains filtered or unexported fields
}

TemplateHandler handles template management endpoints.

func (*TemplateHandler) CreateRegistry

CreateRegistry creates a new template registry.

func (*TemplateHandler) CreateTemplate

CreateTemplate creates a new templatetypes.

func (*TemplateHandler) DeleteRegistry

DeleteRegistry deletes a template registry.

func (*TemplateHandler) DeleteTemplate

DeleteTemplate deletes a templatetypes.

func (*TemplateHandler) DownloadTemplate

DownloadTemplate downloads a remote template to local storage.

func (*TemplateHandler) FetchRegistry

FetchRegistry fetches templates from a remote registry URL.

func (*TemplateHandler) GetAllTemplates

GetAllTemplates returns all templates without pagination.

func (*TemplateHandler) GetDefaultTemplates

GetDefaultTemplates returns the default compose and env templates.

func (*TemplateHandler) GetRegistries

GetRegistries returns all template registries.

func (*TemplateHandler) GetTemplate

GetTemplate returns a template by ID.

func (*TemplateHandler) GetTemplateContent

GetTemplateContent returns template content with parsed data.

func (*TemplateHandler) ListTemplates

ListTemplates returns a paginated list of templates.

func (*TemplateHandler) SaveDefaultTemplates

SaveDefaultTemplates saves the default compose and env templates.

func (*TemplateHandler) UpdateRegistry

UpdateRegistry updates a template registry.

func (*TemplateHandler) UpdateTemplate

UpdateTemplate updates a templatetypes.

type TemplateRegistry added in v2.8.1

type TemplateRegistry struct {
	database.BaseModel

	Name        string `json:"name" unorm:"nfc" trim:"true"`
	URL         string `json:"url"`
	Enabled     bool   `json:"enabled"`
	Description string `json:"description" unorm:"nfc" trim:"true"`
}

func (TemplateRegistry) TableName added in v2.8.1

func (TemplateRegistry) TableName() string

type TemplateService

type TemplateService struct {
	// contains filtered or unexported fields
}

func NewTemplateService

func NewTemplateService(ctx context.Context, db *database.DB, httpClient *http.Client, settingsService *settings.SettingsService) *TemplateService

func (*TemplateService) CreateRegistry

func (s *TemplateService) CreateRegistry(ctx context.Context, registry *TemplateRegistry) error

func (*TemplateService) CreateTemplate

func (s *TemplateService) CreateTemplate(ctx context.Context, template *ComposeTemplate) error

func (*TemplateService) DeleteRegistry

func (s *TemplateService) DeleteRegistry(ctx context.Context, id string) error

func (*TemplateService) DeleteTemplate

func (s *TemplateService) DeleteTemplate(ctx context.Context, id string) error

func (*TemplateService) DownloadTemplate

func (s *TemplateService) DownloadTemplate(ctx context.Context, remoteTemplate *ComposeTemplate) (*ComposeTemplate, error)

func (*TemplateService) FetchRaw

func (s *TemplateService) FetchRaw(ctx context.Context, rawURL string) ([]byte, error)

func (*TemplateService) FetchTemplateContent

func (s *TemplateService) FetchTemplateContent(ctx context.Context, template *ComposeTemplate) (composeContent, envContent string, err error)

func (*TemplateService) GetAllTemplates

func (s *TemplateService) GetAllTemplates(ctx context.Context) ([]ComposeTemplate, error)

func (*TemplateService) GetAllTemplatesPaginated

func (s *TemplateService) GetAllTemplatesPaginated(ctx context.Context, params pagination.QueryParams) ([]tmpl.Template, pagination.Response, error)

func (*TemplateService) GetComposeTemplate

func (s *TemplateService) GetComposeTemplate(ctx context.Context) string

func (*TemplateService) GetEnvTemplate

func (s *TemplateService) GetEnvTemplate(ctx context.Context) string

func (*TemplateService) GetRegistries

func (s *TemplateService) GetRegistries(ctx context.Context) ([]TemplateRegistry, error)

func (*TemplateService) GetRegistryFetchErrors

func (s *TemplateService) GetRegistryFetchErrors() map[string]string

GetRegistryFetchErrors returns a snapshot of the last fetch error per registry ID. An absent entry means the registry fetched successfully (or has never been attempted).

func (*TemplateService) GetSwarmStackEnvTemplate

func (s *TemplateService) GetSwarmStackEnvTemplate(ctx context.Context) string

func (*TemplateService) GetSwarmStackTemplate

func (s *TemplateService) GetSwarmStackTemplate(ctx context.Context) string

func (*TemplateService) GetTemplate

func (s *TemplateService) GetTemplate(ctx context.Context, id string) (*ComposeTemplate, error)

func (*TemplateService) GetTemplateContentWithParsedData

func (s *TemplateService) GetTemplateContentWithParsedData(ctx context.Context, id string) (*tmpl.TemplateContent, error)

GetTemplateContentWithParsedData returns template content along with parsed metadata

func (*TemplateService) SaveComposeTemplate

func (s *TemplateService) SaveComposeTemplate(ctx context.Context, content string) error

func (*TemplateService) SaveEnvTemplate

func (s *TemplateService) SaveEnvTemplate(ctx context.Context, content string) error

func (*TemplateService) SyncLocalTemplatesFromFilesystem

func (s *TemplateService) SyncLocalTemplatesFromFilesystem(ctx context.Context) (err error)

SyncLocalTemplatesFromFilesystem imports template folders from the templates directory, at most once per fsSyncInterval.

func (*TemplateService) UpdateRegistry

func (s *TemplateService) UpdateRegistry(ctx context.Context, id string, updates *TemplateRegistry) error

func (*TemplateService) UpdateTemplate

func (s *TemplateService) UpdateTemplate(ctx context.Context, id string, updates *ComposeTemplate) error

type UpdateTemplateInput

type UpdateTemplateInput struct {
	ID   string `path:"id" doc:"Template ID"`
	Body template.UpdateRequest
}

type UpdateTemplateRegistryInput

type UpdateTemplateRegistryInput struct {
	ID   string `path:"id" doc:"Registry ID"`
	Body template.UpdateRegistryRequest
}

Jump to

Keyboard shortcuts

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