mirror of https://github.com/databricks/cli.git
fix aliasing
This commit is contained in:
parent
57a75190cc
commit
38d47e62f2
|
@ -3,6 +3,7 @@ package template
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/databricks/cli/libs/cmdio"
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
|
@ -120,7 +121,7 @@ func SelectTemplate(ctx context.Context) (TemplateName, error) {
|
||||||
|
|
||||||
func Get(name TemplateName) *Template {
|
func Get(name TemplateName) *Template {
|
||||||
for _, template := range allTemplates {
|
for _, template := range allTemplates {
|
||||||
if template.name == name {
|
if template.name == name || slices.Contains(template.aliases, string(name)) {
|
||||||
return &template
|
return &template
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,4 +86,7 @@ func TestTemplateGet(t *testing.T) {
|
||||||
tmpl := Get(TemplateName(name))
|
tmpl := Get(TemplateName(name))
|
||||||
assert.Nil(t, tmpl)
|
assert.Nil(t, tmpl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assert the alias works.
|
||||||
|
assert.Equal(t, Get(TemplateName("mlops-stack")).name, MlopsStacks)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue