Documentation
¶
Overview ¶
Package template owns compose templates and the template HTTP surface.
Index ¶
- func RegisterTemplates(api huma.API, templateService *TemplateService)
- type ComposeTemplate
- type ComposeTemplateMetadata
- type CreateTemplateInput
- type CreateTemplateOutput
- type CreateTemplateRegistryInput
- type CreateTemplateRegistryOutput
- type DeleteTemplateInput
- type DeleteTemplateOutput
- type DeleteTemplateRegistryInput
- type DeleteTemplateRegistryOutput
- type Dependencies
- type DownloadTemplateInput
- type DownloadTemplateOutput
- type FetchTemplateRegistryInput
- type FetchTemplateRegistryOutput
- type GetAllTemplatesInput
- type GetAllTemplatesOutput
- type GetDefaultTemplatesInput
- type GetDefaultTemplatesOutput
- type GetTemplateContentInput
- type GetTemplateContentOutput
- type GetTemplateInput
- type GetTemplateOutput
- type GetTemplateRegistriesInput
- type GetTemplateRegistriesOutput
- type ListTemplatesInput
- type ListTemplatesOutput
- type Module
- type SaveDefaultTemplatesInput
- type SaveDefaultTemplatesOutput
- type TemplateHandler
- func (h *TemplateHandler) CreateRegistry(ctx context.Context, input *CreateTemplateRegistryInput) (*CreateTemplateRegistryOutput, error)
- func (h *TemplateHandler) CreateTemplate(ctx context.Context, input *CreateTemplateInput) (*CreateTemplateOutput, error)
- func (h *TemplateHandler) DeleteRegistry(ctx context.Context, input *DeleteTemplateRegistryInput) (*DeleteTemplateRegistryOutput, error)
- func (h *TemplateHandler) DeleteTemplate(ctx context.Context, input *DeleteTemplateInput) (*DeleteTemplateOutput, error)
- func (h *TemplateHandler) DownloadTemplate(ctx context.Context, input *DownloadTemplateInput) (*DownloadTemplateOutput, error)
- func (h *TemplateHandler) FetchRegistry(ctx context.Context, input *FetchTemplateRegistryInput) (*FetchTemplateRegistryOutput, error)
- func (h *TemplateHandler) GetAllTemplates(ctx context.Context, _ *GetAllTemplatesInput) (*GetAllTemplatesOutput, error)
- func (h *TemplateHandler) GetDefaultTemplates(ctx context.Context, _ *GetDefaultTemplatesInput) (*GetDefaultTemplatesOutput, error)
- func (h *TemplateHandler) GetRegistries(ctx context.Context, _ *GetTemplateRegistriesInput) (*GetTemplateRegistriesOutput, error)
- func (h *TemplateHandler) GetTemplate(ctx context.Context, input *GetTemplateInput) (*GetTemplateOutput, error)
- func (h *TemplateHandler) GetTemplateContent(ctx context.Context, input *GetTemplateContentInput) (*GetTemplateContentOutput, error)
- func (h *TemplateHandler) ListTemplates(ctx context.Context, input *ListTemplatesInput) (*ListTemplatesOutput, error)
- func (h *TemplateHandler) SaveDefaultTemplates(ctx context.Context, input *SaveDefaultTemplatesInput) (*SaveDefaultTemplatesOutput, error)
- func (h *TemplateHandler) UpdateRegistry(ctx context.Context, input *UpdateTemplateRegistryInput) (*UpdateTemplateRegistryOutput, error)
- func (h *TemplateHandler) UpdateTemplate(ctx context.Context, input *UpdateTemplateInput) (*UpdateTemplateOutput, error)
- type TemplateRegistry
- type TemplateService
- func (s *TemplateService) CreateRegistry(ctx context.Context, registry *TemplateRegistry) error
- func (s *TemplateService) CreateTemplate(ctx context.Context, template *ComposeTemplate) error
- func (s *TemplateService) DeleteRegistry(ctx context.Context, id string) error
- func (s *TemplateService) DeleteTemplate(ctx context.Context, id string) error
- func (s *TemplateService) DownloadTemplate(ctx context.Context, remoteTemplate *ComposeTemplate) (*ComposeTemplate, error)
- func (s *TemplateService) FetchRaw(ctx context.Context, url string) ([]byte, error)
- func (s *TemplateService) FetchTemplateContent(ctx context.Context, template *ComposeTemplate) (string, string, error)
- func (s *TemplateService) GetAllTemplates(ctx context.Context) ([]ComposeTemplate, error)
- func (s *TemplateService) GetAllTemplatesPaginated(ctx context.Context, params pagination.QueryParams) ([]tmpl.Template, pagination.Response, error)
- func (s *TemplateService) GetComposeTemplate(ctx context.Context) string
- func (s *TemplateService) GetEnvTemplate(ctx context.Context) string
- func (s *TemplateService) GetRegistries(ctx context.Context) ([]TemplateRegistry, error)
- func (s *TemplateService) GetRegistryFetchErrors() map[string]string
- func (s *TemplateService) GetSwarmStackEnvTemplate(ctx context.Context) string
- func (s *TemplateService) GetSwarmStackTemplate(ctx context.Context) string
- func (s *TemplateService) GetTemplate(ctx context.Context, id string) (*ComposeTemplate, error)
- func (s *TemplateService) GetTemplateContentWithParsedData(ctx context.Context, id string) (*tmpl.TemplateContent, error)
- func (s *TemplateService) ParseComposeServices(ctx context.Context, composeContent string) []string
- func (s *TemplateService) SaveComposeTemplate(ctx context.Context, content string) error
- func (s *TemplateService) SaveEnvTemplate(ctx context.Context, content string) error
- func (s *TemplateService) SyncLocalTemplatesFromFilesystem(ctx context.Context) error
- func (s *TemplateService) UpdateRegistry(ctx context.Context, id string, updates *TemplateRegistry) error
- func (s *TemplateService) UpdateTemplate(ctx context.Context, id string, updates *ComposeTemplate) error
- type UpdateTemplateInput
- type UpdateTemplateOutput
- type UpdateTemplateRegistryInput
- type UpdateTemplateRegistryOutput
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 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 (*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 ¶
func (h *TemplateHandler) CreateRegistry(ctx context.Context, input *CreateTemplateRegistryInput) (*CreateTemplateRegistryOutput, error)
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 ¶
func (h *TemplateHandler) DeleteRegistry(ctx context.Context, input *DeleteTemplateRegistryInput) (*DeleteTemplateRegistryOutput, error)
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 ¶
func (h *TemplateHandler) DownloadTemplate(ctx context.Context, input *DownloadTemplateInput) (*DownloadTemplateOutput, error)
DownloadTemplate downloads a remote template to local storage.
func (*TemplateHandler) FetchRegistry ¶
func (h *TemplateHandler) FetchRegistry(ctx context.Context, input *FetchTemplateRegistryInput) (*FetchTemplateRegistryOutput, error)
FetchRegistry fetches templates from a remote registry URL.
func (*TemplateHandler) GetAllTemplates ¶
func (h *TemplateHandler) GetAllTemplates(ctx context.Context, _ *GetAllTemplatesInput) (*GetAllTemplatesOutput, error)
GetAllTemplates returns all templates without pagination.
func (*TemplateHandler) GetDefaultTemplates ¶
func (h *TemplateHandler) GetDefaultTemplates(ctx context.Context, _ *GetDefaultTemplatesInput) (*GetDefaultTemplatesOutput, error)
GetDefaultTemplates returns the default compose and env templates.
func (*TemplateHandler) GetRegistries ¶
func (h *TemplateHandler) GetRegistries(ctx context.Context, _ *GetTemplateRegistriesInput) (*GetTemplateRegistriesOutput, error)
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 ¶
func (h *TemplateHandler) GetTemplateContent(ctx context.Context, input *GetTemplateContentInput) (*GetTemplateContentOutput, error)
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 ¶
func (h *TemplateHandler) SaveDefaultTemplates(ctx context.Context, input *SaveDefaultTemplatesInput) (*SaveDefaultTemplatesOutput, error)
SaveDefaultTemplates saves the default compose and env templates.
func (*TemplateHandler) UpdateRegistry ¶
func (h *TemplateHandler) UpdateRegistry(ctx context.Context, input *UpdateTemplateRegistryInput) (*UpdateTemplateRegistryOutput, error)
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) 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]
}