template

package
v2.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: BSD-3-Clause Imports: 37 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"`
	Description string                   `json:"description"`
	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"`
}

type CreateTemplateInput

type CreateTemplateInput struct {
	Body templatetypes.CreateRequest
}

type CreateTemplateOutput

type CreateTemplateOutput struct {
	Body base.ApiResponse[templatetypes.Template]
}

type CreateTemplateRegistryInput

type CreateTemplateRegistryInput struct {
	Body templatetypes.CreateRegistryRequest
}

type CreateTemplateRegistryOutput

type CreateTemplateRegistryOutput struct {
	Body base.ApiResponse[templatetypes.TemplateRegistry]
}

type DeleteTemplateInput

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

type DeleteTemplateOutput

type DeleteTemplateOutput struct {
	Body base.ApiResponse[base.MessageResponse]
}

type DeleteTemplateRegistryInput

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

type DeleteTemplateRegistryOutput

type DeleteTemplateRegistryOutput struct {
	Body base.ApiResponse[base.MessageResponse]
}

type Dependencies

type Dependencies struct {
	Context    context.Context
	DB         *database.DB
	HTTPClient *http.Client
	Settings   *settings.SettingsService
}

type DownloadTemplateInput

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

type DownloadTemplateOutput

type DownloadTemplateOutput struct {
	Body base.ApiResponse[templatetypes.Template]
}

type FetchTemplateRegistryInput

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

type FetchTemplateRegistryOutput

type FetchTemplateRegistryOutput struct {
	Body base.ApiResponse[templatetypes.RemoteRegistry]
}

type GetAllTemplatesInput

type GetAllTemplatesInput struct{}

type GetAllTemplatesOutput

type GetAllTemplatesOutput struct {
	Body base.ApiResponse[[]templatetypes.Template]
}

type GetDefaultTemplatesInput

type GetDefaultTemplatesInput struct{}

type GetDefaultTemplatesOutput

type GetDefaultTemplatesOutput struct {
	Body base.ApiResponse[templatetypes.DefaultTemplatesResponse]
}

type GetTemplateContentInput

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

type GetTemplateContentOutput

type GetTemplateContentOutput struct {
	Body base.ApiResponse[templatetypes.TemplateContent]
}

type GetTemplateInput

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

type GetTemplateOutput

type GetTemplateOutput struct {
	Body base.ApiResponse[templatetypes.Template]
}

type GetTemplateRegistriesInput

type GetTemplateRegistriesInput struct{}

type GetTemplateRegistriesOutput

type GetTemplateRegistriesOutput struct {
	Body base.ApiResponse[[]templatetypes.TemplateRegistry]
}

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 ListTemplatesOutput

type ListTemplatesOutput struct {
	Body base.Paginated[templatetypes.Template]
}

type Module

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

func New

func New(deps Dependencies) *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 templatetypes.SaveDefaultTemplatesRequest
}

type SaveDefaultTemplatesOutput

type SaveDefaultTemplatesOutput struct {
	Body base.ApiResponse[base.MessageResponse]
}

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

func (h *TemplateHandler) CreateTemplate(ctx context.Context, input *CreateTemplateInput) (*CreateTemplateOutput, error)

CreateTemplate creates a new templatetypes.

func (*TemplateHandler) DeleteRegistry

DeleteRegistry deletes a template registry.

func (*TemplateHandler) DeleteTemplate

func (h *TemplateHandler) DeleteTemplate(ctx context.Context, input *DeleteTemplateInput) (*DeleteTemplateOutput, error)

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

func (h *TemplateHandler) GetTemplate(ctx context.Context, input *GetTemplateInput) (*GetTemplateOutput, error)

GetTemplate returns a template by ID.

func (*TemplateHandler) GetTemplateContent

GetTemplateContent returns template content with parsed data.

func (*TemplateHandler) ListTemplates

func (h *TemplateHandler) ListTemplates(ctx context.Context, input *ListTemplatesInput) (*ListTemplatesOutput, error)

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

func (h *TemplateHandler) UpdateTemplate(ctx context.Context, input *UpdateTemplateInput) (*UpdateTemplateOutput, error)

UpdateTemplate updates a templatetypes.

type TemplateRegistry added in v2.8.1

type TemplateRegistry struct {
	database.BaseModel

	Name        string `json:"name"`
	URL         string `json:"url"`
	Enabled     bool   `json:"enabled"`
	Description string `json:"description"`
}

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, url string) ([]byte, error)

func (*TemplateService) FetchTemplateContent

func (s *TemplateService) FetchTemplateContent(ctx context.Context, template *ComposeTemplate) (string, string, 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) ParseComposeServices

func (s *TemplateService) ParseComposeServices(ctx context.Context, composeContent string) []string

ParseComposeServices extracts service names from a compose file content using compose-go

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) error

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 templatetypes.UpdateRequest
}

type UpdateTemplateOutput

type UpdateTemplateOutput struct {
	Body base.ApiResponse[templatetypes.Template]
}

type UpdateTemplateRegistryInput

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

type UpdateTemplateRegistryOutput

type UpdateTemplateRegistryOutput struct {
	Body base.ApiResponse[base.MessageResponse]
}

Jump to

Keyboard shortcuts

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