MCPcopy Index your code
hub / github.com/coder/coder / templateName

Method templateName

cli/templatepush.go:391–411  ·  view source on GitHub ↗
(inv *serpent.Invocation)

Source from the content-addressed store, hash-verified

389}
390
391func (pf *templateUploadFlags) templateName(inv *serpent.Invocation) (string, error) {
392 args := inv.Args
393 if pf.stdin(inv) {
394 // Can't infer name from directory if none provided.
395 if len(args) == 0 {
396 return "", xerrors.New("template name argument must be provided")
397 }
398 return args[0], nil
399 }
400
401 if len(args) > 0 {
402 return args[0], nil
403 }
404 // Have to take absPath to resolve "." and "..".
405 absPath, err := filepath.Abs(pf.directory)
406 if err != nil {
407 return "", err
408 }
409 // If no name is provided, use the directory name.
410 return filepath.Base(absPath), nil
411}
412
413type createValidTemplateVersionArgs struct {
414 Name string

Callers 2

templateCreateMethod · 0.80
templatePushMethod · 0.80

Calls 2

stdinMethod · 0.95
NewMethod · 0.65

Tested by

no test coverage detected