mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
cc381e17e8
- Replace stub module with real code-server module manifest - Export ParseModulesFromFS(fs.FS) for test isolation (no sync.Once coupling) - Use sync.OnceValues for the cached loader - Validate module ID (non-empty, unique), pinned_version, and variable types during parsing; reject unknown types at load time - Normalize nil slices to empty in ToSDK() to prevent null in JSON responses - Distinguish fs.ErrNotExist from other ReadFile errors - Improve error messages to describe what failed, not internal plumbing - Rewrite tests with fstest.MapFS fixtures covering all variable types, default pointer, validation errors, and full SDK field assertions - Trim zero-value godoc comments - Add future tense to README for unimplemented behavior; link RFC
41 lines
1.8 KiB
Go
41 lines
1.8 KiB
Go
package codersdk
|
|
|
|
// TemplateBuilderVariableType enumerates the variable types
|
|
// supported by template builder module manifests.
|
|
type TemplateBuilderVariableType string
|
|
|
|
const (
|
|
TemplateBuilderVariableTypeString TemplateBuilderVariableType = "string"
|
|
TemplateBuilderVariableTypeNumber TemplateBuilderVariableType = "number"
|
|
TemplateBuilderVariableTypeBool TemplateBuilderVariableType = "bool"
|
|
)
|
|
|
|
type TemplateBuilderModuleVariable struct {
|
|
Name string `json:"name"`
|
|
Type TemplateBuilderVariableType `json:"type"`
|
|
Description string `json:"description"`
|
|
Default *string `json:"default,omitempty"`
|
|
Required bool `json:"required"`
|
|
Sensitive bool `json:"sensitive"`
|
|
BuilderManaged bool `json:"builder_managed"`
|
|
}
|
|
|
|
// TemplateBuilderModule is the API response type returned by
|
|
// GET /api/v2/templatebuilder/modules. The Version field is
|
|
// populated from the catalog manifest's PinnedVersion at serving time.
|
|
type TemplateBuilderModule struct {
|
|
ID string `json:"id"`
|
|
DisplayName string `json:"display_name"`
|
|
Description string `json:"description"`
|
|
Icon string `json:"icon"`
|
|
Category string `json:"category"`
|
|
Version string `json:"version"`
|
|
CompatibleOS []string `json:"compatible_os"`
|
|
ConflictsWith []string `json:"conflicts_with"`
|
|
Variables []TemplateBuilderModuleVariable `json:"variables"`
|
|
}
|
|
|
|
type TemplateBuilderModulesResponse struct {
|
|
Modules []TemplateBuilderModule `json:"modules"`
|
|
}
|