mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add base template variables to API (#26425)
This commit is contained in:
@@ -41,6 +41,7 @@ type BaseManifest struct {
|
||||
DisplayName string `json:"display_name"`
|
||||
OS string `json:"os"`
|
||||
DefaultContext BaseDefaultContext `json:"default_context"`
|
||||
Variables []ModuleVariable `json:"variables"`
|
||||
}
|
||||
|
||||
// BaseDefaultContext holds default render values stored in base.json.
|
||||
@@ -192,6 +193,17 @@ func BaseTemplateIDs() []string {
|
||||
return ids
|
||||
}
|
||||
|
||||
// BaseVariables returns the user-facing variables for a given base
|
||||
// template ID. Computed variables are excluded. Returns nil if the
|
||||
// base is unknown or has no variables.
|
||||
func BaseVariables(exampleID string) []ModuleVariable {
|
||||
bases, err := loadBases()
|
||||
if err != nil || bases[exampleID] == nil {
|
||||
return nil
|
||||
}
|
||||
return bases[exampleID].Manifest.Variables
|
||||
}
|
||||
|
||||
// BaseTemplateFS returns a filesystem rooted at the given base template
|
||||
// directory within the embedded bases catalog. Returns an error if
|
||||
// exampleID is not a known base template.
|
||||
|
||||
Reference in New Issue
Block a user